Skip to content

Commit eefaa42

Browse files
committed
0.0.3
1 parent d573fce commit eefaa42

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

dist/vue-highcharts.js

+27-17
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,56 @@
66

77
HighchartsOnly = 'default' in HighchartsOnly ? HighchartsOnly['default'] : HighchartsOnly;
88

9+
var ctors = {
10+
highcharts: 'Chart',
11+
highstock: 'StockChart',
12+
highmaps: 'Map',
13+
'highcharts-renderer': 'Renderer'
14+
};
15+
916
function create(tagName, Highcharts) {
10-
var ctors = {
11-
highcharts: 'Chart',
12-
highstock: 'StockChart',
13-
highmaps: 'Map'
14-
};
1517
var Ctor = Highcharts[ctors[tagName]];
1618
if (!Ctor) {
1719
return null;
1820
}
21+
var isRenderer = tagName === 'highcharts-renderer';
1922
return {
2023
name: tagName,
2124
template: '<div></div>',
22-
props: {
23-
options: Object
24-
},
25+
props: isRenderer
26+
? {
27+
width: { type: Number, required: true },
28+
height: { type: Number, required: true }
29+
}
30+
: { options: { type: Object, required: true } },
2531
methods: {
26-
render: function(options) {
27-
var opts = options || {};
28-
opts.chart = opts.chart || {};
29-
opts.chart.renderTo = this.$el;
30-
this._chart = new Ctor(opts);
32+
_renderChart: function() {
33+
if (isRenderer) {
34+
this.renderer = new Ctor(this.$el, this.width, this.height);
35+
} else {
36+
var opts = JSON.parse(JSON.stringify(this.options));
37+
opts.chart = opts.chart || {};
38+
opts.chart.renderTo = this.$el;
39+
this.chart = new Ctor(opts);
40+
}
3141
}
3242
},
3343
mounted: function() {
34-
this.render(this.options);
44+
this._renderChart();
3545
},
3646
beforeDestroy: function() {
37-
this._chart.destroy();
47+
!isRenderer && this.chart.destroy();
3848
}
3949
};
4050
}
4151

4252
function install(Vue, options) {
4353
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
4454
Vue.prototype.Highcharts = Highcharts;
45-
['highcharts', 'highstock', 'highmaps'].forEach(function(tagName) {
55+
for (var tagName in ctors) {
4656
var component = create(tagName, Highcharts);
4757
component && Vue.component(tagName, component);
48-
});
58+
}
4959
}
5060

5161
return install;

dist/vue-highcharts.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-highcharts",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Highcharts component for Vue",
55
"main": "dist/vue-highcharts.js",
66
"jsnext:main": "src/index.js",

0 commit comments

Comments
 (0)