Chart.js: Bar Chart Click Events

前端 未结 8 935
梦如初夏
梦如初夏 2020-12-07 18:56

I\'ve just started working with Chart.js, and I am getting very frustrated very quickly. I have my stacked bar chart working, but I can\'t get the click \"events\" to work.<

8条回答
  •  失恋的感觉
    2020-12-07 19:41

    Hi this is the click event under options which is getting values from x and y-axis

    onClick: function(c,i) {
        e = i[0];
        console.log(e._index)
        var x_value = this.data.labels[e._index];
        var y_value = this.data.datasets[0].data[e._index];
        console.log(x_value);
        console.log(y_value);
    }
    

提交回复
热议问题