Skip to content

Commit

Permalink
better imposition wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 25, 2018
1 parent d60a83b commit 9524675
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/model/ImpositionBoxPlotColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class ImpositionBoxPlotColumn extends CompositeColumn implements

this.setDefaultRenderer('boxplot');
this.setDefaultGroupRenderer('boxplot');
this.setDefaultSummaryRenderer('boxplot');
}

get label() {
Expand Down
49 changes: 46 additions & 3 deletions src/model/ImpositionCompositeColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {toolbar, SortByDefault} from './annotations';
import Column, {widthChanged, labelChanged, metaDataChanged, dirty, dirtyHeader, dirtyValues, rendererTypeChanged, groupRendererChanged, summaryRendererChanged, visibilityChanged, dirtyCaches} from './Column';
import CompositeColumn, {addColumn, filterChanged, moveColumn, removeColumn} from './CompositeColumn';
import {IDataRow, IGroup, IColumnDesc, DEFAULT_COLOR} from './interfaces';
import {isNumberColumn, INumberColumn, isMapAbleColumn, IColorMappingFunction, IMappingFunction} from './INumberColumn';
import {isNumberColumn, INumberColumn, isMapAbleColumn, IColorMappingFunction, IMappingFunction, IMapAbleColumn, INumberFilter} from './INumberColumn';
import NumberColumn from './NumberColumn';
import {DEFAULT_FORMATTER} from './internalNumber';
import {DEFAULT_FORMATTER, noNumberFilter} from './internalNumber';
import {ScaleMappingFunction} from './MappingFunction';
import {DEFAULT_COLOR_FUNCTION} from './ColorMappingFunction';


/**
Expand Down Expand Up @@ -36,7 +38,7 @@ declare function colorMappingChanged(previous: IColorMappingFunction, current: I
*/
@toolbar('filterNumber', 'colorMapped', 'editMapping')
@SortByDefault('descending')
export default class ImpositionCompositeColumn extends CompositeColumn implements INumberColumn {
export default class ImpositionCompositeColumn extends CompositeColumn implements INumberColumn, IMapAbleColumn {
static readonly EVENT_MAPPING_CHANGED = NumberColumn.EVENT_MAPPING_CHANGED;
static readonly EVENT_COLOR_MAPPING_CHANGED = NumberColumn.EVENT_COLOR_MAPPING_CHANGED;

Expand All @@ -45,6 +47,7 @@ export default class ImpositionCompositeColumn extends CompositeColumn implement

this.setDefaultRenderer('number');
this.setDefaultGroupRenderer('boxplot');
this.setDefaultSummaryRenderer('histogram');
}

get label() {
Expand Down Expand Up @@ -156,6 +159,46 @@ export default class ImpositionCompositeColumn extends CompositeColumn implement
return super.getExportValue(row, format);
}

getMapping() {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.getMapping() : new ScaleMappingFunction();
}

getOriginalMapping() {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.getOriginalMapping() : new ScaleMappingFunction();
}

setMapping(mapping: IMappingFunction): void {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.setMapping(mapping) : undefined;
}

getColorMapping() {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.getColorMapping() : DEFAULT_COLOR_FUNCTION;
}

setColorMapping(mapping: IColorMappingFunction) {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.setColorMapping(mapping) : undefined;
}

getFilter() {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.getFilter() : noNumberFilter();
}

setFilter(value?: INumberFilter): void {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.setFilter(value) : undefined;
}

getRange(): [string, string] {
const w = this.wrapper;
return w && isMapAbleColumn(w) ? w.getRange() : ['0', '1'];
}

toCompareValue(row: IDataRow) {
return NumberColumn.prototype.toCompareValue.call(this, row);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/ImpositionCompositesColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class ImpositionCompositesColumn extends CompositeColumn implemen

this.setDefaultRenderer('numbers');
this.setDefaultGroupRenderer('numbers');
this.setDefaultSummaryRenderer('histogram');
}

get label() {
Expand Down

0 comments on commit 9524675

Please sign in to comment.