2017-06-30 18 views
0

HighCharts散布図の特定の点を非表示にする必要があります。私は正しい方法ではないことをseries.point.visibleに設定しようとしました... http://jsfiddle.net/1wfotmoa/28/を参照してください。 #buttonのクリック機能に挿入する正しいコードはどれですか?私はオプションHighCharts散布図の特定の点を隠す

のカップルの考えることができる

$(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); 
}); 
+1

http://jsfiddle.net/55tkvfbn/がこれに該当します –

答えて

1

は、マーカーを隠す:

$('#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; 
    } 
    }); 

http://jsfiddle.net/1wfotmoa/31/

からポイントを削除しますコメントからのDeep 3015の提案も好きですが、