/** * Created by mm28969 on 11/8/16. */ import { ScaleContainerTypeEnum, ScaleTypeEnum, stackLayoutCreator } from "../mmviz-layout/index"; import {AreaComponentSvg} from "../mmviz-component-svg/index"; import {DetailsBehavior, DetailsFocusTypeEnum} from "../mmviz-behavior/index"; import {ChartBuilderSvg} from "./builder"; import {OrientationEnum} from "../mmviz-common"; export class StackChartBuilderSvg extends ChartBuilderSvg { component; orientationEnum: OrientationEnum; constructor(selector: string) { super(selector); this.orientationEnum = OrientationEnum.VERTICAL; this.component = new AreaComponentSvg(selector, ".area-stack"); this.component.orientationEnum = this.orientationEnum; this.detailsBehavior = new DetailsBehavior(selector, this.component.selector); this.detailsBehavior.focusTypeEnum = DetailsFocusTypeEnum.DATA; } setOrientation(orientation: OrientationEnum){ this.orientationEnum = orientation; this.component.orientationEnum = orientation; return this; } createView(){ super.createView(); this.chartView.addContentTypeClass("stack-content"); if (OrientationEnum.VERTICAL === this.orientationEnum) { this.chartView.addContentTypeClass("stack-vertical"); } else if (OrientationEnum.HORIZONTAL === this.orientationEnum) { this.chartView.addContentTypeClass("stack-horizontal"); } return this; } updateView(): StackChartBuilderSvg { if (!this.chartView.isViewable){ return this; } let viewModel: any, layouter: Function, layoutExtender = stackLayoutCreator(this.orientationEnum, this.colorScaleKey); super.updateView(); this.layoutScale .xScaleSetup(ScaleTypeEnum.LINEAR) .yScaleSetup(ScaleTypeEnum.LINEAR); // setup color scale super.mapColorScale(); layouter = layoutExtender(this.dataModel, this.layoutScale); this.displayAxies(); viewModel = layouter(); this.component.updateView(this.chartView.stage, viewModel); super.updateComponents(); return this; } resizeView(){ return this.updateView(); } }