Skip to content

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhenye committed Jan 30, 2019
1 parent dc2c2fa commit d24cb0c
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 102 deletions.
180 changes: 80 additions & 100 deletions dist/vue-highcharts.js
Original file line number Diff line number Diff line change
@@ -1,118 +1,98 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('highcharts')) :
typeof define === 'function' && define.amd ? define(['highcharts'], factory) :
(global.VueHighcharts = factory(global.Highcharts));
}(this, (function (HighchartsOnly) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('highcharts')) :
typeof define === 'function' && define.amd ? define(['exports', 'highcharts'], factory) :
(global = global || self, factory(global.VueHighcharts = {}, global.Highcharts));
}(this, function (exports, HighchartsOnly) { 'use strict';

HighchartsOnly = HighchartsOnly && HighchartsOnly.hasOwnProperty('default') ? HighchartsOnly['default'] : HighchartsOnly;
HighchartsOnly = HighchartsOnly && HighchartsOnly.hasOwnProperty('default') ? HighchartsOnly['default'] : HighchartsOnly;

var ctors = {
Highcharts: 'Chart',
Highstock: 'StockChart',
Highmaps: 'Map',
HighchartsRenderer: 'Renderer'
};
var ctors = {
Highcharts: 'chart',
Highstock: 'stockChart',
Highmaps: 'mapChart',
HighchartsGantt: 'ganttChart',
};

function clone(obj) {
var copy;
if (obj === null || typeof obj !== 'object') {
return obj;
}
if (obj instanceof Array) {
copy = [];
for (var i = obj.length - 1; i >= 0; i--) {
copy[i] = clone(obj[i]);
// eslint-disable-next-line consistent-return
function clone(obj) {
var copy;
if (obj === null || typeof obj !== 'object') {
return obj;
}
return copy;
}
/* istanbul ignore else */
if (obj instanceof Object) {
copy = {};
for (var key in obj) {
copy[key] = clone(obj[key]);
if (obj instanceof Array) {
copy = [];
for (var i = obj.length - 1; i >= 0; i--) {
copy[i] = clone(obj[i]);
}
return copy;
}
/* istanbul ignore else */
if (obj instanceof Object) {
copy = {};
for (var key in obj) {
copy[key] = clone(obj[key]);
}
return copy;
}
return copy;
}
}

function render(createElement) {
return createElement('div');
}

function create(tagName, Highcharts, Vue) {
var Ctor = Highcharts[ctors[tagName]];
if (!Ctor) {
return Highcharts.win
? null
// When running in server, Highcharts will not be instanced,
// so there're no constructors in Highcharts,
// to avoid unmated content during SSR, it returns minimum component.
: { render: render };
function render(createElement) {
return createElement('div');
}
var isRenderer = tagName === 'HighchartsRenderer';
var component = {
name: tagName,
props: isRenderer
? {
width: { type: Number, required: true },
height: { type: Number, required: true }
}
: { options: { type: Object, required: true } },
methods: {
_initChart: function() {
this._renderChart();
if (isRenderer) {
this.$watch('width', this._renderChart);
this.$watch('height', this._renderChart);
} else {
this.$watch('options', this._renderChart, { deep: true });
}

function create(name, Highcharts) {
var ctor = Highcharts[ctors[name]];
if (!ctor) {
return Highcharts.win
? null
// When running in server, Highcharts will not be instanced,
// so there're no constructors in Highcharts,
// to avoid unmated content during SSR, it returns minimum component.
: { render: render };
}
return {
name: name,
props: {
options: { type: Object, required: true }
},
_renderChart: function() {
if (isRenderer) {
this.renderer && this.$el.removeChild(this.renderer.box);
this.renderer = new Ctor(this.$el, this.width, this.height);
} else {
this.chart = new Ctor(this.$el, clone(this.options));
}
}
},
beforeDestroy: function() {
if (isRenderer) {
this.$el.removeChild(this.renderer.box);
for (var property in this.renderer) {
delete this.renderer[property];
watch: {
options: {
handler: function () {
this.$_h_render();
},
deep: true
}
this.renderer = null;
} else {
},
mounted: function () {
this.$_h_render();
},
beforeDestroy: function () {
this.chart.destroy();
}
}
};
var isVue1 = /^1\./.test(Vue.version);
if (isVue1) {
component.template = '<div></div>';
component.ready = function() {
this._initChart();
};
} else {
component.render = render;
component.mounted = function() {
this._initChart();
},
methods: {
$_h_render: function () {
this.chart = ctor(this.$el, clone(this.options));
}
},
render: render
};
}
return component;
}

function install(Vue, options) {
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
Vue.prototype.Highcharts = Highcharts;
for (var tagName in ctors) {
var component = create(tagName, Highcharts, Vue);
component && Vue.component(tagName, component);
function install(Vue, options) {
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
for (var name in ctors) {
var component = create(name, Highcharts);
component && Vue.component(name, component);
}
}

if (typeof window !== 'undefined' && window.Vue && window.Highcharts) {
install(window.Vue, window.Highcharts);
}
}

return install;
exports.default = install;
exports.genComponent = create;

Object.defineProperty(exports, '__esModule', { value: true });

})));
}));
2 changes: 1 addition & 1 deletion dist/vue-highcharts.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-highcharts",
"version": "0.0.11",
"version": "0.1.0",
"description": "Highcharts component for Vue",
"main": "dist/vue-highcharts.js",
"module": "src/index.js",
Expand Down

0 comments on commit d24cb0c

Please sign in to comment.