mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 09:50:21 +00:00
Add prop for inline plugins
This commit is contained in:
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user