0
我需要添加一个属性到数据集/标签以在点击时识别它。 我已经试过这样的事情:chart.js 2.0将新属性添加到数据集
Chart.controllers.customBar = Chart.controllers.bar.extend({
code: null
});
和它差不多的作品,因为我可以看到新属性“代码”,数据与之相关联,图表背景是可见的,但空的,我的意思是无论从数据集数据可见。
这是我的初始化:
var ctx = document.getElementById("roads-chart").getContext("2d");
window.roadsBar = new Chart(ctx, {
type: 'bar',
data: roadsChartData,
options: {
title: {
display: true,
text: "Stan dróg"
},
tooltips: {
mode: 'label'
},
responsive: true,
scales: {
xAxes: [{
stacked: true,
}],
yAxes: [{
stacked: true
}]
},
onClick: function(e, d) {
console.log(d);
}
}
});
的事情是,我不觉得chart.js之,有人可以帮我处理这件事,并显示如何延长工作的例子吗? :)
感谢