Skip to content

Commit

Permalink
#463 bar chart change the dimension value when row, aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
sting009 committed Jan 21, 2019
1 parent 409f55f commit c8636a5
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion discovery-frontend/src/app/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
LogicalType
} from '../domain/datasource/datasource';
import {
BarMarkType,
BarMarkType, ChartColorType,
ChartType,
EventType,
LegendConvertType,
Expand Down Expand Up @@ -3844,6 +3844,63 @@ export class PageComponent extends AbstractPopupComponent implements OnInit, OnD
if ('map' !== this.selectChart && uiCloneQuery.pivot.columns.length + uiCloneQuery.pivot.rows.length + uiCloneQuery.pivot.aggregations.length === 0) {
return;
}

// (bar차트) 행 또는 교차 선반에 값이 올라갈 경우 차원값 색상 및 범례 변경
if ('bar' == this.selectChart ) {

let isChangeDimensionType : boolean = false;

let targetField : string = '';
let fieldDimensionRowCnt = 0;
let fieldDimensionAggregationCnt = 0;
if( !isUndefined(this.uiOption.fielDimensionList) ){

this.uiOption.fielDimensionList.forEach((item) => {
if( item['currentPivot'].toString() == 'ROWS' ){
fieldDimensionRowCnt++;
( targetField == '' ? targetField = item['targetField'] : '' );
}
if( item['currentPivot'].toString() == 'AGGREGATIONS' ){
fieldDimensionAggregationCnt++;
( targetField == '' ? targetField = item['targetField'] : '' );
}
});
}

// 행선반에 dimension 값이 처음 생기는 경우
if ( this.pivot.rows.length == 1 && fieldDimensionRowCnt == 0 ){
this.pivot.rows.forEach((item) => {

// dimension이면
if (item.type === String(ShelveFieldType.DIMENSION)) {
isChangeDimensionType = true;
}
});
}

let fieldAggregationCnt = 0;

// 교차선반에 dimension 값이 처음 생기는 경우
this.pivot.aggregations.forEach((item) => {

// dimension이면
if (item.type === String(ShelveFieldType.DIMENSION)) {
fieldAggregationCnt++;
}
});
if( fieldAggregationCnt == 1 && fieldDimensionAggregationCnt == 0 ){
isChangeDimensionType = true;
}

// dimension color 변경
if( isChangeDimensionType ) {
this.uiOption.color['schema'] = 'SC1';
this.uiOption.color['type'] = ChartColorType.DIMENSION;
this.uiOption.color['targetField'] = targetField;
}

} // end if - barChart

this.loadingShow();
this.isNoData = false;
this.isError = false;
Expand Down

0 comments on commit c8636a5

Please sign in to comment.