I have created a Multiple line Line chart using the ChartJS library on Laravel. It has two line. I want to add percentage data to my Line Chart Tooltips for each xLabel. But I am not able to use it in this wrapper. Could you help me out?
Example: Line: data (percent_data)%
Below code is giving only the first element on my Charts Tooltips
var ctx = document.getElementById("myLineChart");
var myLineChart = new Chart(ctx, {
type: 'line',
data: {
labels: label,
datasets: [{
label: "Line",
data: data,
percent_data: per_data_from_html,
}],
},
tooltips: {
callbacks: {
label: function(tooltipItem, chart) {
var datasetLabel = chart.datasets[tooltipItem.datasetIndex].label || '';
return datasetLabel + ': ₹ ' + number_format(tooltipItem.yLabel)+' ('+ (chart.datasets[tooltipItem.datasetIndex].percent_data[tooltipItem.datasetIndex]);
}
}
}
}
});
labelanddata?labelanddata.