Carrm Posted August 13, 2018 Share Posted August 13, 2018 I'm struggling with Jasper to display value labels on top of the bars of my chart. What I want to generate: I use Jaspersoft Studio, and I checked the "Show Labels" box in "Chart Plot" tab. For test purpose, I use some sort of red and violet for the item label font color and background color, which should be quite visible on the bar chart.My jrxml file looks like this: <barPlot isShowLabels="true" isShowTickMarks="false"> <plot backcolor="#FFFFFF" labelRotation="0.0"> <seriesColor seriesOrder="0" color="#6D74BC"/> </plot> <itemLabel color="#E86841" backgroundColor="#C429B5"> <font fontName="Arial" size="25" isBold="true" isItalic="true" isUnderline="true" isStrikeThrough="true"/> </itemLabel> <categoryAxisFormat labelRotation="0.0"> <axisFormat labelColor="#000000" tickLabelColor="#6D74BC" verticalTickLabels="true" axisLineColor="#6D74BC"> <labelFont> <font fontName="Arial" size="8"/> </labelFont> <tickLabelFont> <font fontName="Arial" size="8"/> </tickLabelFont> </axisFormat> </categoryAxisFormat> <valueAxisLabelExpression><![CDATA[$P{unitFact}]]></valueAxisLabelExpression> <valueAxisFormat> <axisFormat labelColor="#6D74BC" tickLabelColor="#6D74BC" verticalTickLabels="false" axisLineColor="#6D74BC"> <labelFont> <font fontName="Arial" size="8"/> </labelFont> <tickLabelFont> <font fontName="Arial" size="8"/> </tickLabelFont> </axisFormat> </valueAxisFormat> </barPlot> I also tried to use a customizer:@Overridepublic void customize(JFreeChart jFreeChart, JRChart jrChart) { CategoryPlot plot = (CategoryPlot)jFreeChart.getPlot(); plot.getRenderer() .setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));}I couldn't make it work, I have the bar chart above but without the 110/760 labels.What should I do in order to show these values? Link to comment Share on other sites More sharing options...
Solution Carrm Posted August 14, 2018 Author Solution Share Posted August 14, 2018 I created a new bar chart from scratch and everything worked fine with the same config. After some digging, I figured out that when I first created the initial chart, I put a blank string as the expression to use for labels, thinking that it was the axis label (I didn't want the Value axis' labels to show up). I fixed that, and the first bar chart worked as well. Dumb way to lose days of work. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now