aspose file tools
The moose likes Java in General and the fly likes JFreeChart - Stacked Bar Chart Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JFreeChart - Stacked Bar Chart
 
Similar Threads
Barchart diagrams in jsp
A Cewolf ChartPostProcessor with dynamic variable
Dollar Symbol at Vertical Bar in StackedBarChar in JFreeChart
Setting unveven intervals in JFreechart
Customizing Y Axis in JFreechart