EXTJS 4 – I am trying to customize the renderer function for the ‘series’ in StackedBarChart. I want to conditionally color the bars.
renderer: function(sprite, record, curAttr, index, store) {
return Ext.apply(curAttr, {
fill: color
});
return curAttr;
},
My Question is, how to find out which element its currently rendering. I want to give white color to the first element of each record in my data store/series.
Thank you.
I found a way to detect exactly which element is currently being rendered. First, you’ll need the following override, which addresses several issues with the renderer parameters. It shouldn’t affect the normal bar charts, but I haven’t tested them.
Here’s the change list for
renderer():Example: for a record that looks like
{name: 'metric': segment1: 12, segment2: 22}, the index forsegment1will be0instead of1, because the first item in the record does not belong to its axis (it’s the category name)So, to answer your question, now you can use the renderer like so:
If you want to set the color for a named item, you may also do it like this:
For that last one, you’ll need this function, which allows you to retrieve a property from an object using a numeric index: