• Line chart - setting y-axis range

    By Tom M Rhodes 1 decade ago

    Hi,

    I have a chart of % successful items which usually is > 90% for all items.  The line chart defaults the y-axis to start at 0.

    Is there a way to specify the min and max of the y-axis values so I could set to say 80 and 100 and therefore have a better display of the data I am interested in?

    • You can try this code

      By Naveen Maurya 1 decade ago

      In the class Common in org.openntf.javacharts package you will find a method getBALJFreeChart. Their after line number 301 (plot.setRowRenderingOrder(SortOrder.DESCENDING);) you can add this code:

       

      NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
      
      rangeAxis.setRange(80, 100);
      

      This would set your axis to start from 80 and end at 100. Word of caution, this would set the axis of all the charts i.e. Bar, Bar 3D, Line, Line 3D, Stacked Area, Stacked bar & Waterfall. You will have to do a bit of coding their to get it work only for line chart or you could add a new property to BALChart custom control.

      But this is good idea to include in my next version! Smile

      • Thanks for the quick response

        By Tom Rhodes 1 decade ago

        Unfortunately I need the default setting for other charts.

        I have got round it by charting the % fails instead of %successes (so y-axis is from 0 to 20%) and this works well for my requirement.

        Would be a great improvement if you were able to allow these values to be set individually in a future release.  I'll keep my eye out here for any news.

        • Java Charts v1.3 is available

          By Naveen Maurya 1 decade ago

          Hi Tom,

           

          I have updated Java Charts to include your suggestion. The current update has few other enhancements which you can use in your future projects. Smile

           

          Regards,

          Naveen