grofit / knockout.chart

A knockout binding to allow chart.js and knockout to work together for the greater good.
MIT License
25 stars 12 forks source link

Update does not work on an computed observable #4

Open mika76 opened 7 years ago

mika76 commented 7 years ago

If you have a computed observable like

self.Chart_Played = ko.computed(function () {
    return {
        labels: [
            "Played",
            "Not Played"
        ],
        datasets: [{
            data: [
                self.PlayedMachines, // <-- 1
                (self.Machines().length - self.PlayedMachines()) || 0 // <-- 2
            ],
            backgroundColor: [
                "#FF6384",
                "#36A2EB"
            ],
            hoverBackgroundColor: [
                "#FF6384",
                "#36A2EB"
            ]
        }]
    };
});

there are a coupe of issues.

So all in all there are work arounds, but it would be nice if the code worked a little nicer with computed observables 😊

grofit commented 7 years ago

I dont have capacity to add any features on this at the moment, by all means raise a PR for it.