From 0cdfb96213582280a7b4fbe8bee03b88d5d558ed Mon Sep 17 00:00:00 2001 From: weizhenye Date: Sun, 23 Oct 2016 06:01:30 +0800 Subject: [PATCH] 0.0.6 --- dist/vue-highcharts.js | 36 ++++++++++++++++++++++++++---------- dist/vue-highcharts.min.js | 2 +- package.json | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/dist/vue-highcharts.js b/dist/vue-highcharts.js index e2bcb09..b3dd069 100644 --- a/dist/vue-highcharts.js +++ b/dist/vue-highcharts.js @@ -29,29 +29,45 @@ function create(tagName, Highcharts) { } : { options: { type: Object, required: true } }, methods: { + _init: function() { + this._renderChart(); + if (isRenderer) { + this.$watch('width', this._renderChart); + this.$watch('height', this._renderChart); + } else { + this.$watch('options', this._renderChart, { deep: true }); + } + }, _renderChart: function() { if (isRenderer) { + this.renderer && this.$el.removeChild(this.renderer.box); this.renderer = new Ctor(this.$el, this.width, this.height); } else { - var opts = this.options || {}; - opts.chart = opts.chart || {}; - opts.chart.renderTo = this.$el; - this.chart = new Ctor(opts); + var opts = {}; + for (var property in this.options) { + opts[property] = this.options[property]; + } + this.chart = new Ctor(this.$el, opts); } } }, mounted: function() { - this._renderChart(); - }, - updated: function() { - this._renderChart(); + this._init(); }, beforeDestroy: function() { - !isRenderer && this.chart.destroy(); + if (isRenderer) { + this.$el.removeChild(this.renderer.box); + for (var property in this.renderer) { + delete this.renderer[property]; + } + this.renderer = null; + } else { + this.chart.destroy(); + } }, // compat Vue v1.x ready: function() { - this._renderChart(); + this._init(); } }; } diff --git a/dist/vue-highcharts.min.js b/dist/vue-highcharts.min.js index c532605..c6f36fd 100644 --- a/dist/vue-highcharts.min.js +++ b/dist/vue-highcharts.min.js @@ -1 +1 @@ -(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?module.exports=t(require("highcharts")):typeof define==="function"&&define.amd?define(["highcharts"],t):e.VueHighcharts=t(e.Highcharts)})(this,function(e){"use strict";e="default"in e?e["default"]:e;var t={highcharts:"Chart",highstock:"StockChart",highmaps:"Map","highcharts-renderer":"Renderer"};function r(e,r){var h=r[t[e]];if(!h){return null}var i=e==="highcharts-renderer";return{name:e,template:"
",props:i?{width:{type:Number,required:true},height:{type:Number,required:true}}:{options:{type:Object,required:true}},methods:{_renderChart:function(){if(i){this.renderer=new h(this.$el,this.width,this.height)}else{var e=this.options||{};e.chart=e.chart||{};e.chart.renderTo=this.$el;this.chart=new h(e)}}},mounted:function(){this._renderChart()},updated:function(){this._renderChart()},beforeDestroy:function(){!i&&this.chart.destroy()},ready:function(){this._renderChart()}}}function h(h,i){var n=i&&i.Highcharts||e;h.prototype.Highcharts=n;for(var a in t){var o=r(a,n);o&&h.component(a,o)}}return h}); \ No newline at end of file +(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?module.exports=t(require("highcharts")):typeof define==="function"&&define.amd?define(["highcharts"],t):e.VueHighcharts=t(e.Highcharts)})(this,function(e){"use strict";e="default"in e?e["default"]:e;var t={highcharts:"Chart",highstock:"StockChart",highmaps:"Map","highcharts-renderer":"Renderer"};function r(e,r){var i=r[t[e]];if(!i){return null}var h=e==="highcharts-renderer";return{name:e,template:"
",props:h?{width:{type:Number,required:true},height:{type:Number,required:true}}:{options:{type:Object,required:true}},methods:{_init:function(){this._renderChart();if(h){this.$watch("width",this._renderChart);this.$watch("height",this._renderChart)}else{this.$watch("options",this._renderChart,{deep:true})}},_renderChart:function(){if(h){this.renderer&&this.$el.removeChild(this.renderer.box);this.renderer=new i(this.$el,this.width,this.height)}else{var e={};for(var t in this.options){e[t]=this.options[t]}this.chart=new i(this.$el,e)}}},mounted:function(){this._init()},beforeDestroy:function(){if(h){this.$el.removeChild(this.renderer.box);for(var e in this.renderer){delete this.renderer[e]}this.renderer=null}else{this.chart.destroy()}},ready:function(){this._init()}}}function i(i,h){var n=h&&h.Highcharts||e;i.prototype.Highcharts=n;for(var s in t){var o=r(s,n);o&&i.component(s,o)}}return i}); \ No newline at end of file diff --git a/package.json b/package.json index 8080262..1746f1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-highcharts", - "version": "0.0.5", + "version": "0.0.6", "description": "Highcharts component for Vue", "main": "dist/vue-highcharts.js", "jsnext:main": "src/index.js",