Created
March 24, 2015 10:22
-
-
Save MatthewBarker/b1e10b4296a6ca1f72c4 to your computer and use it in GitHub Desktop.
Knockout-Kendo custom chart binding override to watch the graph options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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