diff --git a/src/BaseCharts/Bar.js b/src/BaseCharts/Bar.js index d5baee6f..a52fd57b 100644 --- a/src/BaseCharts/Bar.js +++ b/src/BaseCharts/Bar.js @@ -41,6 +41,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, data () { @@ -65,13 +71,13 @@ export default { }] } }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -80,7 +86,7 @@ export default { type: 'bar', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/Bubble.js b/src/BaseCharts/Bubble.js index 557ddebe..14df228a 100644 --- a/src/BaseCharts/Bubble.js +++ b/src/BaseCharts/Bubble.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -67,13 +73,13 @@ export default { }] } }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -83,7 +89,7 @@ export default { type: 'bubble', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/Doughnut.js b/src/BaseCharts/Doughnut.js index d1565505..aaab9c79 100644 --- a/src/BaseCharts/Doughnut.js +++ b/src/BaseCharts/Doughnut.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -50,13 +56,13 @@ export default { _chart: null, defaultOptions: { }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -66,7 +72,7 @@ export default { type: 'doughnut', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/HorizontalBar.js b/src/BaseCharts/HorizontalBar.js index dec9dc01..b9e57d58 100644 --- a/src/BaseCharts/HorizontalBar.js +++ b/src/BaseCharts/HorizontalBar.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -67,13 +73,13 @@ export default { }] } }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options, type) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -82,7 +88,7 @@ export default { type: 'horizontalBar', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/Line.js b/src/BaseCharts/Line.js index 802aa663..3daa6591 100644 --- a/src/BaseCharts/Line.js +++ b/src/BaseCharts/Line.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -65,13 +71,13 @@ export default { }] } }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -81,7 +87,7 @@ export default { type: 'line', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/Pie.js b/src/BaseCharts/Pie.js index 355d475e..99d7a4f0 100644 --- a/src/BaseCharts/Pie.js +++ b/src/BaseCharts/Pie.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -50,13 +56,13 @@ export default { _chart: null, defaultOptions: { }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -66,7 +72,7 @@ export default { type: 'pie', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/PolarArea.js b/src/BaseCharts/PolarArea.js index 9f31b2e0..f33b6823 100644 --- a/src/BaseCharts/PolarArea.js +++ b/src/BaseCharts/PolarArea.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -50,13 +56,13 @@ export default { _chart: null, defaultOptions: { }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -66,7 +72,7 @@ export default { type: 'polarArea', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/Radar.js b/src/BaseCharts/Radar.js index 2c24af67..e6acd914 100644 --- a/src/BaseCharts/Radar.js +++ b/src/BaseCharts/Radar.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -50,13 +56,13 @@ export default { _chart: null, defaultOptions: { }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -66,7 +72,7 @@ export default { type: 'radar', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/src/BaseCharts/Scatter.js b/src/BaseCharts/Scatter.js index 65ccb918..e29e0cb0 100644 --- a/src/BaseCharts/Scatter.js +++ b/src/BaseCharts/Scatter.js @@ -42,6 +42,12 @@ export default { }, styles: { type: Object + }, + plugins: { + type: Array, + default () { + return [] + } } }, @@ -56,13 +62,13 @@ export default { }] } }, - plugins: [] + _plugins: this.plugins } }, methods: { addPlugin (plugin) { - this.plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -72,7 +78,7 @@ export default { type: 'scatter', data: data, options: chartOptions, - plugins: this.plugins + plugins: this.$data._plugins } ) } diff --git a/test/unit/specs/Bar.spec.js b/test/unit/specs/Bar.spec.js index accd62c7..661e0deb 100644 --- a/test/unit/specs/Bar.spec.js +++ b/test/unit/specs/Bar.spec.js @@ -76,9 +76,31 @@ describe('BarChart', () => { components: { BarChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + BarChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { BarChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Bubble.spec.js b/test/unit/specs/Bubble.spec.js index eb6bdbe9..8920ad56 100644 --- a/test/unit/specs/Bubble.spec.js +++ b/test/unit/specs/Bubble.spec.js @@ -76,9 +76,31 @@ describe('BubbleChart', () => { components: { BubbleChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + BubbleChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { BubbleChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Doughnut.spec.js b/test/unit/specs/Doughnut.spec.js index afbcd007..932eb088 100644 --- a/test/unit/specs/Doughnut.spec.js +++ b/test/unit/specs/Doughnut.spec.js @@ -76,9 +76,31 @@ describe('DoughnutChart', () => { components: { DoughnutChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + DoughnutChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { DoughnutChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/HorizontalBar.spec.js b/test/unit/specs/HorizontalBar.spec.js index 535362f0..28633c33 100644 --- a/test/unit/specs/HorizontalBar.spec.js +++ b/test/unit/specs/HorizontalBar.spec.js @@ -76,9 +76,31 @@ describe('HorizontalBarChart', () => { components: { HorizontalBarChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + HorizontalBarChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { HorizontalBarChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Line.spec.js b/test/unit/specs/Line.spec.js index 4d0f23df..7d87ca7a 100644 --- a/test/unit/specs/Line.spec.js +++ b/test/unit/specs/Line.spec.js @@ -76,9 +76,31 @@ describe('LineChart', () => { components: { LineChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + LineChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { LineChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Pie.spec.js b/test/unit/specs/Pie.spec.js index e1c14999..ca0e5ba2 100644 --- a/test/unit/specs/Pie.spec.js +++ b/test/unit/specs/Pie.spec.js @@ -75,9 +75,31 @@ describe('PieChart', () => { components: { PieChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + PieChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { PieChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/PolarArea.spec.js b/test/unit/specs/PolarArea.spec.js index 32392254..07ac1927 100644 --- a/test/unit/specs/PolarArea.spec.js +++ b/test/unit/specs/PolarArea.spec.js @@ -76,9 +76,31 @@ describe('PolarChart', () => { components: { PolarChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + PolarChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { PolarChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Radar.spec.js b/test/unit/specs/Radar.spec.js index 86d5020f..352f12dc 100644 --- a/test/unit/specs/Radar.spec.js +++ b/test/unit/specs/Radar.spec.js @@ -75,9 +75,31 @@ describe('RadarChart', () => { components: { RadarChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + RadarChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { RadarChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Scatter.spec.js b/test/unit/specs/Scatter.spec.js index bf5af48a..8e6dc673 100644 --- a/test/unit/specs/Scatter.spec.js +++ b/test/unit/specs/Scatter.spec.js @@ -76,9 +76,31 @@ describe('ScatterChart', () => { components: { ScatterChart } }).$mount(el) - expect(vm.$children[0].plugins).to.exist + expect(vm.$children[0].$data._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins.length).to.equal(1) + }) + + it('should add inline plugins based on prop', () => { + const testPlugin = { + id: 'test' + } + + const vm = new Vue({ + render: function (createElement) { + return createElement( + ScatterChart, { + props: { + plugins: [testPlugin] + } + } + ) + }, + components: { ScatterChart } + }).$mount(el) + + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) })