Chartjs-How to push a variable number of datasets to a chart data, without the _observer "magic"_ (using vuecharts.js)?

1๐Ÿ‘

โœ…

Use options instead:

name: 'myComponent',
data: () {
  return {
    some: 'properties'
  }
},
nonReactiveData: {
  whatever: 'you like'
}

This basically creates your component with an option named nonReactiveData. Then you could use it in your html like:

<some-component :data="$options.nonReactiveData">

Or if you need it in your script:

methods: {
  someMethod() {
    console.log(this.$options.nonReactiveData)
  }
}

Hope that helps ๐Ÿ™‚

0๐Ÿ‘

Fixed it by concatenating the dynamicDataCollection Object:

     that.dynamicDataCollection = [];
        for (i =0; i < allDeptNames.length; i++) {
            let datasets = [
                {
                label: allDeptNames[i],
                backgroundColor: barColours[i],
                data: [spaceIterationIns[i].length] 
                }
            ]
            that.dynamicDataCollection.push(datasets);
        }
// here
        let dynamicFlat = [].concat.apply([], that.dynamicDataCollection)  
        that.datacollection2 = {
            labels: ['Weekly'],                
            datasets: [                           
            ]
        }
// and then here
        that.datacollection2.datasets = dynamicFlat;

Leave a comment