score:1

Accepted answer

changing tooltip template by label

you can use the label property of the valuesobject to figure out the index and use that to pick your symbol, like so

chart.mysymbols = ['!', '@', '#', '$', '%', '^', '&'];

var ctx = document.getelementbyid("mychart").getcontext("2d");
var mychart = new chart(ctx).line(window.data, {
    multitooltiptemplate: "<%=datasetlabel%> : <%= value %><%= chart.mysymbols[window.data.labels.indexof(label)] %>"
});

notice that both data and mysymbols collection are properties of globally referencible objects (window and chart in this case, but it could be any global object). this is because only the valuesobject is injected into the template function. unless you want to change the library code, using global objects would be the way to do it (however, do note that its not good design).


fiddle - http://jsfiddle.net/z1nfqhfn/


changing tooltip template by dataset

if you want to do a similar thing by dataset, it would be

chart.mysymbols = ['°c', '%'];

var ctx = document.getelementbyid("mychart").getcontext("2d");
var mychart = new chart(ctx).line(window.data, {
    multitooltiptemplate: "<%=datasetlabel%> : <%= value %><%= chart.mysymbols[window.data.datasets.map(function(e) { return e.label }).indexof(datasetlabel)] %>"
});

fiddle - http://jsfiddle.net/fnu0dyd2/


Related Query

More Query from same tag