0
是否有任何方式爲每個圖表js數據值添加模態彈出框。這裏dD 1,dD2等...是數據值,點擊這個每個值,我需要打開模式彈出。爲每個chart.js數據值添加模態彈出框
var dData = function() {
return Math.round(Math.random() * 90) + 10
};
var barChartData = {
labels: ["dD 1", "dD 2", "dD 3", "dD 4", "dD 5", "dD 6", "dD 7", "dD 8", "dD 9", "dD 10"],
datasets: [{
fillColor: "rgba(0,60,100,1)",
strokeColor: "black",
data: [dData(), dData(), dData(), dData(), dData(), dData(), dData(), dData(), dData(), dData()]
}]
}
var index = 11;
var ctx = document.getElementById("canvas").getContext("2d");
var barChartDemo = new Chart(ctx).Bar(barChartData, {
responsive: true,
barValueSpacing: 2
});
setInterval(function() {
barChartDemo.removeData();
barChartDemo.addData([dData()], "dD " + index);
index++;
}, 3000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
<canvas id="canvas"></canvas>
感謝您的回覆。添加這個腳本後,當點擊每個欄時,我在控制檯中出現腳本錯誤。 「畫布未定義(...)」,你能否在上面的代碼片段中的每個欄上實現模態。 – sid
看在控制檯,[jsfiddle](https://jsfiddle.net/mahidaparth7/1rpn77by/)。點擊酒吧我有控制bar @ sid的數據 –