2013-07-08 121 views
3

我已经搜索了答案,但没有找到任何有用的信息。所以,也许你可以帮我做一个工具提示,当我悬停点(标记)时,只能在悬停时出现。区域类型使工具提示显示在图表上的任何位置。我想要的只是当鼠标在标记上时显示工具提示。当我移动指针下的指针标记变为突出显示时,似乎图表“认为”我的鼠标已经在标记原因上。试图绑定系列对象的事件,但没有成功。HighCharts区域图 - 只显示悬停标记的工具提示

var chartOptions = { 
      chart: { 
       height: $('.sidebar').height()-100, 
       zoomType: 'xy', 
       spacingRight: 20, 
       animation: true, 
       renderTo: 'chart-container', 

      }, 
      xAxis: { 
       gridLineWidth: 1, 
       type: 'linear', 
       maxZoom: 1, // fourteen days 
       title: { 
        text: 'Frequency (HZ)' 
       } 
      }, 
      yAxis: { 
       min: 0, 
       title: { 
        text: 'Acceleration (g)' 
       } 
      }, 
      tooltip: { 

       enabled: true, 
       formatter: function(){ 
        if(this.series.name != 'Acceleration (g): '){ 
         return false ; 

        }else { 
         return 'Frequency: <b>'+ parseFloat(this.x).toFixed(2) + '</b> Hz<br/>'+ 
          'Acceleration: <b>' + parseFloat(this.y).toFixed(4) + '</b> g'; 
        } 

       }, 

      }, 
      legend: { 
       enabled: false 
      }, 
      plotOptions: { 
       area: { 
        trackByArea: false, 
        fillColor: { 
         linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1}, 
         stops: [ 
          [0, Highcharts.getOptions().colors[0]], 
          [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')] 
         ] 
        }, 
        lineWidth: 1, 
        marker: { 
         enabled: false, 
        }, 
        shadow: false, 
        states: { 
         hover: { 
          lineWidth: 1 
         } 
        }, 
        threshold: null, 

       }, 
      }, 

      series: [{ 
       type: 'area', 
       name: 'Acceleration (g): ', 
       pointInterval: 1.953125, 
       pointStart: 0, 
       data: dataFFT.y, 

      }] 
     }; 

回答

3

这种行为是不可能改变 - 而不是禁用标记和工具提示(返回格式错误)的区域系列及散系列。 Scatter系列完全符合您的需求。见例:http://jsfiddle.net/mZt3r/

 tooltip :{ 
      shared: true, 
      formatter: function() { 
       if(this.points && this.points.length == 1) { 
        return false; 
       } else { 
        var p = this; 
        return 'x: ' + p.x + '<br/>y: ' + p.y; 
       } 
      } 
     }, 
相关问题