0
私はバーをクリックすると、データがツールチップに表示されます。私はonClick
機能でツールチップのデータが必要です。続きどのように棒グラフのツールチップのデータをクリックするのですか?
は、棒グラフのための私のコードです:
var tool = new Chart(canvas, {
type: 'bar',
data: data,
options: {
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)'
},
position : 'bottom'
},
title: {
display: true,
text: title
},
scales: {
xAxes: [{stacked: true,barPercentage: 5.0,
categoryPercentage: 0.2}],
yAxes: [{
stacked: true,
ticks: {
beginAtZero: true
},
barPercentage: 0.3
}]
},
events: [ "click"],
onClick: function(event, array){
console.log("tool.data:",tool.tooltip);
}
}
});
私はあなたができる "見逃し" のような私のクリック機能でデータを、 "中"、78
@gruntしかし、あなたのonClick関数を使用すると、私のマシン上で要素[0]が未定義になっています。 –
HOW ??あなたが明確にわかるように、与えられた例では完全に正常に動作しています。ChartJS(2.7.1)の最新バージョンを使用していることを確認してください。 –