Skip to content

Instantly share code, notes, and snippets.

@MatthewBarker
Created March 24, 2015 10:22
Show Gist options
  • Save MatthewBarker/b1e10b4296a6ca1f72c4 to your computer and use it in GitHub Desktop.
Save MatthewBarker/b1e10b4296a6ca1f72c4 to your computer and use it in GitHub Desktop.
Knockout-Kendo custom chart binding override to watch the graph options
ko.kendo.bindingFactory.createBinding({
name: 'kendoChart',
watch: {
data: function (value) {
ko.kendo.setDataSource(this, value);
},
options: function (value) {
//unwrap observables from the options object
var jsonOptions = ko.toJSON(value);
//convert the unwrapped json to a plain object
var options = JSON.parse(jsonOptions);
//pass the options to the chart's setOptions method
this.setOptions(options);
this.refresh();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment