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之,有人可以幫我處理這件事,並顯示如何延長工作的例子嗎? :)
感謝