I am using JDK1.5 and JFreeChart 1.0.13.
I need to generate stacked bar charts either horizontally or vertically depending upon user's input.
I was able to generate the bar labels at the top of each bar with the following code
Code: Select all
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
Code: Select all
chart = ChartFactory.createStackedBarChart(chartTitle,null,null,dataset,PlotOrientation.HORIZONTAL,true,true,false);
I want a chart as follows:
But currently, am getting as follows:
One more problem am facing is with the value marker. Following is the code I have used in my code.
Code: Select all
Marker mark = new ValueMarker(0);
mark.setPaint(Color.black);
mark.setStroke(new BasicStroke(1.0f));
plot.addRangeMarker(mark);

With the same code for vertical orientation, the chart displays as follows.
Please let me know how to solve these problems.