import java.awt.*;

public class BarDisplay implements ChartDisplay{

    protected Color fillColor[] = {Color.green, Color.red, Color.blue, Color.black, Color.yellow};
	protected int total = 0;

	public void display(Graphics g, String[] categories, int[] amount, int catCount, Dimension d) {
		for (int i=0;i<catCount;i++){
			  total += amount[i];
		}
	    for (int i=0;i<catCount;i++){
				g.setColor(Color.black);
				g.drawString(categories[i],20, (i+1)*20 + 250);
				g.setColor(fillColor[i]);
				g.fillRect(100, (i+1)*20 + 240,10,10);
				double temp = amount[i];
				temp = temp/(double)total * 250;
				g.fillRect(30, 50 + i * 50,(int)temp, 50);
		}
    }
}