Vertical category labels in Vertical Bar Chart

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

Vertical category labels in Vertical Bar Chart

Post by Bill Knight » Mon May 20, 2002 7:31 pm

Hi. I'm a new user to JFreeChart and have an ultra-picky question: I'm generating a vertical bar chart with one series and setting the HorizontalCategoryAxis to use VerticalCategoryLabels but the center of the labels don't line up with the center of the category bars. I can send an e-mail for an example but, with 40 values in a 800x600 chart, the labels appear to be in between the bars so it's hard to tell which label goes with which bar. Here's the code that I'm using (with certain values hard-coded to represent the final result):

__________________________________________________________

Double[] ovalues1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
Number[][] dataArray = {ovalues1};
Object[] categoryArray = ovalues1;

DefaultCategoryDataset categoryData = new DefaultCategoryDataset(dataArray);
categoryData.setCategories(categoryArray);

JFreeChart chart = ChartFactory.createVerticalBarChart("Vertical Bar Chart", "Categories", null, categoryData, true);
chart.setBackgroundPaint(new GradientPaint(0, 0, java.awt.Color.white, 1000, 0, java.awt.Color.red));
Plot bPlot = chart.getPlot();
HorizontalCategoryAxis cAxis = (HorizontalCategoryAxis)bPlot.getAxis(Axis.HORIZONTAL);
cAxis.setVerticalCategoryLabels(true);
ChartUtilities.saveChartAsJPEG(new File("JFreeChart.jpg"), chart, 800, 600);

__________________________________________________________

Hopefully someone else also sees the same results I do and/or can suggest what I'm doing wrong or could do different.

Thanks.

Bill Knight
bknight@synquest.com

David Gilbert

Re: Vertical category labels in Vertical Bar Chart

Post by David Gilbert » Mon May 20, 2002 10:42 pm

There is a bug in one of the JDKs (one of the 1.3.something releases) that caused rotated text to be shifted to the right slightly. I get this problem with the JDK that ships with JBuilder 5, but not when I use the IBM JDK1.3 (both on Linux). I haven't tried 1.4 yet.

That might be the problem you are seeing too...though I'm only guessing.

Regards,

DG.

Bill Knight

Re: Vertical category labels in Vertical Bar Chart

Post by Bill Knight » Tue May 21, 2002 3:29 pm

Interesting thought. I'll try some other JDK versions.

Thanks for the speedy response! :)

bk

Locked