2013-02-20 51 views
1

我使用Highcharts提示生成驗證碼:highcharts:提示顯示了花鍵而不是散點圖

tooltip: { 
shared: true, 
crosshairs: true, 
formatter: function() { 
    var s = '<b>' + Highcharts.dateFormat('%e. %b %Y, %H:00', this.x) + '</b>'; 

    $.each(this.points, function (i, point) { 
     s += '<br/>' + point.series.name + ': ' + point.y + ' m/s'; 
    }); 

    return s; 
} 

}

它完美對於使用花的defaultSeriesType圖,但它不」 t適用於散點圖。

請參閱此小提琴http://jsfiddle.net/s83aT/爲樣條和分散的行動。

任何意見將不勝感激。提前致謝。

+1

正如我所見,它是由共享選項引起的,當它被設置爲false時,出現工具提示。 – 2013-02-21 11:18:46

+0

@ SebastianBochan謝謝,這確實指向了我最終實現的解決方案,請參見下文。 – 2013-02-25 11:31:16

回答

2

在Sebastian Bochan指出「共享:真實」是問題的一部分之後,我對此進行了更多的研究,這裏是我發現的以及我最終如何解決問題。不管出於什麼原因,小提琴在這個問題上都被搞砸了。

shared: true 

是必需的,如果圖表中有多個系列,並且想要將所有系列顯示在相同的工具提示中。在我的情況下,這是來自我製作的其他情節中的剩餘物,但是我的原始問題關於單個情節不需要。

不應使用「series:true」的單個系列圖。它默認爲「shared:false」,因此「共享」根本不需要包含。

這裏的,我現在使用的格式代碼,它適用於所有單系列,無論是花鍵或散射:

tooltip: { 
    crosshairs: true, 
    formatter: function() { 
     return '<b>' + Highcharts.dateFormat('%e. %b %Y, %H:00', this.x) + 
       '</b> ' + this.series.name + ': ' + this.y + ' deg'; 
    } 
}, 

在行動,在花鍵和散點圖見http://jsfiddle.net/Reality_Extractor/pNFYL/