Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): fix chart plugins type #786

Merged
merged 1 commit into from Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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