Skip to content

Commit 65762c8

Browse files
authored
fix: fix chart plugins type (#786)
change chart plugins type from object to array, fix tests and examples #782
1 parent e39aa45 commit 65762c8

File tree

61 files changed

+171
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+171
-229
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ export default {
129129
default: () => {}
130130
},
131131
plugins: {
132-
type: Object,
133-
default: () => {}
132+
type: Array,
133+
default: () => []
134134
}
135135
},
136136
data() {
@@ -183,8 +183,8 @@ export default defineComponent({
183183
default: () => {}
184184
},
185185
plugins: {
186-
type: Object as PropType<PluginOptionsByType<'bar'>>,
187-
default: () => {}
186+
type: Array as PropType<Plugin<'bar'>[]>,
187+
default: () => []
188188
}
189189
},
190190
setup(props) {

legacy/sandboxes/bar/src/components/Bar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export default {
5858
default: () => {}
5959
},
6060
plugins: {
61-
type: Object,
62-
default: () => {}
61+
type: Array,
62+
default: () => []
6363
}
6464
},
6565
data() {

legacy/sandboxes/bubble/src/components/Bubble.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/sandboxes/doughnut/src/components/Doughnut.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/sandboxes/line/src/components/Line.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/sandboxes/pie/src/components/Pie.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/sandboxes/polar-area/src/components/PolarArea.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/sandboxes/radar/src/components/Radar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/sandboxes/scatter/src/components/Scatter.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/src/Charts.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
chartCreate,
1515
chartDestroy,
1616
chartUpdate,
17-
getChartOptions,
1817
getChartData,
1918
setChartLabels,
2019
setChartDatasets,
@@ -59,8 +58,8 @@ export function generateChart(chartId, chartType, chartController) {
5958
default: () => {}
6059
},
6160
plugins: {
62-
type: Object,
63-
default: () => {}
61+
type: Array,
62+
default: () => []
6463
}
6564
},
6665
data() {
@@ -100,7 +99,8 @@ export function generateChart(chartId, chartType, chartController) {
10099
this.$data._chart = new ChartJS(canvasEl2DContext, {
101100
type: chartType,
102101
data: chartData,
103-
options: getChartOptions(options, this.plugins)
102+
options,
103+
plugins: this.plugins
104104
})
105105
}
106106
}

legacy/test/Bar.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ describe('LegacyBar', () => {
3131

3232
it('should add inline plugins based on prop', () => {
3333
const testPlugin = {
34-
title: {
35-
display: true
36-
}
34+
id: 'test'
3735
}
3836

3937
const wrapper = mount(Component, {
40-
propsData: { plugins: testPlugin }
38+
propsData: { plugins: [testPlugin] }
4139
})
4240

43-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
41+
expect(wrapper.props().plugins.length).toEqual(1)
4442
})
4543
})

legacy/test/Bubble.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ describe('LegacyBubble', () => {
3232

3333
it('should add inline plugins based on prop', () => {
3434
const testPlugin = {
35-
title: {
36-
display: true
37-
}
35+
id: 'test'
3836
}
3937

4038
const wrapper = mount(Component, {
41-
propsData: { plugins: testPlugin }
39+
propsData: { plugins: [testPlugin] }
4240
})
4341

44-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
42+
expect(wrapper.props().plugins.length).toEqual(1)
4543
})
4644
})

legacy/test/Doughnut.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ describe('LegacyDoughnut', () => {
3232

3333
it('should add inline plugins based on prop', () => {
3434
const testPlugin = {
35-
title: {
36-
display: true
37-
}
35+
id: 'test'
3836
}
3937

4038
const wrapper = mount(Component, {
41-
propsData: { plugins: testPlugin }
39+
propsData: { plugins: [testPlugin] }
4240
})
4341

44-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
42+
expect(wrapper.props().plugins.length).toEqual(1)
4543
})
4644
})

legacy/test/Line.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ describe('LegacyLine', () => {
3131

3232
it('should add inline plugins based on prop', () => {
3333
const testPlugin = {
34-
title: {
35-
display: true
36-
}
34+
id: 'test'
3735
}
3836

3937
const wrapper = mount(Component, {
40-
propsData: { plugins: testPlugin }
38+
propsData: { plugins: [testPlugin] }
4139
})
4240

43-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
41+
expect(wrapper.props().plugins.length).toEqual(1)
4442
})
4543
})

legacy/test/Pie.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ describe('LegacyPie', () => {
3131

3232
it('should add inline plugins based on prop', () => {
3333
const testPlugin = {
34-
title: {
35-
display: true
36-
}
34+
id: 'test'
3735
}
3836

3937
const wrapper = mount(Component, {
40-
propsData: { plugins: testPlugin }
38+
propsData: { plugins: [testPlugin] }
4139
})
4240

43-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
41+
expect(wrapper.props().plugins.length).toEqual(1)
4442
})
4543
})

legacy/test/PolarArea.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ describe('LegacyPolarArea', () => {
3232

3333
it('should add inline plugins based on prop', () => {
3434
const testPlugin = {
35-
title: {
36-
display: true
37-
}
35+
id: 'test'
3836
}
3937

4038
const wrapper = mount(Component, {
41-
propsData: { plugins: testPlugin }
39+
propsData: { plugins: [testPlugin] }
4240
})
4341

44-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
42+
expect(wrapper.props().plugins.length).toEqual(1)
4543
})
4644
})

legacy/test/Radar.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ describe('LegacyRadar', () => {
3232

3333
it('should add inline plugins based on prop', () => {
3434
const testPlugin = {
35-
title: {
36-
display: true
37-
}
35+
id: 'test'
3836
}
3937

4038
const wrapper = mount(Component, {
41-
propsData: { plugins: testPlugin }
39+
propsData: { plugins: [testPlugin] }
4240
})
4341

44-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
42+
expect(wrapper.props().plugins.length).toEqual(1)
4543
})
4644
})

legacy/test/Scatter.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ describe('LegacyScatter', () => {
3232

3333
it('should add inline plugins based on prop', () => {
3434
const testPlugin = {
35-
title: {
36-
display: true
37-
}
35+
id: 'test'
3836
}
3937

4038
const wrapper = mount(Component, {
41-
propsData: { plugins: testPlugin }
39+
propsData: { plugins: [testPlugin] }
4240
})
4341

44-
expect(Object.keys(wrapper.props().plugins).length).toEqual(1)
42+
expect(wrapper.props().plugins.length).toEqual(1)
4543
})
4644
})

legacy/test/examples/Bar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export default {
5858
default: () => {}
5959
},
6060
plugins: {
61-
type: Object,
62-
default: () => {}
61+
type: Array,
62+
default: () => []
6363
}
6464
},
6565
data() {

legacy/test/examples/Bubble.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/test/examples/Doughnut.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/test/examples/Line.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/test/examples/Pie.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/test/examples/PolarArea.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/test/examples/Radar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

legacy/test/examples/Scatter.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default {
5757
default: () => {}
5858
},
5959
plugins: {
60-
type: Object,
61-
default: () => {}
60+
type: Array,
61+
default: () => []
6262
}
6363
},
6464
data() {

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "vue-chartjs",
33
"version": "4.0.2",
4-
"packageManager": "[email protected]",
54
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
65
"author": "Jakub Juszczak <[email protected]>",
76
"homepage": "http://vue-chartjs.org",

0 commit comments

Comments
 (0)