Hi,
I am working on vertical BarCharts.I am trying to draw BarCharts for Countries(x-axis) and
products(y-axis).This data is comming from data_base. For four to six countries my code is
working well.Whenever I am trying to display chart for more than six countries,
it is overlapping on one another.How can I extend the x-axis to overcome this problem?
If you have any example please send me.Iam sending the code I've used:
DefaultCategoryDataSource myDataSource = new DefaultCategoryDataSource(arrSelectedProductsList,arrSelectedCountryList,data);
JFreeChart myChart = JFreeChart.createVerticalBarChart(myDataSource);
JFreeChartPanel myChartPanel = new JFreeChartPanel(myChart);
myChart.setTitle("Installs Report");
VerticalBarPlot myPlot =(VerticalBarPlot)myChart.getPlot();
Axis myHorizontalAxis = myPlot.getAxis(Plot.HORIZONTAL_AXIS);
myHorizontalAxis.setLabel("Country");
Axis myVerticalAxis = myPlot.getAxis(Plot.VERTICAL_AXIS);
myVerticalAxis.setLabel("Installs Count");
myDataSource.setSeriesNames(arrSelectedProductsList);
myDataSource.setCategories(arrSelectedCountryList);
add(myChartPanel);
Thanks in Advance,
Kiran
Overlapping Labels on X-Axis
RE: Overlapping Labels on X-Axis
Kiran,
All I can suggest is using vertical labels on your category axis, and maybe changing to a smaller font...that will buy you a few extra categories.
The code you need to add to HorizontalCategoryAxis (this method should have been there already, but isn't):
public void setVerticalCategoryLabels(boolean flag) {
this.verticalCategoryLabels = flag;
this.notifyListeners(new com.jrefinery.chart.event.AxisChangeEvent(this));
}
Then where you have:
myHorizontalAxis.setLabel("Country");
...add...
myHorizontalAxis.setVerticalCategoryLabels(true);
Regards,
DG.
All I can suggest is using vertical labels on your category axis, and maybe changing to a smaller font...that will buy you a few extra categories.
The code you need to add to HorizontalCategoryAxis (this method should have been there already, but isn't):
public void setVerticalCategoryLabels(boolean flag) {
this.verticalCategoryLabels = flag;
this.notifyListeners(new com.jrefinery.chart.event.AxisChangeEvent(this));
}
Then where you have:
myHorizontalAxis.setLabel("Country");
...add...
myHorizontalAxis.setVerticalCategoryLabels(true);
Regards,
DG.