Subclassing IlvBarChartRenderer,computeDataLabel() has no effect

Article ID: 2471
Last updated: 28 May, 2018
Article ID: 2471
Last updated: 28 May, 2018
Revision: 3
Views: 685
Posted: 21 Jul, 2011
by Dean J.
Updated: 28 May, 2018
by Gargani A.

Problem

I have made of subclass of IlvBarChartRenderer and have overwriten the computeDataLabel() method.However, this has no effect. How to change the labels being displayed on each of the bars ?

Cause

This behavior is the expected one. The []IlvBarChartRenderer[] does not compute each of its bar data labels. Instead, it delegates this to its child renderer (a []IlvSingleBarRenderer[]).

Resolving the problem

Instead of modifying the IlvBarChartRenderer.computeDataLabel(), you need to modify the IlvSingleBarRenderer.computeDataLabel()method, and set this IlvSingleBarRenderer's subclass in your IlvBarChartRenderer.createChild() method:

public class MySingleBarRenderer extends IlvSingleBarRenderer

{

public String computeDataLabel(IlvDataSetPoint dp)

{

String ret = new String(....);

// do your modifications on the DataLabel

...

return ret;

}

}

public class MyRenderer extends IlvBarChartRenderer

{

protected IlvChartRenderer createChild(IlvDataSet dataSet)

{

// set the above subclass

IlvSingleBarRenderer chartRenderer = new MySingleBarRenderer();

return chartRenderer;

}

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2471
Last updated: 28 May, 2018
Revision: 3
Views: 685
Posted: 21 Jul, 2011 by Dean J.
Updated: 28 May, 2018 by Gargani A.

Others in this category