2014-09-05 94 views
1

我試圖禁用Highcharts上的標記,但仍然看到它們時,我將鼠標懸停在數據點上,無法使其工作。我試圖在圖表,系列和數據級別禁用標記,並且在每種情況下,標記都會消失,當我將鼠標懸停在它們上時,我無法獲取數據點。這裏是我禁用一個數據系列的標記的代碼:Highcharts禁用標記不起作用

<html> 
<head> 
<script src="http://code.jquery.com/jquery-1.11.1.js" type="text/javascript"></script> 
<script src="http://code.highcharts.com/highcharts.js"></script> 
<script src="http://code.highcharts.com/highcharts-more.js"></script> 
<script src="http://code.highcharts.com/modules/exporting.js"></script> 
<script> 
    $(document).ready(function() { 
    //Define the data points 


    //Define and render the HighChart 
    chart = new Highcharts.Chart({ 
     chart: { 
      renderTo: "container", 
      defaultSeriesType: "scatter" 
     }, 
     plotOptions: { 
      scatter: { 
       lineWidth: 2 
      } 
     }, 
     series: [{data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], 
    marker: { 
    enabled: false 
    } 
    }, 
{data: [129.9, 171.5, 10.4, 12.2, 14.0, 17.0, 13.6, 14.5, 21.4, 19.1, 9.6, 5.4]}] 


    }) 

}) 
</script> 
</head> 
<body> 

<div id="container" style="height: 600px; min-width: 310px; max-width: 800px; margin: 0 auto"></div> 

</body> 
</html> 

爲什麼不能正常工作?

+0

它看起來像你真正想要的是折線圖。爲什麼不使用線型而不是散射型?散點圖存在用於在特定點顯示標記的目的。因此,禁用標記將會產生問題。 – jlbriggs 2014-09-09 19:24:27

回答

1

對於散點圖,懸停事件發生在標記上。如果您禁用標記,則禁用懸停事件。我只是設置fillColortransparent

series: [{ 
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], 
    marker: { 
     fillColor: 'transparent' 
    } 
} 

小提琴here

編輯

我錯了,你可以禁用標記,仍然可以得到鼠標懸停工作。但是,它並不適用於您的情況,因爲您正在使用散點圖。切換到默認線條系列和all is well.

+0

非常感謝。我已經試過這個,它的工作原理。我仍然不明白爲什麼其他方法不起作用,因爲它適用於Highcharts網站 - 請參閱:http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts。 com/tree/master/samples/highcharts/plotoptions/series-marker-enabled-false/ – Thomas 2014-09-07 19:54:24

+0

@Thomas,這是因爲您正在使用散點圖,請參閱上面的編輯。 – Mark 2014-09-07 20:32:42