An empty chart is displayed when the chart contains only one data point with the bar renderer

Article ID: 2267
Last updated: 29 May, 2018
Article ID: 2267
Last updated: 29 May, 2018
Revision: 3
Views: 720
Posted: 26 Oct, 2007
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

Why an empty chart is displayed when the chart contains only one data point with the bar renderer?

Answer

In order to display a data point, the bar renderer must calculate the width and height of the bar using the x and y axis data range, respectively. When there is only one data point (0, 10) in the data source, the data range of the x-axis is [0,0] and y-axis is [10,10]. With both data ranges being 0, an empty chart will be displayed. You can display a bar for the single data point chart in the following ways:

  1. By explicitly set the data range for both x and y axis using the following methods:
    • IlvChart.getXAxis()
    • lvChart.getYAxis(int index)
    • IlvAxis.setDataRange(int min, int max)
    • IlvAxis.setDataRange(IlvDataInterval range)
    Note that the data point must be within the given data range.
  2. By setting your own data range policy to the chart.
     

    chart.setDataRangePolicy (new IlvDefaultDataRangePolicy (){
       public IlvDataInterval computeDataRange(IlvChart chart,
            IlvAxis axis, IlvDataInterval retRange) {
         if( retRange != null && retRange.getLength() == 0 )
            // return your own data interval that contains the data point.
         else
           return super.computeDataRange( chart, axis, retRange );
       } 
    }

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2267
Last updated: 29 May, 2018
Revision: 3
Views: 720
Posted: 26 Oct, 2007 by Dean J.
Updated: 29 May, 2018 by Gargani A.

Others in this category