This is a migrated thread and some comments may be shown as answers.

Resize all Charts on the page

2 Answers 233 Views
Charts
This is a migrated thread and some comments may be shown as answers.
magdil
Top achievements
Rank 1
magdil asked on 08 May 2014, 02:12 PM
Hello,

I am trying to set the height of all the charts on the page to half of the window size. However I keep getting the following error: Uncaught TypeError: undefined is not a function

The code I have is as follows:

$(window).resize(function () {
        // for any chart or gauge widget
        $(".k-chart").each(function () {
            // get the instance of the chart/gauage
            var chart = kendo.widgetInstance($(this), kendo.ui);
            var c = $(this).data("kendoChart");
            // make sure transitions are off
            //chart.options.transitions = false;
            console.log($(window).height() * 0.4);
            c.height($(window).height() * 0.4);
            // redraw the chart/gauge
            if (chart && chart.redraw) {
                chart.redraw();
            }
        });
    });

The error pops up with the c.height($(window).height() * 0.5); statement. 

Any idea what I am doing wrong? I am running the 2014.1.318 version

Thank you

2 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 08 May 2014, 03:43 PM
Hi,

The Chart does not provide a height method, instead it supports resize that picks up the current container size.

You can also call kendo.resize on the top-level container to resize all widgets. See Using Kendo with In Responsive Web Pages

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
magdil
Top achievements
Rank 1
answered on 09 May 2014, 09:53 AM
Thank you. This helped a lot.
Tags
Charts
Asked by
magdil
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
magdil
Top achievements
Rank 1
Share this question
or