如何在Chart.js中显示工具提示? [英] How to show tooltips in Chart.js?
本文介绍了如何在Chart.js中显示工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
按照教程,此代码绘制折线图,但没有工具提示。我在这里缺少一些配置选项?在教程中显示了工具提示。
Following the tutorial this code draws the line chart, but no tooltips. Am I missing some configuration option here? In the tutorial there are tooltips showing up.
var chartData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
var ctx = document.getElementById("chart").getContext("2d");
var myNewChart = new Chart(ctx).Line(chartData, {
showTooltip: true,
tooltipTemplate: "<%= value %>"
});
推荐答案
您使用的是什么版本的chart.js?
What version of chart.js are you using?
我可以使用v1.0.1-beta2确认工具提示
I can confirm that tooltips work using v1.0.1-beta2
<script src="//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1-beta.2/Chart.min.js"></script>
但不起作用使用v0.2.0 。
版本1.0.1-beta2可从cdnjs获取。
Version 1.0.1-beta2 is available from cdnjs.
这篇关于如何在Chart.js中显示工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文