我使用chartJS创建了一个图表,并希望通过单击该Bar来获取angularJs中的条形图中的特定条形数据

时间:2019-06-14 11:44:57

标签: angularjs charts

I am trying to implement click event on the Stacked Bar chart.

Below are the values i am getting wherever i click on single bar:
Bar 1 - label = P1, value = 6 
Bar 2 - label = P2, value = 7 
Bar 3 - label = P3, value = 6 and etc...

Problem: 
So wherever I click on the 1st bar the label is P1 its because I am getting the index value as 0 for the entire bar and 1 for bar 2 and so on.

Question:
Is there any way to identify the x coordinate value? so that I can identify the click is from which stack.

 options: {
            onClick: function (evt, item) {
              console.log('legend onClick', evt);
              console.log('legd item', item);
            },
}

预期的输出是我只想要那个特定的条形数据或水平   有什么方法可以识别x坐标值?这样我就可以确定点击来自哪个堆栈。

0 个答案:

没有答案