I'm working on a webapp and I recently swapped google charts with chart.js because it is visually more appealing. However, the one loss that I took is that I can no longer get tooltips above the data points. I was wondering if anyone knows how this can be done as I am a novice with javascript. Here is the code for the graph and the settings:
var data = {
labels : graphData[0],
datasets : [
{
fillColor : "rgba(200,160,100,0.5)",
strokeColor : "rgba(80,240,70,1)",
pointColor : "rgba(80,240,70,1)",
pointStrokeColor : "#fff",
data : graphData[3]
},
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : graphData[1]
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
data : graphData[2]
}
]
};
var options = {
scaleShowGridLines : true,
scaleShowLabels : true,
animationSteps : 150,
scaleOverride: true,
scaleSteps : Math.max.apply(Math, graphData[3]),
scaleStepWidth : 1,
scaleStartValue : 1
};
var ctx = document.getElementById("chart_div").getContext("2d");
ctx.canvas.width = Math.max(graphData[0].length * 60, 600);
var myNewChart = new Chart(ctx).Line(data,options);
$('#chart_area').fadeIn();
$('html, body').animate({
scrollTop: $("#picture_area").offset().top
}, 1000);
I'm working on a webapp and I recently swapped google charts with chart.js because it is visually more appealing. However, the one loss that I took is that I can no longer get tooltips above the data points. I was wondering if anyone knows how this can be done as I am a novice with javascript. Here is the code for the graph and the settings:
var data = {
labels : graphData[0],
datasets : [
{
fillColor : "rgba(200,160,100,0.5)",
strokeColor : "rgba(80,240,70,1)",
pointColor : "rgba(80,240,70,1)",
pointStrokeColor : "#fff",
data : graphData[3]
},
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : graphData[1]
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
data : graphData[2]
}
]
};
var options = {
scaleShowGridLines : true,
scaleShowLabels : true,
animationSteps : 150,
scaleOverride: true,
scaleSteps : Math.max.apply(Math, graphData[3]),
scaleStepWidth : 1,
scaleStartValue : 1
};
var ctx = document.getElementById("chart_div").getContext("2d");
ctx.canvas.width = Math.max(graphData[0].length * 60, 600);
var myNewChart = new Chart(ctx).Line(data,options);
$('#chart_area').fadeIn();
$('html, body').animate({
scrollTop: $("#picture_area").offset().top
}, 1000);
Share
Improve this question
edited Jun 1, 2013 at 23:59
Dennis Rongo
4,6111 gold badge27 silver badges26 bronze badges
asked Apr 12, 2013 at 19:14
EricEric
1,3662 gold badges14 silver badges24 bronze badges
2
- have you figure it out how to implement tooltips? – tviana Commented Jun 18, 2014 at 16:18
-
2
get the newest Chart.js library it should have builtin tooltip, then to activate it add it in option
{showTooltips:true}
and refer the docs to modify it – whale_steward Commented Sep 16, 2014 at 4:30
1 Answer
Reset to default 1var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true,
showTooltips: true,
multiTooltipTemplate: "<%= value %>",
});
use this to set a gloabl settings in chartjs.