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

Changing dataSource on chart won't update my chart.

3 Answers 322 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 15 Feb 2012, 01:26 PM
I want to update the dataSource of my chart based on a selection in a kendoDropDownList, however no change is applied (and neither do I see exceptions).

$('#parking-filter-select').kendoDropDownList({
    dataSource: usageData,
    change: function (e) {
        var value = $('#parking-filter-select').val();
 
        var chart = $('#chart-utilization').data("kendoChart");
         
        chart.dataSource = new kendo.data.DataSource({
            data: usageData[value].Usage
        });
 
        chart.refresh();
    }
});
 
$('#chart-utilization').kendoChart({ 
    title: {
        text: "Parking utilization for week"
    },
    dataSource:{
        data: usageData[0].Usage
    },
    series:[{
        type: "column",
        field: "Max",
        name: "Max utilization"
    }],
    categoryAxis:{
        field: "Week"
    },
    tooltip: {
        visible: true,
        template: "${ Max } of ${ Capacity }"
    },
    legend: {
        visible: false
    }
});

I tried setting chart.dataSource.data too, but that also didn't work.

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 15 Feb 2012, 01:49 PM
Hi,

 Setting the dataSource field of the chart will not update it. The supported method is this:

chart.dataSource.data(newData);

 If it didn't work in your case we would need to reproduce it locally. You can provide a runnable page or create a jsFiddle.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dennis
Top achievements
Rank 1
answered on 15 Feb 2012, 02:53 PM
http://jsfiddle.net/f8Qzx/  ... which works fine... I am going to get back to you on this and check out what is going wrong.


Mental note: make jsfiddles before posting in the forum ;-).
0
Dennis
Top achievements
Rank 1
answered on 15 Feb 2012, 03:05 PM
Ok, I need to learn to read my own code...

Sorry for taking your time on this, lets just hope the fiddle is useful to someone else ;-).
Tags
Charts
Asked by
Dennis
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Dennis
Top achievements
Rank 1
Share this question
or