Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1390
igChart Knoutout Extensions
posted

Hi I needed a knockout binding extension for the igChart, this is what a came up with.

// Infragistics Chart.
(function ($) {
	ko.bindingHandlers['igChart'] = {
		init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
			var value		= ko.utils.unwrapObservable(valueAccessor());
			var bindings	= ko.bindingHandlers['igChart']._getBindings(allBindingsAccessor);
			$(element)[bindings.igChart.type](bindings.igChart.options);
		},
		update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {			
			var bindings = ko.bindingHandlers['igChart']._getBindings(allBindingsAccessor);			
			$(element)[bindings.igChart.type]({ dataSource: bindings.igChart.options.dataSource });
		},
		_getBindings: function (allBindingsAccessor)
		{
			var bindings = allBindingsAccessor();
			return jQuery.extend({}, bindings, {
				dataSource: typeof bindings.igChart.options.dataSource == "function"
					? bindings.igChart.options.dataSource()
					: bindings.igChart.options.dataSource
			});
		}
	};	
})(jQuery);
Parents
No Data
Reply
  • 37874
    posted

    Hello christoffelleroux,

    Thank you for sharing this with the community, it will be helpful for others that want to use knockoutjs with igChart.

Children
No Data