简体   繁体   English

双击c3js折线图

[英]Double clicking on c3js line chart

I'm trying to create a double-click event on a c3js line chart. 我正在尝试在c3js折线图上创建一个双击事件。 I've created double-click events with other kinds of charts with the following code: 我使用以下代码创建了带有其他类型图表的双击事件:

    chart.internal.main.selectAll('.' + c3.chart.internal.fn.CLASS.eventRect).on('dblclick', function (d) {
    var $$ = chart.internal;
    $$.main.selectAll('.' + c3.chart.internal.fn.CLASS.bar).each(function (d) {
        if ($$.isWithinShape(this, d)) {

         ...

        }
    });

But when I try this on a line chart (changing c3.chart.internal.fn.CLASS.bar to c3.chart.internal.fn.CLASS.line ) it catches all the lines in the chart, and gives no information on where on the X-axis I'm clicking. 但是,当我在折线图上尝试此操作(将c3.chart.internal.fn.CLASS.bar更改为c3.chart.internal.fn.CLASS.line )时,它会捕获图表中的所有折线,并且不提供有关位置的信息在我点击的X轴上 I looked through all the other values under CLASS but can't find anything that might correspond to the dots that separate the line segments. 我查看了CLASS下的所有其他值,但找不到与分隔线段的点相对应的任何内容。

I figured it out. 我想到了。 I need to use c3.chart.internal.fn.CLASS.circle . 我需要使用c3.chart.internal.fn.CLASS.circle That will tell me which datapoint is being clicked on. 这将告诉我正在单击哪个数据点。

I haven't tried this with circles turned off. 我没有尝试过关闭圈子功能。 It might not work then. 那可能不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM