David
I have the BarChartDemo with 13 categories and 3 series each. Because the categories' labels are too long I'm rotating them to the vertical position in order to avoid overlapping. But the label instead of staying below the center series stays below the right series? Why?
...
CategoryAxis domainAxis = plot.getDomainAxis();
CategoryLabelPosition position = new CategoryLabelPosition(
RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_CENTER, -Math.PI / 2.0
);
domainAxis.setBottomCategoryLabelPosition(position);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
...
Rgds
Luis
BarChartDemo - rotation of x-axis labels
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
The TextBlockAnchor defines which point on the label is aligned to the (x, y) location on the screen. At the moment, you are aligning the TOP_RIGHT of the text to that point - try CENTER_RIGHT and the alignment should be what you are looking for.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Label Wrapping
Hi Guys,
Thanks for the tips - I've had to set my label vertically as well because they are so long. But now they're wrapping and overlapping. Any idea how to disable the text wrapping for the label rectangle, or even a way to increase the Label's rectangles size?
Thanks in advance,
Cochese
Thanks for the tips - I've had to set my label vertically as well because they are so long. But now they're wrapping and overlapping. Any idea how to disable the text wrapping for the label rectangle, or even a way to increase the Label's rectangles size?
Thanks in advance,
Cochese
-
- Posts: 22
- Joined: Thu Jan 29, 2004 8:28 pm
BarChartDemo - rotation of x-axis labels
Try this:
CategoryPlot oPlot;
CategoryAxis oAxis;
oPlot = oChart.getCategoryPlot();
oAxis = oPlot.getDomainAxis();
oAxis.setCategoryMargin(0.25); // twenty-five percent
oAxis.setLowerMargin(0.04); // four percent
oAxis.setUpperMargin(0.04); // four percent
oAxis.setMaxCategoryLabelWidthRatio(10);
// I played with drawing a single chart with either VERTICAL or HORIZONTAL, and need this only for vertical orientation
if(oChartOrientation == PlotOrientation.VERTICAL)
oAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
Good luck!
phamdinhnguyen
CategoryPlot oPlot;
CategoryAxis oAxis;
oPlot = oChart.getCategoryPlot();
oAxis = oPlot.getDomainAxis();
oAxis.setCategoryMargin(0.25); // twenty-five percent
oAxis.setLowerMargin(0.04); // four percent
oAxis.setUpperMargin(0.04); // four percent
oAxis.setMaxCategoryLabelWidthRatio(10);
// I played with drawing a single chart with either VERTICAL or HORIZONTAL, and need this only for vertical orientation
if(oChartOrientation == PlotOrientation.VERTICAL)
oAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
Good luck!
phamdinhnguyen