File tree Expand file tree Collapse file tree 4 files changed +50
-15
lines changed Expand file tree Collapse file tree 4 files changed +50
-15
lines changed Original file line number Diff line number Diff line change 114
114
return this ;
115
115
} ;
116
116
117
+ MultiChart . prototype . chartTypeProperties = function ( _ ) {
118
+ if ( ! arguments . length ) return this . _chartTypeProperties ;
119
+ this . _chartTypeProperties = _ ;
120
+ return this ;
121
+ } ;
122
+
117
123
MultiChart . prototype . requireContent = function ( chartType , callback ) {
118
124
var path = "src/" + this . _allCharts [ chartType ] . widgetClass . split ( "_" ) . join ( "/" ) ;
119
125
require ( [ path ] , function ( WidgetClass ) {
122
128
} ;
123
129
124
130
MultiChart . prototype . switchChart = function ( callback ) {
131
+ if ( this . _switchingTo === this . chartType ( ) ) {
132
+ if ( callback ) {
133
+ callback ( this ) ;
134
+ }
135
+ return ;
136
+ } else if ( this . _switchingTo ) {
137
+ console . log ( "Attempting switch to: " + this . chartType ( ) + ", before previous switch is complete (" + this . _switchingTo + ")" ) ;
138
+ }
139
+ this . _switchingTo = this . chartType ( ) ;
125
140
var oldContent = this . chart ( ) ;
126
141
var context = this ;
127
142
this . requireContent ( this . chartType ( ) , function ( newContent ) {
132
147
. data ( context . _data )
133
148
. size ( size )
134
149
;
150
+ if ( context . _chartTypeProperties ) {
151
+ for ( var key in context . _chartTypeProperties ) {
152
+ if ( newContent [ key ] ) {
153
+ try {
154
+ newContent [ key ] ( context . _chartTypeProperties [ key ] ) ;
155
+ } catch ( e ) {
156
+ console . log ( "Exception Setting Property: " + key ) ;
157
+ }
158
+ } else {
159
+ console . log ( "Unknown Property: " + key ) ;
160
+ }
161
+ }
162
+ delete context . _chartTypeProperties ;
163
+ }
135
164
context . chart ( newContent ) ;
136
165
if ( oldContent ) {
137
166
oldContent
141
170
;
142
171
}
143
172
}
173
+ delete context . _switchingTo ;
144
174
if ( callback ) {
145
175
callback ( this ) ;
146
176
}
You can’t perform that action at this time.
0 commit comments