itchytoes Posted June 11, 2008 Share Posted June 11, 2008 Hi -- I have a stacked bar chart for which I want the values to show within each of the bar sections. I once got the line charts to show values on the points by using a customizer class with setSeriesItemLabelsVisible(). Is there a way to do this with the stacked bar chart? Thanks Betty Link to comment Share on other sites More sharing options...
teodord Posted June 11, 2008 Share Posted June 11, 2008 Hi, For anything that represents a special chart setting as this, you have to look into the JFreeChart documentation to see if it is possible and how.With a chart customizer we simply give you the possibility to use the JFreeChart API directly and do whatever it is able to do. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
bklawans Posted June 11, 2008 Share Posted June 11, 2008 You need to do more than call setSeriesItemLabelsVisibile - you need to add a label generator the chart's CategoryItemRenderer. Then call setItemLabelsVisible(true) on the renderer to see the labels. Teodor is right - get a copy of the JFreeChart Developers docs for detailed documentation and sample code. -Barry Link to comment Share on other sites More sharing options...
itchytoes Posted June 12, 2008 Author Share Posted June 12, 2008 Hi -- thanks for the suggestion. I've actually been using Jfreechart 1.0.9 for my reports and I've done quite a bit of customization. For a line chart, I did use setBaseItemLabelGenerator(new StandardCatgetoryItemLabelGenerator()) followed bysetBaseItemLabelFont() and setSeriesItemLabelsVisible() and I got labels showing over the point. My problem is with the stacked bar chart. I don't know if it is possible to get the value showing within the bar. I will fuss with it some more. Betty Link to comment Share on other sites More sharing options...
bklawans Posted June 12, 2008 Share Posted June 12, 2008 Hi Betty, That's an area of JFreeChart I haven't played around with, but the samples included with JFreeChart show stacked bars with the values displayed inside each segment of the bar, so it must be possible. Once you get it working, please post what you did hear so other people can benefit from it. Thanks,Barry Link to comment Share on other sites More sharing options...
itchytoes Posted June 14, 2008 Author Share Posted June 14, 2008 Hi -- I got it working, and I believe the original ideas/suggestions posted were all correct. I'm not sure what I left out earlier. In any case, the following works:BarRenderer bsr = (BarRenderer) plot.getRenderer();bsr.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); Font itemLabelFont = bsr.getBaseItemLabelFont(); bsr.setBaseItemLabelFont(itemLabelFont.deriveFont(new Float(8.0))); bsr.setBaseItemLabelsVisible(true); bsr.setItemLabelsVisible(true); I'm not sure if I need that call to setBaseItemLabelsVisible or not. Betty 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