Chart.js multiTooltip labels
Change
window.myBar = new Chart(ctx).Line(barChartData, {
responsive : true,
animation: true,
barValueSpacing : 5,
barDatasetSpacing : 1,
tooltipFillColor: "rgba(0,0,0,0.8)",
multiTooltipTemplate: "<%= label %> - <%= value %>"
});
to:
window.myBar = new Chart(ctx).Line(barChartData, {
responsive : true,
animation: true,
barValueSpacing : 5,
barDatasetSpacing : 1,
tooltipFillColor: "rgba(0,0,0,0.8)",
multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"
});
The change is to the last line
multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"
datasetLabel
gets the value of the label from the dataset objects (in this case 'Bob' and 'Tina'), whereas label
gets the caption printed on the x-axis (part of the labels
array)
want to update the answer, because I was searching for a long time.
You can now change the tooltips settings inside the options. See Docu: http://www.chartjs.org/docs/#chart-configuration-tooltip-configuration
As for the asked question, to show all X data.
window.myBar = new Chart(ctx).Line(barChartData, {
tooltips: {
mode: 'label'
}
});
Cheers Hannes