Javascript 剑道UI图表工具提示和重画
我的问题如下: 我想有一个散线图在剑道用户界面,我可以显示一个工具提示,并有一个系列的效果 演示: 注释第44行:Javascript 剑道UI图表工具提示和重画,javascript,jquery,charts,kendo-ui,kendo-dataviz,Javascript,Jquery,Charts,Kendo Ui,Kendo Dataviz,我的问题如下: 我想有一个散线图在剑道用户界面,我可以显示一个工具提示,并有一个系列的效果 演示: 注释第44行: chart.redraw()查看我的问题。如果重新绘制图表,工具提示将被清除。如果图表没有重画,我就不会得到高光效果 如何同时获得突出显示和工具提示?解决这两个问题的替代方法也被接受。我让它在保存以前的id和仅在更改系列时更改颜色时起作用: var previousId = 0; $("#chart").kendoChart({ title: { text:
chart.redraw()代码>查看我的问题。如果重新绘制图表,工具提示将被清除。如果图表没有重画,我就不会得到高光效果
如何同时获得突出显示和工具提示?解决这两个问题的替代方法也被接受。我让它在保存以前的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
});
希望能有帮助
Fiddle:只有在更改系列时,我才能保存以前的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
});
希望能有帮助
Fiddle:只有在更改系列时,我才能保存以前的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
});
希望能有帮助
Fiddle:只有在更改系列时,我才能保存以前的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
});
希望能有帮助
小提琴手:谢谢,这非常有效!我会尽快给你赏金的,谢谢!我之所以这么做是因为事件在一秒钟内触发了几次,所以图表一直在重新绘制(我想包括工具提示)。因此,只有当您更改系列时,图表才会重新绘制。抱歉,英语不好。呵呵,这实际上意味着除了功能现在正常工作之外,我还得到了性能升级:)谢谢,这非常有效!我会尽快给你赏金的,谢谢!我之所以这么做是因为事件在一秒钟内触发了几次,所以图表一直在重新绘制(我想包括工具提示)。因此,只有当您更改系列时,图表才会重新绘制。抱歉,英语不好。呵呵,这实际上意味着除了功能现在正常工作之外,我还得到了性能升级:)谢谢,这非常有效!我会尽快给你赏金的,谢谢!我之所以这么做是因为事件在一秒钟内触发了几次,所以图表一直在重新绘制(我想包括工具提示)。因此,只有当您更改系列时,图表才会重新绘制。抱歉,英语不好。呵呵,这实际上意味着除了功能现在正常工作之外,我还得到了性能升级:)谢谢,这非常有效!我会尽快给你赏金的,谢谢!我之所以这么做是因为事件在一秒钟内触发了几次,所以图表一直在重新绘制(我想包括工具提示)。因此,只有当您更改系列时,图表才会重新绘制。抱歉,英语不好。嘿,这实际上意味着除了功能现在正常工作之外,我还得到了性能升级:)