score:1
Accepted answer
different labels in tooltip vs scale
just use the tooltiptemplate
option
preview
script
function label(short, long) {
this.short = short;
this.long = long
}
label.prototype.tostring = function() {
return this.short;
}
var data = {
labels: [
new label("j", "jan"),
new label("f", "feb"),
new label("m", "mar"),
new label("a", "apr"),
new label("m", "may"),
new label("j", "jun"),
new label("j", "jul")
],
datasets: [
{
label: "my first dataset",
fillcolor: "rgba(220,220,220,0.5)",
strokecolor: "rgba(220,220,220,0.8)",
highlightfill: "rgba(220,220,220,0.75)",
highlightstroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
}
]
};
// create chart
var ctx = document.getelementbyid("chart").getcontext('2d');
new chart(ctx).bar(data, {
tooltiptemplate: "<%if (label){%><%=label.long%>: <%}%><%= value %>",
});
fiddle - https://jsfiddle.net/7z1s1feg/
score:0
this part of the documentation explain you how to extend the tooltips elements.
var mypiechart = new chart(ctx).pie(data, {
customtooltips: function(tooltip) {
};
});
plus, this example show you how to modify the html of the tooltip inside this function. the example from github :
var innerhtml = '';
for (var i = tooltip.labels.length - 1; i >= 0; i--) {
innerhtml += [
'<div class="chartjs-tooltip-section">',
' <span class="chartjs-tooltip-key" style="background-color:' + tooltip.legendcolors[i].fill + '"></span>',
' <span class="chartjs-tooltip-value">' + tooltip.labels[i] + '</span>',
'</div>'
].join('');
}
tooltipel.html(innerhtml);
with these elements, you will be able to customize your tooltips however you want.
Source: stackoverflow.com
Related Query
- How to modify chartjs tooltip to add customized attribute
- How to modify chartjs tooltip so i can add customized strings in tooltips
- How to add ChartJS code in Html2Pdf to view image
- ChartJS version 3 how to add percentage to pie chart tooltip
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- How to add dataset legend in chartjs tooltip
- How to disable a tooltip for a specific dataset in ChartJS
- How to modify bar width in Chartjs 2 bar charts
- ChartJS add tooltip to a grouped bar chart
- How to add label for ChartJs Legend
- How to change the color of legend in chartjs and be able to add one more legend?
- How to add background color between two lines in yAxis Chartjs
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- how to set color for each item in tooltip with ChartJS
- How to add background color between two specific lines in Chartjs 3.1
- How to sort XY line chart tooltip items based on value and add thousands separators?
- How to add datalabels to chartJS on Primefaces
- How to create a custom tooltip for chartJS graph with data in JSON array in JavaScript?
- How to add a Date Selector to Chartjs in the context of Vue.js
- How to add new data point and remove leftmost data point dynamically in Chartjs
- How to get the data attribute of the canvas chart created using chartjs
- How to add space to the bottom of the chart in chartjs [angular]
- How to toggle between Custom tooltip and normal tooltip in chartjs and angular
- ChartJS add custom tooltip to a stacked bar chart
- chartjs 2.7 how to add labels in center of horizontal bar graph
- How to add left padding for my charts done in ChartJs and my Google Map so it is not glued to the limit of the page on the left
- How to add margin bottom in Tittle ChartJS
- How to add additional label in the middle of each bar using ChartJS
- How to set Custom tooltip event with Chartjs version 2.X
- How do I add Date range filter in chartjs in the context of Vue.js
More Query from same tag
- How to add text in centre of the doughnut chart using Chart.js?
- ChartJS doughnut data toggle on custom button click
- Chart js multiple pie chart on one page
- undefined labels piechart - chartjs
- addData() dropped from latest chart.js 2.1.3 - whats up?
- how to create multiple chart on one component vue
- How can i do so that my chartjs updates everytime data is inserted or by time interval?
- How to use the tooltipTemplate on Chart.JS 2.0
- How to remove header square from chart.js?
- How to change the Chart.js legend rectangles to squares
- ChartJS v2 - Keep tooltip open when user click on a point of a multiple lines chart
- Having problems displaying multiple charts on a page
- How to order a horizontal bar chart - chartJS & Chart.HorizontalBar.js
- AutoSkip: False not working on time xAxes labels
- ChartJS and Laravel5
- ChartJS incorrect plot when plotting multiple line charts in one graph
- chart.js add second line in a Line chart that starts from end of first line
- ChartJS large data range
- Yii2 unable to view chart
- Align Title Left React Chart.js V2
- Values above points - chart.js
- Can't figure out why the values in my objects are changing
- how to change display and styles of the labels in react-chartjs-2
- Chart.js scale which increases by x (arbitary number) for each tick
- How to select context or scale on chart in chartjs quickchart io to run getValueForPixel?
- ChartJS different background gradient depending on data (line graph)
- Not able to change chart.js x and y font colors
- How to noshown the scale while all datasets is hidden (chartjs)?
- Chart.js: chart not displayed from modules despite no errors - JS
- Meteor with Chart js cannot read property ‘getContext’ of null only AFTER new document in collection?