2016-04-22 58 views
-1

我想改变我的highcharts的行为,显示有关数据的工具提示当一个点的点击,而不是上空盘旋,这是我的图表对象的代码,highcharts显示在点提示点击

this.chart = new Highcharts.Chart({ 

     chart : { 
      renderTo : $container[0], 
      type : chartType, 
      events : { 
       load: function() { 
        this.myTooltip = new Highcharts.Tooltip(this, this.options.tooltip); 
        console.log(this.myTooltip); 
       } 
      } 
     }, 
     title: { 
      enabled : false, 
      useHTML: true, 
      text: '' 
     }, 
     legend : { 
      enabled : false 
     }, 
     xAxis: { 
      categories: self.categories, 
      labels : { 
       rotation : 90, 
       formatter: function(){ 
        return '<a href="" class="axisLabel" data-name="'+ this.value +'">' + this.value + '</a>'; 
       }, 
       useHTML: true, 
       padding: '10px', 
       y: 30, 
       x: -5, 
       align:'left' 
      } 
     }, 
     yAxis: { 
      allowDecimals: false, 
      opposite:false 
     }, 
     tooltip: { 
      enabled: false, 
      useHTML : true, 
      backgroundColor: "rgba(255,255,255,1)", 
      formatter : function() { 
       if(self.graphView != "turn") { 
        var tooltip = self.showClientProjects(this.x, self.organisation_filter, this.y, self.graphView); 
        self.pointIndex = this.point.index; 
        return tooltip.innerHTML; 
       } else { 
        console.log(this.x); 
        var tooltip = self.showClientProjects(this.x, null, null, self.graphView); 
        self.pointIndex = this.point.index; 
        return tooltip.innerHTML; 
       } 
      } 
     }, 
     plotOptions: { 
      column: { 
       maxPointWidth: 5, 
       pointPadding: 0.2, 
       //borderWidth:1 
      }, 
      series: { 
       stickyTracking: false, 
       events: { 
        click: function(evt){ 
         this.chart.myTooltip.refresh(evt.point, evt) 
        }, 
        mouseOut: function() { 
         this.chart.myTooltip.hide(); 
        } 
       } 
      } 
     }, 
     series: [{ 
      data : data, 
      dataLabels : { 
       crop : false 
      } 
     }] 

    }); 

点击一个点返回该错误,

highcharts.src.js:1319 Uncaught TypeError: Cannot read property 'call' of null this line of code is from the highcharts library,

// If the event handler return false, prevent the default handler from executing 
if (fn.call(el, eventArguments) === false) { 
    eventArguments.preventDefault(); 
} 

但是它适用于快速小提琴完美的罚款我敲了起来,

http://jsfiddle.net/d1gL4cjx/1/

+1

你的小提琴被打破:'未捕获的错误:Highcharts错误#13:www.highcharts.com /错误/ 13' –

+1

的小提琴你提供的不符合你提供的代码。 – apokryfos

+0

如果您提供有关渲染div的正确信息的Highcharts,那么图表似乎工作正常 - http://jsfiddle.net/gqxzv8bL/1/。此外,不要为配置对象设置两个相同的属性以避免意外的行为 - 您可以使用两次载入事件设置图表。 (本评论提供的小提琴中删除了问题。) –

回答