Category label on/above bar?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Category label on/above bar?

Post by mhilpert » Thu Jun 29, 2006 10:54 am

I would like to have a bar chart with the category labels shown on or on top of the bars instead of below the category axis. Is this possible?
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

balpo
Posts: 2
Joined: Thu Jul 06, 2006 10:03 pm

not Possible?

Post by balpo » Thu Jul 06, 2006 10:23 pm

Hi mhilpert.

Code: Select all

JFreeChart jfreechart = ChartFactory.createBarChart3D("Reglas @Por", "", "Incidencias", categorydataset, PlotOrientation.VERTICAL, true, true, false);
		CategoryPlot categoryplot = jfreechart.getCategoryPlot();
		categoryplot.setDomainGridlinesVisible(true);
		CategoryAxis categoryaxis = categoryplot.getDomainAxis();
		categoryaxis.setCategoryLabelPositionOffset(categoryaxis.getMaximumCategoryLabelLines());
		categoryaxis.setTickLabelPaint(Color.RED);
		BarRenderer3D barrenderer = (BarRenderer3D) categoryplot.getRenderer();
		barrenderer.setItemMargin(0.10000000000000001D);
		barrenderer.setItemLabelGenerator(new BarChartDemo7.LabelGenerator());
		barrenderer.setItemLabelsVisible(true);
		barrenderer.setDrawBarOutline(false);
		ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER, TextAnchor.CENTER, 0D);
		barrenderer.setPositiveItemLabelPosition(itemlabelposition);
		ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER, TextAnchor.CENTER, 0D);
		barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);
		categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
This works for me, I just want to make the bars wider.

Hope this helps.

Balpo.

Locked