I have created a bar graph using chartJS. I want to display the data present in my JSON array into the graph tooltip.
JSON
{
"meth": [ {
"tech": "CSS", "avg": 3, "Count": 80, "sum": 53
}
,
{
"tech": "CCS", "avg": 9, "Count": 70, "sum": 25
}
,
{
"tech": "CSC", "avg": 7, "Count": 50, "sum": 66
}
]
}
The above json data is used to plot the graph by using chartJS in javascript but i want the other data to be displayed in the graph as tooltip. the data avg & sum should be displayed as part of tooltip along with label as tech and data as count.
Graph Code in Javascript:
<script>
var ctx1=document.getElementById('bar').getContext('2d');
var myChart1=new Chart(ctx1, {
type: 'bar', legend: {
display: true
}
, options: {
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var dataset=data.datasets[tooltipItem.datasetIndex];
return data.datasets[tooltipItem.datasetIndex].label+ ' : ' +dataset.data[tooltipItem.index]+"%";
}
}
}
, scales: {
yAxes: [ {
ticks: {
beginAtZero: true, steps: 10, stepValue: 5, max: 100
}
}
]
}
}
, data: {
labels: techDATA, datasets: [ {
backgroundColor: colorCode, label: 'Method Covered', data: countDATA
}
]
}
}
);
</script>
I want to display the data like avg and sum in the tooltip which already has the default tooltip with label and data. Help me with code.....!

