@@ -76,6 +76,8 @@ define([
7676
7777 _tooltipNode : null ,
7878
79+ _chartEntityObject : null ,
80+
7981 startup : function ( ) {
8082 logger . debug ( this . id + ".startup" ) ;
8183
@@ -142,12 +144,13 @@ define([
142144 this . _mxObj = obj ;
143145
144146 if ( this . _handle !== null ) {
145- mx . data . unsubscribe ( this . _handle ) ;
147+ this . unsubscribe ( this . _handle ) ;
146148 this . _handle = null ;
147149 }
148150
149151 if ( this . _mxObj ) {
150- this . _handle = mx . data . subscribe ( {
152+ logger . debug ( this . id + ".update obj " + this . _mxObj . getGuid ( ) ) ;
153+ this . _handle = this . subscribe ( {
151154 guid : this . _mxObj . getGuid ( ) ,
152155 callback : lang . hitch ( this , this . _loadData )
153156 } ) ;
@@ -184,6 +187,8 @@ define([
184187 return ;
185188 }
186189
190+ this . _chartEntityObject = obj ;
191+
187192 // Retrieve datasets
188193 mx . data . get ( {
189194 guids : guids ,
@@ -217,13 +222,46 @@ define([
217222
218223 uninitialize : function ( ) {
219224 logger . debug ( this . id + ".uninitialize" ) ;
225+
226+ //console.log(this._data);
220227 if ( this . _handle !== null ) {
221- mx . data . unsubscribe ( this . _handle ) ;
228+ this . unsubscribe ( this . _handle ) ;
222229 }
223230
224231 if ( this . _tooltipNode ) {
225232 domConstruct . destroy ( this . _tooltipNode ) ;
226233 }
234+
235+ if ( mx . data . release && ! mx . version || mx . version && parseInt ( mx . version . split ( "." ) [ 0 ] ) < 7 ) { // mx.data.release is deprecated in MX7, so this is for MX5 & MX6
236+ if ( this . _data && this . _data . datasets && this . _data . datasets . length > 0 ) {
237+ logger . debug ( this . id + ".uninitialize release datasets" ) ;
238+ for ( var i = 0 ; i < this . _data . datasets . length ; i ++ ) {
239+ var data = this . _data . datasets [ i ] ;
240+ if ( data . dataset && data . dataset . getGuid ) {
241+ logger . debug ( this . id + ".uninitialize release dataset obj " + data . dataset . getGuid ( ) ) ;
242+ mx . data . release ( data . dataset ) ;
243+ }
244+ if ( data . points && data . points . length > 0 ) {
245+ for ( var j = 0 ; j < data . points . length ; j ++ ) {
246+ var point = data . points [ j ] ;
247+ if ( point && point . getGuid ) {
248+ logger . debug ( this . id + ".uninitialize release datapoint " + point . getGuid ( ) ) ;
249+ mx . data . release ( point ) ;
250+ }
251+ }
252+ }
253+ }
254+ }
255+
256+ if ( this . _chartEntityObject !== null ) {
257+ logger . debug ( this . id + ".uninitialize release obj " + this . _chartEntityObject . getGuid ( ) ) ;
258+ mx . data . release ( this . _chartEntityObject ) ;
259+ }
260+
261+ if ( this . _data . object && this . _data . object . getGuid ) {
262+ mx . data . release ( this . _data . object ) ;
263+ }
264+ }
227265 } ,
228266
229267 customTooltip : function ( tooltip ) {
0 commit comments