Kendo UI chart not resizing?

2020-04-04 15:02发布

enter image description here

I have a Kendo ui chart which displays a column chart from a dynamic data source. But occassionally, the chart opens half the size of the available space. When I click on some links or change the date, it resizes itself. Any idea why its causing it?

In the datasource change event, its showing the container div's width as 0 when it shows this behaviour. I can give more details if needed

I tried the refresh method as given in one of the answers but its not of help

标签: kendo-ui
6条回答
别忘想泡老子
2楼-- · 2020-04-04 15:10

Try this

var chart=$("#chart").data("kendoChart");
//to check the chart exist or not if exist then redraw it..
if(chart)
{
chart.redraw();
}

Thanks

查看更多
太酷不给撩
3楼-- · 2020-04-04 15:15

This happens generally when you open a chart in a animated window before it is finished expanding.

My suggestion is to redraw the chart when you are sure everything is loaded and fully opened.

$("#myChart").data("kendoChart").redraw();

If you have not disabled animations you may want to do that before this and re-enable them after.

$("#myChart").data("kendoChart").options.transitions = false;
查看更多
The star\"
4楼-- · 2020-04-04 15:19

When you have got all the necessary data in the controller you can call a Javascript CallBack function in which you can set the transition to false and then redraw the chart and set transition to true, also you can hide the chart by default and make it visible on Javascript CallBack function

查看更多
ら.Afraid
5楼-- · 2020-04-04 15:28

$("#divSensingData").kendoChart({ chartArea: { width: 900, height: 500 },

查看更多
放我归山
6楼-- · 2020-04-04 15:32

This is what I using for my charts:

if($("#areaChart").data("kendoChart")) {
    $("#areaChart svg").width(Number($('.k-content').width()));
    $("#areaChart svg").height(Number($('.k-content').height()));

    $("#areaChart").data("kendoChart").refresh();
}

Taken from here

Have you checked the resize() Method?

查看更多
成全新的幸福
7楼-- · 2020-04-04 15:32

I fixed it by adding a small delay after calling the CreateChart() function as below:

CreateChart(this.id, this.id + " this week", "week", null);
    sleep(1000);

its working fine now

查看更多
登录 后发表回答