Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: fix chart plugins type (#786)
change chart plugins type from object to array, fix tests and examples

#782
  • Loading branch information
thabarbados committed Mar 29, 2022
1 parent e39aa45 commit 65762c8
Show file tree
Hide file tree
Showing 61 changed files with 171 additions and 229 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -129,8 +129,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down Expand Up @@ -183,8 +183,8 @@ export default defineComponent({
default: () => {}
},
plugins: {
type: Object as PropType<PluginOptionsByType<'bar'>>,
default: () => {}
type: Array as PropType<Plugin<'bar'>[]>,
default: () => []
}
},
setup(props) {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/bar/src/components/Bar.vue
Expand Up @@ -58,8 +58,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/bubble/src/components/Bubble.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/doughnut/src/components/Doughnut.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/line/src/components/Line.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/pie/src/components/Pie.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/polar-area/src/components/PolarArea.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/radar/src/components/Radar.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/sandboxes/scatter/src/components/Scatter.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
8 changes: 4 additions & 4 deletions legacy/src/Charts.js
Expand Up @@ -14,7 +14,6 @@ import {
chartCreate,
chartDestroy,
chartUpdate,
getChartOptions,
getChartData,
setChartLabels,
setChartDatasets,
Expand Down Expand Up @@ -59,8 +58,8 @@ export function generateChart(chartId, chartType, chartController) {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down Expand Up @@ -100,7 +99,8 @@ export function generateChart(chartId, chartType, chartController) {
this.$data._chart = new ChartJS(canvasEl2DContext, {
type: chartType,
data: chartData,
options: getChartOptions(options, this.plugins)
options,
plugins: this.plugins
})
}
}
Expand Down
8 changes: 3 additions & 5 deletions legacy/test/Bar.spec.js
Expand Up @@ -31,15 +31,13 @@ describe('LegacyBar', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/Bubble.spec.js
Expand Up @@ -32,15 +32,13 @@ describe('LegacyBubble', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/Doughnut.spec.js
Expand Up @@ -32,15 +32,13 @@ describe('LegacyDoughnut', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/Line.spec.js
Expand Up @@ -31,15 +31,13 @@ describe('LegacyLine', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/Pie.spec.js
Expand Up @@ -31,15 +31,13 @@ describe('LegacyPie', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/PolarArea.spec.js
Expand Up @@ -32,15 +32,13 @@ describe('LegacyPolarArea', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/Radar.spec.js
Expand Up @@ -32,15 +32,13 @@ describe('LegacyRadar', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
8 changes: 3 additions & 5 deletions legacy/test/Scatter.spec.js
Expand Up @@ -32,15 +32,13 @@ describe('LegacyScatter', () => {

it('should add inline plugins based on prop', () => {
const testPlugin = {
title: {
display: true
}
id: 'test'
}

const wrapper = mount(Component, {
propsData: { plugins: testPlugin }
propsData: { plugins: [testPlugin] }
})

expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
expect(wrapper.props().plugins.length).toEqual(1)
})
})
4 changes: 2 additions & 2 deletions legacy/test/examples/Bar.vue
Expand Up @@ -58,8 +58,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/Bubble.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/Doughnut.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/Line.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/Pie.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/PolarArea.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/Radar.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions legacy/test/examples/Scatter.vue
Expand Up @@ -57,8 +57,8 @@ export default {
default: () => {}
},
plugins: {
type: Object,
default: () => {}
type: Array,
default: () => []
}
},
data() {
Expand Down
1 change: 0 additions & 1 deletion package.json
@@ -1,7 +1,6 @@
{
"name": "vue-chartjs",
"version": "4.0.2",
"packageManager": "pnpm@6.32.2",
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
"author": "Jakub Juszczak <jakub@posteo.de>",
"homepage": "http://vue-chartjs.org",
Expand Down

0 comments on commit 65762c8

Please sign in to comment.