pb of orientation of the value labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Claire Leriche

pb of orientation of the value labels

Post by Claire Leriche » Thu Jul 18, 2002 10:11 am

Hi,

Despite the use of the setVerticalLabels(boolean flag) method, the labels which indicate the values of the bars in bar charts remain horizontal.
(the boolean changes normally). What did I do wrong ?


example :
CategoryPlot plot = chart.getCategoryPlot();
plot.setLabelsVisible(true); (OK)
plot.setVerticalLabels(true);

Thanks

Harald Faber

Re: pb of orientation of the value labels

Post by Harald Faber » Thu Jul 18, 2002 10:48 am

Not sure what you did completely, maybe you should check e.g. for

NumberAxis valueAxis = new VerticalNumberAxis(valueAxisLabel);
in the ChartFactory. The example completely shows:

------------------------------------------------------------
public static JFreeChart createStackedVerticalBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset data,
boolean legend) {

CategoryAxis categoryAxis = new HorizontalCategoryAxis(categoryAxisLabel);

NumberAxis valueAxis = new VerticalNumberAxis(valueAxisLabel);

CategoryItemRenderer renderer = new StackedVerticalBarRenderer();

Plot plot = new VerticalCategoryPlot(data, categoryAxis, valueAxis, renderer);

JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
------------------------------------------------------------
So you probably should check your code for horizontal and vertical axis with the according labels. Usually, at least here, the label is vertical and the values are horizontal. Setting the direction is not necessary.

Claire Leriche

Re: pb of orientation of the value labels

Post by Claire Leriche » Thu Jul 18, 2002 1:50 pm

I use the ChartFactory to create my vertical bar chart. I thought I would'nt have to deal with the horizontal and vertical axis. What I want to put vertical direction is the labels which appear on top of each bar with the value of the bar inside.

here is my code :

double[][] data = new double[][] {
{ 111.0, 444.0, 377.0, 555.0, 554.0, 777.0, 477.0, 148.0 },
{ 555.0, 443.0, 666.0, 888.0, 444.0, 455.0, 222.0, 111.0 },
{ 444.0, 344.0, 244.0, 344.0, 644.0, 344.0, 444.0, 344.0 }
};
DefaultCategoryDataset dataset = new DefaultCategoryDataset(data);

JFreeChart chart = ChartFactory.createVerticalBarChart
("Title", "Category", "Value", dataset, true );

CategoryPlot plot = chart.getCategoryPlot();
// label data points with values...
plot.setLabelsVisible(true); //OK
plot.setVerticalLabels(true); //THIS LINE SEEMS NOT TO WORK !
System.out.println("isVertical? :"+plot.getVerticalLabels());//the boolean changes normally

Locked