134👍
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)
10👍
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
- [Chartjs]-Chart Js Change Label orientation on x-Axis for Line Charts
- [Chartjs]-How to set start value as "0" in chartjs?
1👍
As I answered here, you can give multiTooltipTemplate a function. Put a breakpoint inside that function with ‘debugger’, and explore the given object for all the properties you’d like. Then construct a string to be displayed in your tooltip:
multiTooltipTemplate: function(v) {debugger; return someManipulation(v);}
tooltipTemplate: function(v) {return someOtherManipulation(v);}
- [Chartjs]-Change the Y-axis values from real numbers to integers in Chart.js
- [Chartjs]-Chart Js Change Label orientation on x-Axis for Line Charts
1👍
Similar to the answer by Hannes but the documentation has been updated since then – There are various options now and the link he provided no longer goes anywhere as that option is deprecated.
I’m adding a new answer as it took me a while to find.
This is x mode – displays multiple dataset info in tooltip based on x axis
var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
tooltips: {
mode: 'x'
}
}
})
http://www.chartjs.org/docs/latest/general/interactions/modes.html#x
There is also ‘y’ mode. Label mode is now deprecated.
You can also use ‘point’, ‘index’ and ‘nearest’ mode.