Skip to content

Commit bb21a40

Browse files
committed
Rewrite template option to render function
1 parent e4ba9ea commit bb21a40

File tree

8 files changed

+131
-37
lines changed

8 files changed

+131
-37
lines changed

src/BaseCharts/Bar.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {
@@ -51,7 +63,6 @@ export default Vue.extend({
5163
methods: {
5264
renderChart (data, options, type) {
5365
let chartOptions = mergeOptions(this.defaultOptions, options)
54-
5566
this._chart = new Chart(
5667
this.$refs.canvas.getContext('2d'), {
5768
type: type || 'bar',

src/BaseCharts/Bubble.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {

src/BaseCharts/Doughnut.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {

src/BaseCharts/Line.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {

src/BaseCharts/Pie.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {

src/BaseCharts/PolarArea.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {

src/BaseCharts/Radar.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import Chart from 'chart.js'
33
import { mergeOptions } from '../helpers/options'
44

55
export default Vue.extend({
6-
template: `
7-
<div>
8-
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
9-
</div>
10-
`,
6+
render: function (createElement) {
7+
return createElement(
8+
'div',
9+
[
10+
createElement(
11+
'canvas', {
12+
attrs: {
13+
id: this.chartId,
14+
width: this.width,
15+
height: this.height
16+
},
17+
ref: 'canvas'
18+
}
19+
)
20+
]
21+
)
22+
},
1123

1224
props: {
1325
chartId: {

yarn.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,10 @@ dateformat@^1.0.6:
15351535
get-stdin "^4.0.1"
15361536
meow "^3.3.0"
15371537

1538+
de-indent@^1.0.2:
1539+
version "1.0.2"
1540+
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
1541+
15381542
15391543
version "0.7.4"
15401544
resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39"
@@ -2527,7 +2531,7 @@ hawk@~3.1.3:
25272531
hoek "2.x.x"
25282532
sntp "1.x.x"
25292533

2530-
2534+
[email protected], he@^1.1.0:
25312535
version "1.1.0"
25322536
resolved "https://registry.yarnpkg.com/he/-/he-1.1.0.tgz#29319d49beec13a9b1f3c4f9b2a6dde4859bb2a7"
25332537

@@ -5501,6 +5505,13 @@ vue-style-loader@^1.0.0:
55015505
dependencies:
55025506
loader-utils "^0.2.7"
55035507

5508+
vue-template-compiler@^2.1.6:
5509+
version "2.1.6"
5510+
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.1.6.tgz#f96f968652fc1e861bb0052f61993ba1fdc18ad3"
5511+
dependencies:
5512+
de-indent "^1.0.2"
5513+
he "^1.1.0"
5514+
55045515
vue-template-es2015-compiler@^1.2.2:
55055516
version "1.4.0"
55065517
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.4.0.tgz#7b88853ca4bf8d84ae54ab9e56771de271e60198"

0 commit comments

Comments
 (0)