2014-09-05 93 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