@@ -491,85 +491,47 @@ function ResultCtrl($scope, $rootScope, $route, $window, $routeParams, $location
491491 const builtInViz = builtInVisualizations [ graphMode ] ;
492492 if ( ! builtInViz ) { return ; }
493493
494- // deactive previsouly active visualization
495- for ( let t in builtInVisualizations ) {
496- const v = builtInVisualizations [ t ] . instance ;
497-
498- if ( t !== graphMode && v && v . isActive ( ) ) {
499- v . deactivate ( ) ;
500- break ;
501- }
502- }
503-
504- if ( ! builtInViz . instance ) { // not instantiated yet
505- // render when targetEl is available
506- const afterLoaded = ( loadedElem ) => {
507- try {
508- const transformationSettingTargetEl = angular . element ( '#trsetting' + $scope . id + '_' + graphMode ) ;
509- const visualizationSettingTargetEl = angular . element ( '#trsetting' + $scope . id + '_' + graphMode ) ;
510- // set height
511- loadedElem . height ( height ) ;
512-
513- // instantiate visualization
514- const config = getVizConfig ( graphMode ) ;
515- const Visualization = builtInViz . class ;
516- builtInViz . instance = new Visualization ( loadedElem , config ) ;
517-
518- // inject emitter, $templateRequest
519- const emitter = function ( graphSetting ) {
520- commitVizConfigChange ( graphSetting , graphMode ) ;
521- } ;
522- builtInViz . instance . _emitter = emitter ;
523- builtInViz . instance . _compile = $compile ;
524- builtInViz . instance . _createNewScope = createNewScope ;
525- const transformation = builtInViz . instance . getTransformation ( ) ;
526- transformation . _emitter = emitter ;
527- transformation . _templateRequest = $templateRequest ;
528- transformation . _compile = $compile ;
529- transformation . _createNewScope = createNewScope ;
530-
531- // render
532- const transformed = transformation . transform ( tableData ) ;
533- transformation . renderSetting ( transformationSettingTargetEl ) ;
534- builtInViz . instance . render ( transformed ) ;
535- builtInViz . instance . renderSetting ( visualizationSettingTargetEl ) ;
536- builtInViz . instance . activate ( ) ;
537- angular . element ( window ) . resize ( ( ) => {
538- builtInViz . instance . resize ( ) ;
539- } ) ;
540- } catch ( err ) {
541- console . error ( 'Graph drawing error %o' , err ) ;
542- }
543- } ;
544-
545- retryUntilElemIsLoaded ( tableElemId , afterLoaded ) ;
546- } else if ( refresh ) {
547- // when graph options or data are changed
548- console . log ( 'Refresh data %o' , tableData ) ;
549-
550- const afterLoaded = ( loadedElem ) => {
494+ // render when targetEl is available
495+ const afterLoaded = ( loadedElem ) => {
496+ try {
551497 const transformationSettingTargetEl = angular . element ( '#trsetting' + $scope . id + '_' + graphMode ) ;
552498 const visualizationSettingTargetEl = angular . element ( '#trsetting' + $scope . id + '_' + graphMode ) ;
553- const config = getVizConfig ( graphMode ) ;
499+ // set height
554500 loadedElem . height ( height ) ;
501+
502+ // instantiate visualization
503+ const config = getVizConfig ( graphMode ) ;
504+ const Visualization = builtInViz . class ;
505+ builtInViz . instance = new Visualization ( loadedElem , config ) ;
506+
507+ // inject emitter, $templateRequest
508+ const emitter = function ( graphSetting ) {
509+ commitVizConfigChange ( graphSetting , graphMode ) ;
510+ } ;
511+ builtInViz . instance . _emitter = emitter ;
512+ builtInViz . instance . _compile = $compile ;
513+ builtInViz . instance . _createNewScope = createNewScope ;
555514 const transformation = builtInViz . instance . getTransformation ( ) ;
556- transformation . setConfig ( config ) ;
515+ transformation . _emitter = emitter ;
516+ transformation . _templateRequest = $templateRequest ;
517+ transformation . _compile = $compile ;
518+ transformation . _createNewScope = createNewScope ;
519+
520+ // render
557521 const transformed = transformation . transform ( tableData ) ;
558522 transformation . renderSetting ( transformationSettingTargetEl ) ;
559- builtInViz . instance . setConfig ( config ) ;
560523 builtInViz . instance . render ( transformed ) ;
561524 builtInViz . instance . renderSetting ( visualizationSettingTargetEl ) ;
562- } ;
563-
564- retryUntilElemIsLoaded ( tableElemId , afterLoaded ) ;
565- } else {
566- const afterLoaded = ( loadedElem ) => {
567- loadedElem . height ( height ) ;
568525 builtInViz . instance . activate ( ) ;
569- } ;
526+ angular . element ( window ) . resize ( ( ) => {
527+ builtInViz . instance . resize ( ) ;
528+ } ) ;
529+ } catch ( err ) {
530+ console . error ( 'Graph drawing error %o' , err ) ;
531+ }
532+ } ;
570533
571- retryUntilElemIsLoaded ( tableElemId , afterLoaded ) ;
572- }
534+ retryUntilElemIsLoaded ( tableElemId , afterLoaded ) ;
573535 } ;
574536
575537 $scope . switchViz = function ( newMode ) {
0 commit comments