• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFreeChart - Stacked Bar Chart  RSS feed

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);

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

Any help will be greatly appreciated..
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!