Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击即可在HighCharts中隐藏点_Javascript_Jquery_Highcharts - Fatal编程技术网

Javascript 单击即可在HighCharts中隐藏点

Javascript 单击即可在HighCharts中隐藏点,javascript,jquery,highcharts,Javascript,Jquery,Highcharts,我有一张2系列的海图。 现在,我希望在单击链接时禁用系列1中的某些点 这是我目前的代码: $('.remove').click(function () { var chart = $('#plot').highcharts(), series = chart.series[0]; if (series.data.length) { chart.series[0].data[0].remove(); } }); 问题是,删除此点后,[0]

我有一张2系列的海图。 现在,我希望在单击链接时禁用系列1中的某些点

这是我目前的代码:

$('.remove').click(function () {
    var chart = $('#plot').highcharts(),
        series = chart.series[0];
    if (series.data.length) {

        chart.series[0].data[0].remove();
    }
});
问题是,删除此点后,[0]会更改为另一个值,再次单击后,它会继续删除。 我只想让点消失,这在可见的情况下是可能的:

从1.2.0只读开始可见。由设置的系列的可见性状态 series.show()、series.hide()或初始配置


但是我只是没有在我的onClick事件中以正确的方式实现它。

如果我很理解你,你需要保持“位置”在哪里?如果是,您可以尝试使用
point.update()
函数并设置空值


示例:

我解决了单击链接删除点的问题,如下所示:

$('.remove').click(function () {

    var series = chart.series[0];
    var id = $(this).data('id');

    if (series.data.length) {

        // disable point in graph
        chart.series[0].data[id-1].update(
        {
            y:null
        });

    }

    // delete used tablerow
    $(this).closest("tr").fadeOut(50);
});
    series: [{
        name: 'time',
        data: data: [[1, 129386],[2, 123966],[3, 123162],[4, 123245],[5, 124314],[6, 123946],[7, 124156],[8, 123367],[9, 124460],[10, 123366],[11, 123182],[12, 123915],[13, 124627],[14, 123142],[15, 124044],[16, 124346],[17, 123156],[18, 124356],[19, 123511],[20, 124239],[21, 123252],[22, 125169],[23, 125027],[24, 123508],[25, 124065],[26, 122719],[27, 124199],[28, 122968],[29, 124132],[30, 124052],[31, 124383],[32, 123265],[33, 124083],[34, 123855],[35, 124284],[36, 123719],[37, 123213],[38, 124245],[39, 123079],[40, 123721]],
        events: {

            // if point gets clicked, it'll be deleted
            click: function(event) {
                console.log(event.point);

                var pointId = event.point.x;

                $("#hidden-points-table").fadeIn(1000);
                $('#hidden-elements').append(pointId + ", ");

                event.point.update(
                {
                    y: null
                });

                // deleting the table row
                $("[data-id='"+pointId+"']").closest("tr").fadeOut(50);
            }

        }
    }
我用一个事件在图上单击时成功地排除了点,其工作原理如下:

$('.remove').click(function () {

    var series = chart.series[0];
    var id = $(this).data('id');

    if (series.data.length) {

        // disable point in graph
        chart.series[0].data[id-1].update(
        {
            y:null
        });

    }

    // delete used tablerow
    $(this).closest("tr").fadeOut(50);
});
    series: [{
        name: 'time',
        data: data: [[1, 129386],[2, 123966],[3, 123162],[4, 123245],[5, 124314],[6, 123946],[7, 124156],[8, 123367],[9, 124460],[10, 123366],[11, 123182],[12, 123915],[13, 124627],[14, 123142],[15, 124044],[16, 124346],[17, 123156],[18, 124356],[19, 123511],[20, 124239],[21, 123252],[22, 125169],[23, 125027],[24, 123508],[25, 124065],[26, 122719],[27, 124199],[28, 122968],[29, 124132],[30, 124052],[31, 124383],[32, 123265],[33, 124083],[34, 123855],[35, 124284],[36, 123719],[37, 123213],[38, 124245],[39, 123079],[40, 123721]],
        events: {

            // if point gets clicked, it'll be deleted
            click: function(event) {
                console.log(event.point);

                var pointId = event.point.x;

                $("#hidden-points-table").fadeIn(1000);
                $('#hidden-elements').append(pointId + ", ");

                event.point.update(
                {
                    y: null
                });

                // deleting the table row
                $("[data-id='"+pointId+"']").closest("tr").fadeOut(50);
            }

        }
    }
由于很难找到解决办法,我希望这能帮助一些人解决这个问题。
这也很有帮助。

谢谢,效果很好。是否也可以通过此事件传递某些点?