File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 11import clone from './clone.js' ;
22import ctors from './constrators.js' ;
33
4- function create ( tagName , Highcharts ) {
4+ function create ( tagName , Highcharts , Vue ) {
55 var Ctor = Highcharts [ ctors [ tagName ] ] ;
66 if ( ! Ctor ) {
77 return null ;
88 }
99 var isRenderer = tagName === 'highcharts-renderer' ;
10- return {
10+ var component = {
1111 name : tagName ,
12- render : function ( createElement ) {
13- return createElement ( 'div' ) ;
14- } ,
1512 props : isRenderer
1613 ? {
1714 width : { type : Number , required : true } ,
@@ -37,9 +34,6 @@ function create(tagName, Highcharts) {
3734 }
3835 }
3936 } ,
40- mounted : function ( ) {
41- this . _initChart ( ) ;
42- } ,
4337 beforeDestroy : function ( ) {
4438 if ( isRenderer ) {
4539 this . $el . removeChild ( this . renderer . box ) ;
@@ -50,12 +44,24 @@ function create(tagName, Highcharts) {
5044 } else {
5145 this . chart . destroy ( ) ;
5246 }
53- } ,
54- // compat Vue v1.x
55- ready : function ( ) {
56- this . _initChart ( ) ;
5747 }
5848 } ;
49+ var isVue1 = / ^ 1 \. / . test ( Vue . version ) ;
50+ if ( isVue1 ) {
51+ component . template = '<div></div>' ;
52+ component . ready = function ( ) {
53+ this . _initChart ( ) ;
54+ } ;
55+ } else {
56+ component . render = function ( createElement ) {
57+ return createElement ( 'div' ) ;
58+ } ;
59+ component . mounted = function ( ) {
60+ this . _initChart ( ) ;
61+ } ;
62+ }
63+ return component ;
5964}
6065
6166export default create ;
67+
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ function install(Vue, options) {
66 var Highcharts = ( options && options . Highcharts ) || HighchartsOnly ;
77 Vue . prototype . Highcharts = Highcharts ;
88 for ( var tagName in ctors ) {
9- var component = create ( tagName , Highcharts ) ;
9+ var component = create ( tagName , Highcharts , Vue ) ;
1010 component && Vue . component ( tagName , component ) ;
1111 }
1212}
You can’t perform that action at this time.
0 commit comments