Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhenye committed Oct 11, 2016
1 parent b15f4e0 commit a4c9413
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
63 changes: 39 additions & 24 deletions dist/vue-highcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,50 @@
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 (Highcharts) { 'use strict';
}(this, (function (HighchartsOnly) { 'use strict';

Highcharts = 'default' in Highcharts ? Highcharts['default'] : Highcharts;
HighchartsOnly = 'default' in HighchartsOnly ? HighchartsOnly['default'] : HighchartsOnly;

var highcharts = {
name: 'highcharts',
template: '<div></div>',
props: {
options: Object
},
methods: {
render: function(options) {
var opts = options || {};
opts.chart = opts.chart || {};
opts.chart.renderTo = this.$el;
this._chart = new Highcharts.Chart(opts);
}
},
mounted: function() {
this.render(this.options);
},
beforeDestroy: function() {
this._chart.destroy();
function create(tagName, Highcharts) {
var ctors = {
highcharts: 'Chart',
highstock: 'StockChart',
highmaps: 'Map'
};
var Ctor = Highcharts[ctors[tagName]];
if (!Ctor) {
return null;
}
};
return {
name: tagName,
template: '<div></div>',
props: {
options: Object
},
methods: {
render: function(options) {
var opts = options || {};
opts.chart = opts.chart || {};
opts.chart.renderTo = this.$el;
this._chart = new Ctor(opts);
}
},
mounted: function() {
this.render(this.options);
},
beforeDestroy: function() {
this._chart.destroy();
}
};
}

function install(Vue) {
function install(Vue, options) {
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
Vue.prototype.Highcharts = Highcharts;
Vue.component('highcharts', highcharts);
['highcharts', 'highstock', 'highmaps'].forEach(function(tagName) {
var component = create(tagName, Highcharts);
component && Vue.component(tagName, component);
});
}

return install;
Expand Down
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.1",
"version": "0.0.2",
"description": "Highcharts component for Vue",
"main": "dist/vue-highcharts.js",
"jsnext:main": "src/index.js",
Expand Down

0 comments on commit a4c9413

Please sign in to comment.