Content-Length: 671178 | pFad | http://github.com/weizhenye/vue-highcharts/commit/d24cb0ca4ef2370df241687b05693623862486dd

12 0.1.0 · weizhenye/vue-highcharts@d24cb0c · GitHub
Skip to content

Commit d24cb0c

Browse files
committed
0.1.0
1 parent dc2c2fa commit d24cb0c

File tree

3 files changed

+82
-102
lines changed

3 files changed

+82
-102
lines changed

dist/vue-highcharts.js

Lines changed: 80 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,98 @@
11
(function (global, factory) {
2-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('highcharts')) :
3-
typeof define === 'function' && define.amd ? define(['highcharts'], factory) :
4-
(global.VueHighcharts = factory(global.Highcharts));
5-
}(this, (function (HighchartsOnly) { 'use strict';
2+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('highcharts')) :
3+
typeof define === 'function' && define.amd ? define(['exports', 'highcharts'], factory) :
4+
(global = global || self, factory(global.VueHighcharts = {}, global.Highcharts));
5+
}(this, function (exports, HighchartsOnly) { 'use strict';
66

7-
HighchartsOnly = HighchartsOnly && HighchartsOnly.hasOwnProperty('default') ? HighchartsOnly['default'] : HighchartsOnly;
7+
HighchartsOnly = HighchartsOnly && HighchartsOnly.hasOwnProperty('default') ? HighchartsOnly['default'] : HighchartsOnly;
88

9-
var ctors = {
10-
Highcharts: 'Chart',
11-
Highstock: 'StockChart',
12-
Highmaps: 'Map',
13-
HighchartsRenderer: 'Renderer'
14-
};
9+
var ctors = {
10+
Highcharts: 'chart',
11+
Highstock: 'stockChart',
12+
Highmaps: 'mapChart',
13+
HighchartsGantt: 'ganttChart',
14+
};
1515

16-
function clone(obj) {
17-
var copy;
18-
if (obj === null || typeof obj !== 'object') {
19-
return obj;
20-
}
21-
if (obj instanceof Array) {
22-
copy = [];
23-
for (var i = obj.length - 1; i >= 0; i--) {
24-
copy[i] = clone(obj[i]);
16+
// eslint-disable-next-line consistent-return
17+
function clone(obj) {
18+
var copy;
19+
if (obj === null || typeof obj !== 'object') {
20+
return obj;
2521
}
26-
return copy;
27-
}
28-
/* istanbul ignore else */
29-
if (obj instanceof Object) {
30-
copy = {};
31-
for (var key in obj) {
32-
copy[key] = clone(obj[key]);
22+
if (obj instanceof Array) {
23+
copy = [];
24+
for (var i = obj.length - 1; i >= 0; i--) {
25+
copy[i] = clone(obj[i]);
26+
}
27+
return copy;
28+
}
29+
/* istanbul ignore else */
30+
if (obj instanceof Object) {
31+
copy = {};
32+
for (var key in obj) {
33+
copy[key] = clone(obj[key]);
34+
}
35+
return copy;
3336
}
34-
return copy;
3537
}
36-
}
37-
38-
function render(createElement) {
39-
return createElement('div');
40-
}
4138

42-
function create(tagName, Highcharts, Vue) {
43-
var Ctor = Highcharts[ctors[tagName]];
44-
if (!Ctor) {
45-
return Highcharts.win
46-
? null
47-
// When running in server, Highcharts will not be instanced,
48-
// so there're no constructors in Highcharts,
49-
// to avoid unmated content during SSR, it returns minimum component.
50-
: { render: render };
39+
function render(createElement) {
40+
return createElement('div');
5141
}
52-
var isRenderer = tagName === 'HighchartsRenderer';
53-
var component = {
54-
name: tagName,
55-
props: isRenderer
56-
? {
57-
width: { type: Number, required: true },
58-
height: { type: Number, required: true }
59-
}
60-
: { options: { type: Object, required: true } },
61-
methods: {
62-
_initChart: function() {
63-
this._renderChart();
64-
if (isRenderer) {
65-
this.$watch('width', this._renderChart);
66-
this.$watch('height', this._renderChart);
67-
} else {
68-
this.$watch('options', this._renderChart, { deep: true });
69-
}
42+
43+
function create(name, Highcharts) {
44+
var ctor = Highcharts[ctors[name]];
45+
if (!ctor) {
46+
return Highcharts.win
47+
? null
48+
// When running in server, Highcharts will not be instanced,
49+
// so there're no constructors in Highcharts,
50+
// to avoid unmated content during SSR, it returns minimum component.
51+
: { render: render };
52+
}
53+
return {
54+
name: name,
55+
props: {
56+
options: { type: Object, required: true }
7057
},
71-
_renderChart: function() {
72-
if (isRenderer) {
73-
this.renderer && this.$el.removeChild(this.renderer.box);
74-
this.renderer = new Ctor(this.$el, this.width, this.height);
75-
} else {
76-
this.chart = new Ctor(this.$el, clone(this.options));
77-
}
78-
}
79-
},
80-
beforeDestroy: function() {
81-
if (isRenderer) {
82-
this.$el.removeChild(this.renderer.box);
83-
for (var property in this.renderer) {
84-
delete this.renderer[property];
58+
watch: {
59+
options: {
60+
handler: function () {
61+
this.$_h_render();
62+
},
63+
deep: true
8564
}
86-
this.renderer = null;
87-
} else {
65+
},
66+
mounted: function () {
67+
this.$_h_render();
68+
},
69+
beforeDestroy: function () {
8870
this.chart.destroy();
89-
}
90-
}
91-
};
92-
var isVue1 = /^1\./.test(Vue.version);
93-
if (isVue1) {
94-
component.template = '<div></div>';
95-
component.ready = function() {
96-
this._initChart();
97-
};
98-
} else {
99-
component.render = render;
100-
component.mounted = function() {
101-
this._initChart();
71+
},
72+
methods: {
73+
$_h_render: function () {
74+
this.chart = ctor(this.$el, clone(this.options));
75+
}
76+
},
77+
render: render
10278
};
10379
}
104-
return component;
105-
}
10680

107-
function install(Vue, options) {
108-
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
109-
Vue.prototype.Highcharts = Highcharts;
110-
for (var tagName in ctors) {
111-
var component = create(tagName, Highcharts, Vue);
112-
component && Vue.component(tagName, component);
81+
function install(Vue, options) {
82+
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
83+
for (var name in ctors) {
84+
var component = create(name, Highcharts);
85+
component && Vue.component(name, component);
86+
}
87+
}
88+
89+
if (typeof window !== 'undefined' && window.Vue && window.Highcharts) {
90+
install(window.Vue, window.Highcharts);
11391
}
114-
}
11592

116-
return install;
93+
exports.default = install;
94+
exports.genComponent = create;
95+
96+
Object.defineProperty(exports, '__esModule', { value: true });
11797

118-
})));
98+
}));

dist/vue-highcharts.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-highcharts",
3-
"version": "0.0.11",
3+
"version": "0.1.0",
44
"description": "Highcharts component for Vue",
55
"main": "dist/vue-highcharts.js",
66
"module": "src/index.js",

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/weizhenye/vue-highcharts/commit/d24cb0ca4ef2370df241687b05693623862486dd

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy