Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-size the Kendo chart while Minimize the window of browser?

In our team project we are using the KendoUI controls here issue while minimize the window chart size not decreasing.How to increase/decrease the size of chart while maximize/minimize the window of browser.?

like image 565
user2314027 Avatar asked Apr 26 '13 10:04

user2314027


People also ask

How do I resize a kendo window?

The Window enables you to set its width and height, and change its dimensions by dragging the resize handles.

How do I resize a kendo grid?

You can enable column resizing for the Kendo UI grid via a simple configuration setting. All you have to do is set its resizable attribute to true, which will make its columns resizable by displaying drag handles/hints when you hover in between their headers.

How do I change the row height in kendo grid?

changing the row height by using custom CSS styles, requires updating the rowHeight option too. For example, if we customize the row height by setting line-height: 28px; the rowHeight should represent the actual height of each Grid row (tr) element in the DOM.


1 Answers

Try this works to me:

<div id="example">
   <div id="chart"></div>
</div>

<script>  
    // Chart Data Source
    var exampleData = [
         { "FromDept": "ACT", "ToDept": "NSW", "Year": 2010, "Total": 101 },
         { "FromDept": "ACT", "ToDept": "NSW", "Year": 2011, "Total": 1001 },
         { "FromDept": "ACT", "ToDept": "NSW", "Year": 2012, "Total": 501 },
         { "FromDept": "ACT", "ToDept": "YNT", "Year": 2010, "Total": 501 }
    ];


    // Function to create Chart
    function createChart() {

        // Creating kendo chart using exampleData
        $("#chart").kendoChart({
            title: {
                text: "Sample"
            },
            dataSource:
            {
                data: exampleData,
            },
            legend: {
                position: "bottom"
            },
            chartArea: {
                background: ""
            },
            seriesDefaults: {
                type: "line"
            },
            series: [{
                field: "Total",
            }],
            valueAxis: {
                labels: {
                    format: "${0}"
                }
            },
            categoryAxis: {
                field: "Year"
            },
            tooltip: {
                visible: true,
                format: "{0}%"
            }
        });
    }

    // Resize the chart whenever window is resized
    $(window).resize(function () {
        $("#chart svg").width(Number($(window).width()));
        $("#chart svg").height(Number($(window).height()));
        $("#chart").data("kendoChart").refresh();
    });

    // Document ready function
    $(document).ready(function () {

        // Initialize the chart with a delay to make sure
        // the initial animation is visible
        createChart();

        // Initially
        $("#chart svg").width(Number($(window).width()));
        $("#chart svg").height(Number($(window).height()));
        $("#chart").data("kendoChart").refresh();

    });
</script>

like image 52
Muthu Avatar answered Sep 30 '22 20:09

Muthu