I am trying to display a value (Prod_ary1[selected index of chart] in the tool tips using the beforeBody callback:
tooltips: {
mode: 'index',
intersect: true,
callbacks: {
beforeBody: function(tooltipItems, data){
return 'Count: ' + "<display Prod_ary[1][highlighted index]";
},
label: function(tooltipItems, data) {
return data.datasets[tooltipItems.datasetIndex].label +': ' + TS_ary[tooltipItems.datasetIndex][tooltipItems.index];
}
}
I have attempted to access the index to tell me which element I need to display in the array using:
return 'Count: ' + Prod_ary[1][tooltipItems.index];
But it returns undefined. I'm screwing something up but can't quite figure out what.
My fiddle
In the tooltips callbacks I changed this:
return 'Count: ' + Prod_ary[1][tooltipItems.index];
to this:
return 'Count: ' + Prod_ary[1][tooltipItems[0]["index"]];