From 5486560257e863c0d207a0eb4d974ab62f260ddf Mon Sep 17 00:00:00 2001 From: Daniel Shuy Date: Wed, 13 Dec 2017 20:02:17 +0800 Subject: [PATCH 1/3] Add prop for inline plugins --- src/BaseCharts/Bar.js | 12 +++++++++--- src/BaseCharts/Bubble.js | 12 +++++++++--- src/BaseCharts/Doughnut.js | 12 +++++++++--- src/BaseCharts/HorizontalBar.js | 12 +++++++++--- src/BaseCharts/Line.js | 12 +++++++++--- src/BaseCharts/Pie.js | 12 +++++++++--- src/BaseCharts/PolarArea.js | 12 +++++++++--- src/BaseCharts/Radar.js | 12 +++++++++--- src/BaseCharts/Scatter.js | 12 +++++++++--- test/unit/specs/Bar.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/Bubble.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/Doughnut.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/HorizontalBar.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/Line.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/Pie.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/PolarArea.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/Radar.spec.js | 26 ++++++++++++++++++++++++-- test/unit/specs/Scatter.spec.js | 26 ++++++++++++++++++++++++-- 18 files changed, 297 insertions(+), 45 deletions(-) diff --git a/src/BaseCharts/Bar.js b/src/BaseCharts/Bar.js index d5baee6f..34403b5a 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._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._plugins } ) } diff --git a/src/BaseCharts/Bubble.js b/src/BaseCharts/Bubble.js index 557ddebe..13321a51 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._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._plugins } ) } diff --git a/src/BaseCharts/Doughnut.js b/src/BaseCharts/Doughnut.js index d1565505..73a01944 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._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._plugins } ) } diff --git a/src/BaseCharts/HorizontalBar.js b/src/BaseCharts/HorizontalBar.js index dec9dc01..eeb4dd30 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._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._plugins } ) } diff --git a/src/BaseCharts/Line.js b/src/BaseCharts/Line.js index 802aa663..029ac2a5 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._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._plugins } ) } diff --git a/src/BaseCharts/Pie.js b/src/BaseCharts/Pie.js index 355d475e..1071c5b4 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._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._plugins } ) } diff --git a/src/BaseCharts/PolarArea.js b/src/BaseCharts/PolarArea.js index 9f31b2e0..d9834c79 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._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._plugins } ) } diff --git a/src/BaseCharts/Radar.js b/src/BaseCharts/Radar.js index 2c24af67..080393d6 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._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._plugins } ) } diff --git a/src/BaseCharts/Scatter.js b/src/BaseCharts/Scatter.js index 65ccb918..b7969398 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._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._plugins } ) } diff --git a/test/unit/specs/Bar.spec.js b/test/unit/specs/Bar.spec.js index accd62c7..ac5c070e 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Bubble.spec.js b/test/unit/specs/Bubble.spec.js index eb6bdbe9..df2c8f5a 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Doughnut.spec.js b/test/unit/specs/Doughnut.spec.js index afbcd007..6a99f7ec 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/HorizontalBar.spec.js b/test/unit/specs/HorizontalBar.spec.js index 535362f0..e5dcaadf 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Line.spec.js b/test/unit/specs/Line.spec.js index 4d0f23df..810f38d8 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Pie.spec.js b/test/unit/specs/Pie.spec.js index e1c14999..a1e0d3eb 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/PolarArea.spec.js b/test/unit/specs/PolarArea.spec.js index 32392254..0ffd9464 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Radar.spec.js b/test/unit/specs/Radar.spec.js index 86d5020f..b38cf486 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) diff --git a/test/unit/specs/Scatter.spec.js b/test/unit/specs/Scatter.spec.js index bf5af48a..6f51a8fd 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]._plugins).to.exist vm.$children[0].addPlugin(testPlugin) - expect(vm.$children[0].plugins.length).to.equal(1) + expect(vm.$children[0]._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]._plugins).to.exist + expect(vm.$children[0]._plugins.length).to.equal(1) }) }) From dd9a5b855dc756a67530ab3b63c189357f34109d Mon Sep 17 00:00:00 2001 From: Daniel Shuy Date: Wed, 13 Dec 2017 20:33:40 +0800 Subject: [PATCH 2/3] Fix test cases for inline prop --- test/unit/specs/Bar.spec.js | 8 ++++---- test/unit/specs/Bubble.spec.js | 8 ++++---- test/unit/specs/Doughnut.spec.js | 8 ++++---- test/unit/specs/HorizontalBar.spec.js | 8 ++++---- test/unit/specs/Line.spec.js | 8 ++++---- test/unit/specs/Pie.spec.js | 8 ++++---- test/unit/specs/PolarArea.spec.js | 8 ++++---- test/unit/specs/Radar.spec.js | 8 ++++---- test/unit/specs/Scatter.spec.js | 8 ++++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/test/unit/specs/Bar.spec.js b/test/unit/specs/Bar.spec.js index ac5c070e..661e0deb 100644 --- a/test/unit/specs/Bar.spec.js +++ b/test/unit/specs/Bar.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('BarChart', () => { components: { BarChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 df2c8f5a..8920ad56 100644 --- a/test/unit/specs/Bubble.spec.js +++ b/test/unit/specs/Bubble.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('BubbleChart', () => { components: { BubbleChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 6a99f7ec..932eb088 100644 --- a/test/unit/specs/Doughnut.spec.js +++ b/test/unit/specs/Doughnut.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('DoughnutChart', () => { components: { DoughnutChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 e5dcaadf..28633c33 100644 --- a/test/unit/specs/HorizontalBar.spec.js +++ b/test/unit/specs/HorizontalBar.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('HorizontalBarChart', () => { components: { HorizontalBarChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 810f38d8..7d87ca7a 100644 --- a/test/unit/specs/Line.spec.js +++ b/test/unit/specs/Line.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('LineChart', () => { components: { LineChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 a1e0d3eb..ca0e5ba2 100644 --- a/test/unit/specs/Pie.spec.js +++ b/test/unit/specs/Pie.spec.js @@ -75,10 +75,10 @@ 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', () => { @@ -99,7 +99,7 @@ describe('PieChart', () => { components: { PieChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 0ffd9464..07ac1927 100644 --- a/test/unit/specs/PolarArea.spec.js +++ b/test/unit/specs/PolarArea.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('PolarChart', () => { components: { PolarChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 b38cf486..352f12dc 100644 --- a/test/unit/specs/Radar.spec.js +++ b/test/unit/specs/Radar.spec.js @@ -75,10 +75,10 @@ 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', () => { @@ -99,7 +99,7 @@ describe('RadarChart', () => { components: { RadarChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + 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 6f51a8fd..8e6dc673 100644 --- a/test/unit/specs/Scatter.spec.js +++ b/test/unit/specs/Scatter.spec.js @@ -76,10 +76,10 @@ 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', () => { @@ -100,7 +100,7 @@ describe('ScatterChart', () => { components: { ScatterChart } }).$mount(el) - expect(vm.$children[0]._plugins).to.exist - expect(vm.$children[0]._plugins.length).to.equal(1) + expect(vm.$children[0].$data._plugins).to.exist + expect(vm.$children[0].$data._plugins.length).to.equal(1) }) }) From 072724fc6f824f1496a1c8e0dd3b7d024bc1eb80 Mon Sep 17 00:00:00 2001 From: Daniel Shuy Date: Wed, 13 Dec 2017 20:58:43 +0800 Subject: [PATCH 3/3] Fix references to private _plugins data property --- src/BaseCharts/Bar.js | 4 ++-- src/BaseCharts/Bubble.js | 4 ++-- src/BaseCharts/Doughnut.js | 4 ++-- src/BaseCharts/HorizontalBar.js | 4 ++-- src/BaseCharts/Line.js | 4 ++-- src/BaseCharts/Pie.js | 4 ++-- src/BaseCharts/PolarArea.js | 4 ++-- src/BaseCharts/Radar.js | 4 ++-- src/BaseCharts/Scatter.js | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/BaseCharts/Bar.js b/src/BaseCharts/Bar.js index 34403b5a..a52fd57b 100644 --- a/src/BaseCharts/Bar.js +++ b/src/BaseCharts/Bar.js @@ -77,7 +77,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -86,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 13321a51..14df228a 100644 --- a/src/BaseCharts/Bubble.js +++ b/src/BaseCharts/Bubble.js @@ -79,7 +79,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -89,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 73a01944..aaab9c79 100644 --- a/src/BaseCharts/Doughnut.js +++ b/src/BaseCharts/Doughnut.js @@ -62,7 +62,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -72,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 eeb4dd30..b9e57d58 100644 --- a/src/BaseCharts/HorizontalBar.js +++ b/src/BaseCharts/HorizontalBar.js @@ -79,7 +79,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options, type) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -88,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 029ac2a5..3daa6591 100644 --- a/src/BaseCharts/Line.js +++ b/src/BaseCharts/Line.js @@ -77,7 +77,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -87,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 1071c5b4..99d7a4f0 100644 --- a/src/BaseCharts/Pie.js +++ b/src/BaseCharts/Pie.js @@ -62,7 +62,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -72,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 d9834c79..f33b6823 100644 --- a/src/BaseCharts/PolarArea.js +++ b/src/BaseCharts/PolarArea.js @@ -62,7 +62,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -72,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 080393d6..e6acd914 100644 --- a/src/BaseCharts/Radar.js +++ b/src/BaseCharts/Radar.js @@ -62,7 +62,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -72,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 b7969398..e29e0cb0 100644 --- a/src/BaseCharts/Scatter.js +++ b/src/BaseCharts/Scatter.js @@ -68,7 +68,7 @@ export default { methods: { addPlugin (plugin) { - this._plugins.push(plugin) + this.$data._plugins.push(plugin) }, renderChart (data, options) { let chartOptions = mergeOptions(this.defaultOptions, options) @@ -78,7 +78,7 @@ export default { type: 'scatter', data: data, options: chartOptions, - plugins: this._plugins + plugins: this.$data._plugins } ) }