0
我正在尋找由Brian Peiris(http://brian.peiris.name/highlightSeries/)製作的highlightSeries插件的幫助。它似乎沒有工作;我敢肯定的是,事件被解僱,因爲我在前面進行的警報測試工作就好了,打印出來$(this).text()
。當用戶將鼠標放在圖例中的系列名稱上時,我試圖讓圖表上的這個系列突出顯示(這在Peiris先生的網站上完美無瑕)。jquery flot charts的highlightSeries插件
$('.server-chart').each(function() {
var serv = $(this).attr('id').substr(6);
var plotData = [];
//alert(serv + ": " + $.toJSON(serverStats[serv]));
for (var k in serverStats[serv].StatsByCollection) {
var outlabel = k;
var outdata = serverStats[serv].StatsByCollection[k];
plotData.push({ label: outlabel, data: outdata});
}
plotOptions = {
legend: {
container: $('#legend-' + serv),
labelFormatter: function(label, series) {
return '<a href="#' + label + '" class="checked label-clickable">' + label + '</a>';
},
noColumns: 2
},
series: {
lines: {
show: true,
fill: false
},
points: {
show: false,
fill: false
}
},
colors: colors,
grid: {
hoverable: false
},
highlightSeries: {
color: "#FF00FF"
}
}
$_plot = $.plot(this, plotData, plotOptions);
$plots.push($_plot);
$('#legend-' + serv + ' .legendLabel, #legend-' + serv + ' .legendColorBox').on('mouseenter', function() {
$_plot.highlightSeries($(this).text());
});
$('#legend-' + serv + ' .legendLabel, #legend-' + serv + ' .legendColorBox').on('mouseleave', function() {
$_plot.unHighlightSeries($(this).text());
});
});
我不確定其他代碼放在這裏,所以告訴我,如果你需要更多的;圖表都工作正常,這只是準備功能的一部分,設置佔位符內的所有圖表和它們的選項。
此外,還有一些附加到標籤的類是無關的;我正在嘗試不同的方式來讓這些東西起作用。
我竟然想通了,這是由於涉及到$ _plot變量一個奇怪的問題;基本上,沒有選擇正確的繪圖對象。我在頁面上創建的所有地塊的數組,所以我只是增加了一個「服務器名稱」屬性,因爲他們產生的,並匹配了服務器名稱(SERV變量)的情節,這解決了這個問題的地塊。 感謝您的實施,但我會接受你的答案。 – 2014-10-03 21:44:47