隐藏HighCharts散点图中的特定点

隐藏HighCharts散点图中的特定点,highcharts,hide,scatter,Highcharts,Hide,Scatter,我需要在HighCharts散点图中隐藏一个特定点。我试图设置series.point.visible,但这不是正确的方法。。。看。 为#按钮单击功能插入的正确代码是什么 $(function () { $('#container').highcharts({ chart: { type: 'scatter', }, plotOptions: { scatter: {

我需要在HighCharts散点图中隐藏一个特定点。我试图设置series.point.visible,但这不是正确的方法。。。看。 为#按钮单击功能插入的正确代码是什么

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'scatter',
        },
        plotOptions: {
            scatter: {
                marker: {
                    radius: 5,
                    symbol:'circle',
                    fillColor: '#800000'
                },
            }
        },
    series: [{
        name: 'A',
        color: "#b0b0b0",
        data: [[38,42],[39,39],[35,45],[35,54],{x:36,y:35}]
        }]
});
var chart=$('#container').highcharts();
});
$('#button').click(function () {
    chart.series[0].data[3].visible=(!chart.series[0].data[3].visible);
});

我可以想出几个选择

隐藏标记:

  $('#button').click(function() {
    // This is an option, but you'd also need to hide the label and tooltip for it to be usable 
    // the data is still in the series
    var data = chart.series[0].data;
    var point = data[3];
    if (point.marker && point.marker.enabled == false) {
      data[3].marker = {
        enabled: true,
        states: {
          hover: {
            enabled: true
          }
        }
      };
    } else {
      data[3].marker = {
        enabled: false,
        states: {
          hover: {
            enabled: false
          }
        }
      };
    }
    chart.series[0].setData(data);
  });
从序列中删除该点

  $('#button2').click(function() {
    // This requires that you keep your original data somewhere, so you can add it back in.  
    // I'm also using a flag to track if the data is hidden or not.  
    // You could check that the series matches the saved data if you'd rather or 
    // keep track of a point and add and remove that.
    var series = chart.series[0];
    if (hidden) {
      myData = origData.slice();
      series.setData(myData);
      hidden = false;
    } else {
      series.removePoint(3);
      hidden = true;
    }
  });

虽然我很喜欢Deep 3015的建议,但我也认为这可以接受吗