-
30 Jul 2012 3:53 AM #1
Unanswered: How to get the label of series in the bar chart on tap event
Unanswered: How to get the label of series in the bar chart on tap event
I have a very strange requirement.
I have a column chart which has
on the X axis - year
and Y axis three fields [data1, data2, data3]
graph.png
So now my requirement is when i click on the first bar i want to show in an overlay the details of the bar i have clicked
For Eg: Year : 2012-02 and Data1 : 2. using item
Here i am able to get values 2012-02 and 2 on the bar tap using the code below
{
type : 'iteminfo',
gesture : 'tap',
listeners: {
show: function (interaction, item, panel) {
//item.value[0]
//item.value[1];
}
}
}
but unable to find whether i have tapped on data1, data2 or data3 bar item.
-
21 Aug 2012 5:22 AM #2
Sencha silence on this is scary
Sencha silence on this is scary
I'm also looking for a way to do this too.
There is a hacky way to get it if you get the legend item with the same color as the item object fill color.
Of course this will only work if you have a different value for each yField.
I just don't know why they couldn't just add it to the series item object here:
Code:items.push({ series: me, storeItem: currentRecord, value: [currentRecord.get(me.xField), yValue], attr: barAttr, point: column ? [barAttr.x + barAttr.width / 2, yValue >= 0 ? barAttr.y : barAttr.y + barAttr.height] : [yValue >= 0 ? barAttr.x + barAttr.width : barAttr.x, barAttr.y + barAttr.height / 2] });
-
21 Aug 2012 8:40 PM #3
-
21 Aug 2012 8:49 PM #4
Work around for this problem
Work around for this problem
In the series listener in the item tap event, we can get the index of the tapped bar item selected based on comparing the color code and value like this
itemtap: function (series, item, event) {
for(i=0; i<series.items.length; i++){
if(item.attr.fill == series.items[i].attr.fill && item.value[0] == series.items[i].value[0]){
selBarIndex = i;
}
}
}
so once you find the selected bar index from the Y fields array you can find out the label of the field you have tapped.
so for example if the Y axis if we had 3 fields [data1, data2, data3]
and in the item tap you got the selBarIndex = 1 that means the field you have tapped is fields[1] ie data1
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote