I had the same problem today and solved it quite simply by adding the onAnimationComplte and tooltipevents options.
onAnitmationComplete calls a method to display tooltips, as the hover event does. Usually you define events in tooltipevents to display tooltips, but we need to remove them and pass an empty array.
Note :( http://www.chartjs.org/docs/#doughnut-pie-chart ).
JavaScript:
var options = { tooltipTemplate: "<%= value %>", onAnimationComplete: function() { this.showTooltip(this.segments, true); //Show tooltips in bar chart (issue: multiple datasets doesnt work http://jsfiddle.net/5gyfykka/14/) //this.showTooltip(this.datasets[0].bars, true); //Show tooltips in line chart (issue: multiple datasets doesnt work http://jsfiddle.net/5gyfykka/14/) //this.showTooltip(this.datasets[0].points, true); }, tooltipEvents: [], showTooltips: true } var context = $('#chart').get(0).getContext('2d'); var chart = new Chart(context).Pie(data, options);
HTML:
<div id="chartContainer"> <canvas id="chart" width="200" height="200"></canvas> </div>
Sample data:
var data = [ { value: 300, color:"#F7464A", highlight: "#FF5A5E" }, { value: 50, color: "#46BFBD", highlight: "#5AD3D1" }, { value: 100, color: "#FDB45C", highlight: "#FFC870" } ]
JSFiddle PIE: http://jsfiddle.net/5gyfykka/
JSFiddle BAR / LINE: http://jsfiddle.net/5gyfykka/14/
Kapi Sep 18 '14 at 12:51 on 2014-09-18 12:51
source share