Muyerina Posted April 29, 2008 Share Posted April 29, 2008 Hello everybody: I'm having problems with my chart customizer using i-Report. My class 'GraficoChartCustomizer' compile and i-Report can recognise it when i specify it in the chart properties, but i-Report ignore the changes i do in the class, the graphic seems equal. Anyone can help me? All i want to do is change the font of the rectangle's label. size=300]http://i22.photobucket.com/albums/b320/Muyerina/untitled.jpg My customize class is the following:Code:Thank you Link to comment Share on other sites More sharing options...
svenn Posted April 29, 2008 Share Posted April 29, 2008 Are you just try to change the font on the 11 or change the font on all the items? Link to comment Share on other sites More sharing options...
Muyerina Posted April 29, 2008 Author Share Posted April 29, 2008 All the items, of course, i have round the 11 to point what label is, not in the axis or out of the graphic. I want to change the font of all the numbers that are in the rectangles. Anyone knows how can i do that? Link to comment Share on other sites More sharing options...
mbj_ravian Posted April 30, 2008 Share Posted April 30, 2008 hi Muyerina! i have seen the image u had posted.... i m getting a problem of showing the lables inside the bars of the barChart... by default ireport shows the label expression as Chart position______________________________BarChart : top of the bars3DBar : inside top of bars_______________________________ can you please help me in showing the lable expression of 3DBarChart on the top of the bars! further more how come customizer class can help me in this regard? and how does it works?thnks alot in adv.Post edited by: mbj_ravian, at: 2008/04/30 16:17 Link to comment Share on other sites More sharing options...
greylimbo Posted May 9, 2008 Share Posted May 9, 2008 This is an example of a chart customizer I have working, I jar up the class and add a classpath in ireports. eg: Options->Classpath->Add jar and viola it works like a charm. Code:public class BillingChartCustomerizer implements JRChartCustomizer{ public void customize(final JFreeChart chart, final JRChart jasperChart) { final GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); final KeyToGroupMap map = new KeyToGroupMap("C1"«»); map.mapKeyToGroup("group1", "C1"«»); map.mapKeyToGroup("group2", "C1"«»); map.mapKeyToGroup("group3", "C2"«»); renderer.setSeriesToGroupMap(map); renderer.setItemMargin(0.0); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); plot.setRenderer(renderer); }} Link to comment Share on other sites More sharing options...
Muyerina Posted May 13, 2008 Author Share Posted May 13, 2008 greylimbo, thanks a lot for your customizer class. Now it seems that the iReport do the changes of my customizer class, but the label of the rectangles has disapeared. Why? i dont know :dry: my new code:Code:StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setItemMargin(0.9); renderer.setBaseItemLabelFont(new Font("Sans", Font.PLAIN, 6)); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer); I tried a lot of methods (setBaseItemLabelFont, setSeriesItemLabelFont, setFixedLegendItems...) but no one works. Anyone can help me? Link to comment Share on other sites More sharing options...
Muyerina Posted May 16, 2008 Author Share Posted May 16, 2008 I've found it!!! This is the code of my Customize class that modify the item label of a rectangle in a StackedBarChart. Code:import net.sf.jasperreports.engine.JRChartCustomizer;import net.sf.jasperreports.engine.JRChart;import org.jfree.chart.JFreeChart;import org.jfree.chart.renderer.category.StackedBarRenderer;import java.awt.*;import org.jfree.chart.plot.CategoryPlot;public class GraficoChartCustomizer implements JRChartCustomizer{ protected static final java.awt.Font ITEM_FONT = new java.awt.Font("Arial", Font.ITALIC, 6); public void customize(final JFreeChart chart, final JRChart jasperChart) { CategoryPlot plot = chart.getCategoryPlot(); StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setBaseItemLabelFont(ITEM_FONT); }} I hope this help you. 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