Labels on stacked vertical bar

2005-11-07
2013-01-13
  • Thierry Collogne

    Hi,

    I'm trying to display labels on top oif each bar in the chart.
    I have used a preprocessor using implementing following code

    public class AlarmChartPostProcessor implements ChartPostProcessor 

        public void processChart( Object chart, Map params ) 
        { 
            CategoryPlot plot = (CategoryPlot)((JFreeChart)chart).getPlot(); 
            CategoryItemRenderer r1=(CategoryItemRenderer)plot.getRenderer();
            r1.setItemLabelsVisible(new Boolean(true));       
        } 
    }

    I get no errors, but the labels are not displayed. Is it possible that no labels are available? do I have to fill the values for the labels, or does this go automaticly?

     
    • Thierry Collogne

      I have managed to make it work partialy.
      I used this code for my preprocessor

      public class AlarmChartPostProcessor implements ChartPostProcessor 

          public void processChart( Object chart, Map params ) 
          { 
              CategoryPlot plot = (CategoryPlot)((JFreeChart)chart).getPlot(); 
              CategoryItemRenderer r1=(CategoryItemRenderer)plot.getRenderer();
              r1.setItemLabelsVisible(new Boolean(true));       
              CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator("{0}", new DecimalFormat("0"));
              r1.setItemLabelFont(new Font("Serif", Font.PLAIN, 10));
              r1.setItemLabelGenerator(generator);   
             
          } 
      }

      The only problem is that the labels are displayed inside the bar, not above it. Due to the fact that the values in the chart tend to be wide apart (0-15000), the lower values are not displayed because the bar is not high enough.

      Is it possible to place the labels above the bars?

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks