/** * Created by michaelbessey on 10/30/16. */ import {DetailsBehavior} from "../mmviz-behavior/index"; import {BoxComponentSvg} from "../mmviz-component-svg/index"; import {OrientationEnum} from "../mmviz-common/index"; import {createBoxModel} from "../mmviz-data"; import {boxLayoutCreator, ScaleTypeEnum} from "../mmviz-layout/index"; import {ChartBuilderSvg} from "./builder"; export class BoxChartBuilderSvg extends ChartBuilderSvg { component: BoxComponentSvg; orientationEnum: OrientationEnum; constructor(selector: string) { super(selector); this.component = new BoxComponentSvg(selector); this.detailsBehavior = new DetailsBehavior(selector, this.component.selector); this.orientationEnum = OrientationEnum.VERTICAL; } setDataArray(dataArray, valueMap: Function){ return this.setDataModel(createBoxModel(dataArray, valueMap)); } createView(){ super.createView(); this.chartView.addContentTypeClass("box-content"); return this; } setOrientation(orientation: OrientationEnum){ this.orientationEnum = orientation; return this; } updateView(){ let viewModel: any, layouter: Function, layoutExtender = boxLayoutCreator(this.orientationEnum), axisViewModel; super.updateView(); if (OrientationEnum.VERTICAL === this.orientationEnum) { this.layoutScale .yScaleSetup(ScaleTypeEnum.LINEAR); } else if (OrientationEnum.HORIZONTAL === this.orientationEnum) { this.layoutScale .xScaleSetup(ScaleTypeEnum.LINEAR) .yScaleSetup(ScaleTypeEnum.LINEAR); } 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(); } }