How to Set Category Label Position At the Bottom ?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
nilayparikh
Posts: 1
Joined: Tue Jan 04, 2011 7:51 am
antibot: No, of course not.

How to Set Category Label Position At the Bottom ?

Post by nilayparikh » Tue Jan 04, 2011 8:00 am

I am creating the bar chart but I have some problem :

I have a sample data like this :
Column-1
raw1 2
raw2 4
raw3 8
raw4 16
raw5 32
raw6 64

Code :
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(2, "row1", "column1");
dataset.addValue(4, "row2", "column1");
dataset.addValue(8, "row3", "column1");
dataset.addValue(16, "row4", "column1");
dataset.addValue(32, "row5", "column1");
dataset.addValue(64, "row6", "column1");
JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart For Incoming ASR",
"Routetype",
"Incoming ASR",
dataset,
PlotOrientation.VERTICAL,
true, true, true
);

using the simple code , I get the lexicals at the bottom showing which raw(color) belongs to which bar. But I want to show the raw lable exactle below the respective bars.


I tried the following code to set the Category Labels at the bottom but it didnt work :
CategoryPlot p = chart.getCategoryPlot();
CategoryAxis axis = p.getDomainAxis();
CategoryLabelPositions pos = axis.getCategoryLabelPositions();
CategoryLabelPositions bottom = new CategoryLabelPositions(CategoryLabelPositions.UP_90,CategoryLabelPositions.DOWN_90,CategoryLabelPositions.STANDARD,CategoryLabelPositions.STANDARD);
axis.setCategoryLabelPositions(CategoryLabelPositions.replaceBottomPosition(pos, bottom));

Reply me soon....Thank you in advance.

Locked