Chartjs深入探讨了多个Y轴杆/线图的问题 [英] Chartjs drill down issue with multiple Y-Axis Bar/Line graph
问题描述
我有一个带有多个Y轴的条形图,如下图所示。
I have a bar chart with multiple Y-Axis as you can see in the image below.
如您所见,这两个条代表两个不同的数据集。画布的 onclick
事件为我们提供了所有条形点的数组。
As you can see the two bar represents two different datasets. The onclick
event of the canvas provides us an array of all the bar points.
canvas.onclick = function (evt) {
var activePoints = chartObject.getBarsAtEvent(evt);
}
现在的问题是,在我们的应用程序中,我们做了两件不同的事情,基于用户点击哪个栏。使用上述几点,我们无法确定用户点击了哪个栏,这意味着如果用户点击蓝色栏然后我们需要做一些事情,否则如果用户点击紫色栏然后我们做了完全不同的事情。我们如何确定用户点击的栏。
Now the problem is that in our application we have do two different thing based on which bar the user clicks on. Using the above points we are not able to determine which bar the user clicked on, meaning if the user clicks on blue bar then we need to do something or else if the user clicks on purple bar then we do something completely different. How can we determine which bar the user clicked.
推荐答案
不幸的是,没有支持,你必须通过以下方式实现它你自己。
请参阅 https://github.com/chartjs/Chart。 js / issues / 3115#event-792845174
另请参阅此解决方案: https://github.com/chartjs/Chart.js/issues/1283
Unfortunately, there is no support for that, you have to implement it by yourself. See https://github.com/chartjs/Chart.js/issues/3115#event-792845174 See also this solution: https://github.com/chartjs/Chart.js/issues/1283
这篇关于Chartjs深入探讨了多个Y轴杆/线图的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!