Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes JFreeChart - Stacked Bar Chart Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JFreeChart - Stacked Bar Chart" Watch "JFreeChart - Stacked Bar Chart" New topic
Author

JFreeChart - Stacked Bar Chart

Achal Jalan
Greenhorn

Joined: Nov 23, 2004
Posts: 21
I have created a program to draw a stacked bar chart using jfreechart. The colours in the bar are decided on their own is their any way that I could assign the different colours in the bars.

eg :
On the x-axis I have "customer name"
On the y-axis I have "number of days"
The bars are created on the basis of what was done with the customer and how much time spent. So if it was "a meeting" then I would like the colour red , if it was "lunch" then green...

The code I have used is as below
ValueAxis valueAxis = new NumberAxis("Number of Days");
sRenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
Plot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, sRenderer);
JFreeChart chart = new JFreeChart("", FreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white);

try {
ChartUtilities.saveChartAsJPEG(new File(fileName), chart, 1024,768);
}catch (Exception e) {System.out.println(e);}



Any help will be greatly appreciated..
Thanks
AJ
 
 
subject: JFreeChart - Stacked Bar Chart