我很难搞清楚如何在我的Chart JS折线图中显示标签,图例和标题。我已直接从example复制代码(转载如下)。但是,标签"我的第一个数据集"没有出现在图表的任何地方,所以我无法分辨出哪一行。我也尝试过添加一个“标题”'到我的数据集,但没有运气。任何人都知道我错过了什么?
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
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]
}
]};
谢谢, Saswat
答案 0 :(得分:49)
在选项中添加此参数
multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"