DataViz Widgets and MVVM

1 posts, 0 answers
  1. Alexey
    Alexey avatar
    1 posts
    Member since:
    Mar 2012

    Posted 28 Mar 2012 Link to this post

    Is it any chance to have Pie Chart or other DataViz widget refreshed after property of my VM was changed?
    I've tried to init charts with VM wrapped by kendo.observable like:
    var viewModel = kendo.observable({
                    theme: "default",
                    title: { text: "Break-up of Spain Electricity Production for 2008" },
                    legend: { position: "bottom" },
                    seriesDefaults: { labels: { visible: true, format: "{0}%" }},
                    series: [{ type: "pie",
                        data: [ { category: "Hydro", value: 10 }, { category: "Solar", value: 20 }, 
           { category: "Nuclear", value: 30 }, { category: "Wind", value: 40}]         
     }]
                });
                $("#chart").kendoChart(viewModel);

    but no luck - my chart was not generated at all.
    It works better if wrap only data for series
    var viewModel = {
                    theme: "default",
                    title: { text: "Break-up of Spain Electricity Production for 2008" },
                    legend: { position: "bottom" },
                    seriesDefaults: { labels: { visible: true, format: "{0}%" }},
                    series: [{ type: "pie",
                        data: kendo.observable([ { category: "Hydro", value: 10 }, { category: "Solar", value: 20 }, 
           { category: "Nuclear", value: 30 }, { category: "Wind", value: 40}])
     }]
                };
                $("#chart").kendoChart(viewModel); 
    but no refresh happened after i changed the collection:
    viewModel.series[0].data.pop();
    viewModel.series[0].data.pop();
    viewModel.series[0].data.push({ category: "New", value: 70 });
    even after i call
    $("#chart").data("kendoChart").refresh();
    Is it any chance to refreshing DataViz control without recreating it?

    Thank you.

    PS: I want to add one more voice for knockoutJS and drill down option for charts :)
Back to Top