0
在我的项目中,我使用Chart.JS
来显示折线图。使用图表中单独数组的自定义标签JS
现在在图中的工具提示示出像
日期:2016年1月2日
价格:50个
这些数据从两个阵列获得。 但我需要在价格下面再显示一个数据。因此,提示会像
日期:2016年1月2日
价格:50
店:店铺名称
我怎样才能在Chart JS
实现这一目标?或者是否有可能与其他图表?请帮忙。我的样本代码来生成图形是
var myLineChart = new Chart(ctx, {
type: 'line',
data: {
labels: data.day,
datasets: [{
label: 'Price Change',
data: data.price,
backgroundColor: "rgba(255,255,255,0.4)",
borderColor: "rgba(0, 183, 255,0.4)",
pointRadius: 5,
pointBorderColor: "rgba(255,0,0,0.4)",
pointBackgroundColor: "rgba(255,0,0,0.4)",
}]
},
options: {
tooltips: {
enabled: true,
mode: 'single',
callbacks: {
label: function(tooltipItems, data) {
return 'Price: '+tooltipItems.yLabel;
}
}
}
}
});
在上面的代码data.price
正存储价格阵列。我需要通过商店详细信息并在工具提示中显示它。
只是完美的答案...非常感谢:) – Arun
你的欢迎! :> – Anami