我的问题如下:
我希望在Kendo UI中有一个scatterLine图表,我可以在其中显示工具提示并具有seriesHover效果。
演示:http://jsfiddle.net/9Lvzu9qh/2/
评论第44行:
chart.redraw();
看到我的问题。如果重绘图表,则清除工具提示。如果图表没有重新绘制,我就不会得到我的高光效果。
如何同时获得重点和工具提示?也可以接受解决这两个问题的替代方法。
答案 0 :(得分:2)
只有当我更改系列时,我才能保存以前的ID并更改颜色:
var previousId = 0;
$("#chart").kendoChart({
title: {
text: "Line demo (Kendo UI v2014.3.1119)"
},
legend: {
position: "bottom"
},
seriesDefaults: {
type: "scatterLine",
width: 2,
},
series: [{
name: "A",
data: [[0,1], [1,2], [2,3]]
},
{
name: "B",
data: [[0,2], [1,3], [2,5]]
},
{
name: "C",
data: [[0,3], [1,5], [2,2]]
}
],
seriesHover : function(e) {
var chart = e.sender;
var idx = _.findIndex(chart.options.series, function (s) {
return s === e.series;
});
if(previousId != idx)
previousId = idx;
else
return;
if (idx >= 0) {
var thisSeries = chart.options.series[idx];
// attach event to hovering over a series
// On hover, set opacity to full and increase width
// Decrease opacity and width on all other series
_.each(chart.options.series, function (s) {
s.width = 2;
s.opacity = 0.4;
});
thisSeries.width = 4;
thisSeries.opacity = 1;
$("#chart").data("kendoChart").redraw();
}
},
tooltip: {
visible: true,
format: "X: {0} Y: {1}"
},
transitions: false
});
希望它有所帮助。