mirror of
				https://github.com/KevinMidboe/vue-chartjs.git
				synced 2025-10-29 18:00:20 +00:00 
			
		
		
		
	Rewrite template option to render function
This commit is contained in:
		| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
| @@ -51,7 +63,6 @@ export default Vue.extend({ | ||||
|   methods: { | ||||
|     renderChart (data, options, type) { | ||||
|       let chartOptions = mergeOptions(this.defaultOptions, options) | ||||
|  | ||||
|       this._chart = new Chart( | ||||
|         this.$refs.canvas.getContext('2d'), { | ||||
|           type: type || 'bar', | ||||
|   | ||||
| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
|   | ||||
| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
|   | ||||
| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
|   | ||||
| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
|   | ||||
| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
|   | ||||
| @@ -3,11 +3,23 @@ import Chart from 'chart.js' | ||||
| import { mergeOptions } from '../helpers/options' | ||||
|  | ||||
| export default Vue.extend({ | ||||
|   template: ` | ||||
|     <div> | ||||
|       <canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas> | ||||
|     </div> | ||||
|   `, | ||||
|   render: function (createElement) { | ||||
|     return createElement( | ||||
|       'div', | ||||
|       [ | ||||
|         createElement( | ||||
|           'canvas', { | ||||
|             attrs: { | ||||
|               id: this.chartId, | ||||
|               width: this.width, | ||||
|               height: this.height | ||||
|             }, | ||||
|             ref: 'canvas' | ||||
|           } | ||||
|         ) | ||||
|       ] | ||||
|     ) | ||||
|   }, | ||||
|  | ||||
|   props: { | ||||
|     chartId: { | ||||
|   | ||||
							
								
								
									
										13
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								yarn.lock
									
									
									
									
									
								
							| @@ -1535,6 +1535,10 @@ dateformat@^1.0.6: | ||||
|     get-stdin "^4.0.1" | ||||
|     meow "^3.3.0" | ||||
|  | ||||
| de-indent@^1.0.2: | ||||
|   version "1.0.2" | ||||
|   resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d" | ||||
|  | ||||
| debug@0.7.4: | ||||
|   version "0.7.4" | ||||
|   resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" | ||||
| @@ -2527,7 +2531,7 @@ hawk@~3.1.3: | ||||
|     hoek "2.x.x" | ||||
|     sntp "1.x.x" | ||||
|  | ||||
| he@1.1.x: | ||||
| he@1.1.x, he@^1.1.0: | ||||
|   version "1.1.0" | ||||
|   resolved "https://registry.yarnpkg.com/he/-/he-1.1.0.tgz#29319d49beec13a9b1f3c4f9b2a6dde4859bb2a7" | ||||
|  | ||||
| @@ -5501,6 +5505,13 @@ vue-style-loader@^1.0.0: | ||||
|   dependencies: | ||||
|     loader-utils "^0.2.7" | ||||
|  | ||||
| vue-template-compiler@^2.1.6: | ||||
|   version "2.1.6" | ||||
|   resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.1.6.tgz#f96f968652fc1e861bb0052f61993ba1fdc18ad3" | ||||
|   dependencies: | ||||
|     de-indent "^1.0.2" | ||||
|     he "^1.1.0" | ||||
|  | ||||
| vue-template-es2015-compiler@^1.2.2: | ||||
|   version "1.4.0" | ||||
|   resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.4.0.tgz#7b88853ca4bf8d84ae54ab9e56771de271e60198" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user