client/src/components/project/panels/layout/ctrlLayoutPanel.js
// onSwitch for original / geo / scatter / grid
onSwitch for original / geo / scatter / grid
onSwitch for original / geo / scatter / grid
function onSwitch(layout_model) {
        console.log('[LayoutPanelCtrl.onSwitch] called with layout_model: %O', layout_model);
        var layoutName = _.find(layout_model.options.primary, 'key', 'layoutName');
        var xAttrOpt = _.find(layout_model.options.primary, 'key', 'xAttr'),
            yAttrOpt = _.find(layout_model.options.primary, 'key', 'yAttr');
        var xAttr = layoutName ? layoutName.input_value + '_X' : (xAttrOpt ? xAttrOpt.input_value : 'OriginalX');
        var yAttr = layoutName ? layoutName.input_value + '_Y' : (yAttrOpt ? yAttrOpt.input_value : 'OriginalY');
        var athenaNamed = _.find(layout_model.options.primary, 'key', 'athena_attr_prefix');
        xAttr = athenaNamed ? athenaNamed.input_value + '_X' : xAttr;
        yAttr = athenaNamed ? athenaNamed.input_value + '_Y' : yAttr;
        var plotOps = {xAttr : xAttr, yAttr : yAttr};
        if(layout_model.plotType === 'scatterplot') {
            var scaleOpts = {
                xScaleType : _.find(layout_model.options.primary, 'key', 'xScaleType').input_value,
                xScaleExponent : parseFloat(_.find(layout_model.options.primary, 'key', 'xScaleExponent').input_value),
                xScaleBase : parseFloat(_.find(layout_model.options.primary, 'key', 'xScaleBase').input_value),
                yScaleType : _.find(layout_model.options.primary, 'key', 'yScaleType').input_value,
                yScaleExponent : parseFloat(_.find(layout_model.options.primary, 'key', 'yScaleExponent').input_value),
                yScaleBase : parseFloat(_.find(layout_model.options.primary, 'key', 'yScaleBase').input_value)
            };
            _.assign(plotOps, scaleOpts);
        } else if(layout_model.plotType === 'grid') {
            plotOps.gridAttr = _.find(layout_model.options.primary, 'key', 'renderAttr').input_value;
            plotOps.gridSortAttr = _.find(layout_model.options.primary, 'key', 'sortAttr').input_value;
            plotOps.listCompareIds = _.find(layout_model.options.primary, 'key', 'compareIds').input_value;
        } else if(layout_model.plotType === 'list') {
            plotOps.listAttrs = _.find(layout_model.options.primary, 'key', 'renderAttrs').input_value;
            plotOps.listSortAttrAr = _.find(layout_model.options.primary, 'key', 'listSortAttrAr').input_value;
            plotOps.listSortReverseAr = _.find(layout_model.options.primary, 'key', 'sortReverseAr').input_value;
            plotOps.listCompareIds = _.find(layout_model.options.primary, 'key', 'compareIds').input_value;
            plotOps.listColSizes = _.find(layout_model.options.primary, 'key', 'listColSizes').input_value;
            console.log('switching layout: ', plotOps.listSortAttrAr);
        }
        if($scope.layoutHelpers) {
            return $scope.layoutHelpers.switchGraph(layout_model.plotType, plotOps);
        }
    }
function onSwitch ( layout_model ) { console . log ( '[LayoutPanelCtrl.onSwitch] called with layout_model: %O' , layout_model ) ; var layoutName = _ . find ( layout_model . options . primary , 'key' , 'layoutName' ) ; var xAttrOpt = _ . find ( layout_model . options . primary , 'key' , 'xAttr' ) , yAttrOpt = _ . find ( layout_model . options . primary , 'key' , 'yAttr' ) ; var xAttr = layoutName ? layoutName . input_value + '_X' : ( xAttrOpt ? xAttrOpt . input_value : 'OriginalX' ) ; var yAttr = layoutName ? layoutName . input_value + '_Y' : ( yAttrOpt ? yAttrOpt . input_value : 'OriginalY' ) ; var athenaNamed = _ . find ( layout_model . options . primary , 'key' , 'athena_attr_prefix' ) ; xAttr = athenaNamed ? athenaNamed . input_value + '_X' : xAttr ; yAttr = athenaNamed ? athenaNamed . input_value + '_Y' : yAttr ; var plotOps = { xAttr : xAttr , yAttr : yAttr } ; if ( layout_model . plotType === 'scatterplot' ) { var scaleOpts = { xScaleType : _ . find ( layout_model . options . primary , 'key' , 'xScaleType' ) . input_value , xScaleExponent : parseFloat ( _ . find ( layout_model . options . primary , 'key' , 'xScaleExponent' ) . input_value ) , xScaleBase : parseFloat ( _ . find ( layout_model . options . primary , 'key' , 'xScaleBase' ) . input_value ) , yScaleType : _ . find ( layout_model . options . primary , 'key' , 'yScaleType' ) . input_value , yScaleExponent : parseFloat ( _ . find ( layout_model . options . primary , 'key' , 'yScaleExponent' ) . input_value ) , yScaleBase : parseFloat ( _ . find ( layout_model . options . primary , 'key' , 'yScaleBase' ) . input_value ) } ; _ . assign ( plotOps , scaleOpts ) ; } else if ( layout_model . plotType === 'grid' ) { plotOps . gridAttr = _ . find ( layout_model . options . primary , 'key' , 'renderAttr' ) . input_value ; plotOps . gridSortAttr = _ . find ( layout_model . options . primary , 'key' , 'sortAttr' ) . input_value ; plotOps . listCompareIds = _ . find ( layout_model . options . primary , 'key' , 'compareIds' ) . input_value ; } else if ( layout_model . plotType === 'list' ) { plotOps . listAttrs = _ . find ( layout_model . options . primary , 'key' , 'renderAttrs' ) . input_value ; plotOps . listSortAttrAr = _ . find ( layout_model . options . primary , 'key' , 'listSortAttrAr' ) . input_value ; plotOps . listSortReverseAr = _ . find ( layout_model . options . primary , 'key' , 'sortReverseAr' ) . input_value ; plotOps . listCompareIds = _ . find ( layout_model . options . primary , 'key' , 'compareIds' ) . input_value ; plotOps . listColSizes = _ . find ( layout_model . options . primary , 'key' , 'listColSizes' ) . input_value ; console . log ( 'switching layout: ' , plotOps . listSortAttrAr ) ; } if ( $scope . layoutHelpers ) { return $scope . layoutHelpers . switchGraph ( layout_model . plotType , plotOps ) ; } }
onSwitch for original / geo / scatter / grid
onSwitch for original / geo / scatter / grid
// athena generated layouts // plotOps.listSortAttr = _.find(layout_model.options.primary, 'key', 'sortAttr').input_value; // plotOps.listSortReverse = _.find(layout_model.options.primary, 'key', 'sortReverse').input_value;