mirror of
				https://github.com/KevinMidboe/vue-chartjs.git
				synced 2025-10-29 18:00:20 +00:00 
			
		
		
		
	Add support for inline plugins
This commit is contained in:
		| @@ -56,18 +56,23 @@ export default Vue.extend({ | ||||
|             barPercentage: 0.2 | ||||
|           }] | ||||
|         } | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|       this._chart = new Chart( | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'bar', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -56,11 +56,15 @@ export default Vue.extend({ | ||||
|             barPercentage: 0.2 | ||||
|           }] | ||||
|         } | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
| @@ -68,7 +72,8 @@ export default Vue.extend({ | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'bubble', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -39,11 +39,15 @@ export default Vue.extend({ | ||||
|   data () { | ||||
|     return { | ||||
|       defaultOptions: { | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
| @@ -51,7 +55,8 @@ export default Vue.extend({ | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'doughnut', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -56,18 +56,23 @@ export default Vue.extend({ | ||||
|             barPercentage: 0.2 | ||||
|           }] | ||||
|         } | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options, type) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|       this._chart = new Chart( | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'horizontalBar', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -54,11 +54,15 @@ export default Vue.extend({ | ||||
|             } | ||||
|           }] | ||||
|         } | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
| @@ -66,7 +70,8 @@ export default Vue.extend({ | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'line', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -39,11 +39,15 @@ export default Vue.extend({ | ||||
|   data () { | ||||
|     return { | ||||
|       defaultOptions: { | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
| @@ -51,7 +55,8 @@ export default Vue.extend({ | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'pie', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -39,11 +39,15 @@ export default Vue.extend({ | ||||
|   data () { | ||||
|     return { | ||||
|       defaultOptions: { | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
| @@ -51,7 +55,8 @@ export default Vue.extend({ | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'polarArea', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
| @@ -39,11 +39,15 @@ export default Vue.extend({ | ||||
|   data () { | ||||
|     return { | ||||
|       defaultOptions: { | ||||
|       } | ||||
|       }, | ||||
|       plugins: [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   methods: { | ||||
|     addPlugin (plugin) { | ||||
|       this.plugins.push(plugin) | ||||
|     }, | ||||
|     renderChart (data, options) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
| @@ -51,7 +55,8 @@ export default Vue.extend({ | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: 'radar', | ||||
|           data: data, | ||||
|           options: chartOptions | ||||
|           options: chartOptions, | ||||
|           plugins: this.plugins | ||||
|         } | ||||
|       ) | ||||
|       this._chart.generateLegend() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user