Skip to content

Commit 52c1c50

Browse files
authored
Merge pull request #23 from apertureless/feature/runtimebuild
Feature/runtimebuild #22
2 parents c0b854b + 482048b commit 52c1c50

17 files changed

+230
-52
lines changed

build/webpack.base.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = {
1616
extensions: ['', '.js', '.vue'],
1717
fallback: [path.join(__dirname, '../node_modules')],
1818
alias: {
19-
'vue': 'vue/dist/vue.common.js',
2019
'src': path.resolve(__dirname, '../src'),
2120
'mixins': path.resolve(__dirname, '../src/mixins'),
2221
'BaseCharts': path.resolve(__dirname, '../src/BaseCharts')

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"vue-html-loader": "^1.2.3",
8383
"vue-loader": "^10.0.2",
8484
"vue-style-loader": "^1.0.0",
85+
"vue-template-compiler": "^2.1.6",
8586
"webpack": "^1.13.2",
8687
"webpack-dev-middleware": "^1.4.0",
8788
"webpack-hot-middleware": "^2.6.0",

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: {

test/unit/specs/Bar.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ describe('BarChart', () => {
1010

1111
it('should render a canvas', () => {
1212
const vm = new Vue({
13-
template: '<bar-chart></bar-chart>',
13+
render: function (createElement) {
14+
return createElement(
15+
BarChart
16+
)
17+
},
1418
components: { BarChart }
1519
}).$mount(el)
1620

@@ -22,7 +26,15 @@ describe('BarChart', () => {
2226

2327
it('should change id based on prop', () => {
2428
const vm = new Vue({
25-
template: '<bar-chart chartId="barchartprop"></bar-chart>',
29+
render: function (createElement) {
30+
return createElement(
31+
BarChart, {
32+
props: {
33+
chartId: 'barchartprop'
34+
}
35+
}
36+
)
37+
},
2638
components: { BarChart }
2739
}).$mount(el)
2840

0 commit comments

Comments
 (0)