| | | | Browse by category |
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;
}
}