更改为以下代码:
var boxWidth = $("#chart").width();
$("#chart").mouseenter(function(){
$(this).animate({
width: "1500"
});
});
$("#chart").mouseleave(function(){
$(this).animate({
width: boxWidth,
});
});
但正如您所看到的那样,唯一的变化是背景宽度而不是图表,这里是片段:
答案 0 :(得分:1)
您需要重新初始化图表。
$("#chart").mouseenter(function() {
if ($(this).width() != 1000) {
$(this).animate({
width: "1000px"
}, function() {
createChart();
});
}
});
$("#chart").mouseleave(function() {
if ($(this).width() != boxWidth) {
$(this).animate({
width: boxWidth
}, function() {
createChart();
});
}
});
这里我正在检查宽度,因为只在宽度变化时重新创建一次图表。
<强>更新强>
不要再次创建图表,只需刷新它,它将占用容器的宽度和高度。
$("#chart").data("kendoChart").refresh();
答案 1 :(得分:-1)
您必须再次createChart()
才能在图表上实际执行刷新。
$("#chart").mouseenter(function(){
$(this).animate({
width: "1500"
});
createChart();
});