Created
March 24, 2015 12:25
-
-
Save MatthewBarker/f9e229194a0318eedf10 to your computer and use it in GitHub Desktop.
Knockout-Kendo custom binding for a bullet graph HTML helper
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.bindingHandlers.kendoBullet = { | |
init: function (element, valueAccessor, | |
allBindingsAccessor, viewModel, bindingContext) { | |
var options = ko.utils.unwrapObservable(valueAccessor()); | |
options.type = 'bullet'; | |
if (!options.chartArea) { | |
options.chartArea = {}; | |
} | |
if (!options.chartArea.background) { | |
options.chartArea.background = 'gainsboro'; | |
} | |
if (!options.tooltip) { | |
options.tooltip = { template: 'Target: #= value.target #<br /> Actual: #= value.current #' }; | |
} | |
if (!options.series[0].target) { | |
options.series[0].target = { color: 'black' }; | |
} | |
if (!options.series[0].gap) { | |
options.series[0].gap = 0; | |
} | |
ko.bindingHandlers.kendoSparkline.init(element, ko.observable(options), | |
allBindingsAccessor, viewModel, bindingContext); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment