2015-04-24 43 views

回答

0

您需要设置allowPointSelect为true,然后通过options配置标记的状态。下一步是在点上捕获click event并使用Renderer添加自定义形状。

series: { 
      allowPointSelect: true, 
      marker: { 
       states: { 
        select: { 
         enabled: true, 
         fillColor: 'red', 
         color: 'red' 
        } 
       }, 
      }, 
      point: { 
       events: { 
        click: function() { 
         var chart = this.series.chart, 
          r = chart.renderer, 
          left = chart.plotLeft, 
          top = chart.plotTop, 
          width = chart.plotWidth, 
          height = chart.plotHeight, 
          x = this.plotX, 
          y = this.plotY; 

         if (this.series.options.enabledCrosshairs) { 
          if (crosshair !== UNDEFINED) crosshair.destroy(); 

          crosshair = r.path(['M', left, top + y, 'L', left + x, top + y, 'M', left + x, top + y, 'L', left + x, top + height]) 
           .attr({ 
           'stroke-width': 1, 
           stroke: 'red' 
          }) 
           .add(); 
         } 
        } 
       } 
      } 
     } 

例:http://jsfiddle.net/u4ha3cxw/15/ 例与点击系列:jsfiddle.net/u4ha3cxw/17

+0

非常感谢你这一点。 这解决了我的问题的70%,我可以在不改变线条的情况下在没有点的线上“非选择区域”添加点吗? – Nazibra

+0

你可以附上一个模型吗? –

+0

我已经完成了上面的图片,我想添加点(两点之间)。 – Nazibra

相关问题