Merge pull request #276 from daniel-shuy/develop

Add prop for inline plugins
This commit is contained in:
Jakub
2017-12-15 09:50:49 +01:00
committed by GitHub
18 changed files with 297 additions and 45 deletions

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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
}
)
}

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})

View File

@@ -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)
})
})