/** * Created by mm28969 on 1/21/17. */ import {Theme} from "../mmviz-common/index"; import {MapLayout, ProjectionTypeEnum, ScaleContainer, ScaleContainerTypeEnum} from "../mmviz-layout/index"; import {MapComponentSvg} from "../mmviz-component-svg/index"; import {DetailsBehavior} from "../mmviz-behavior/index"; import {ChartBuilderSvg} from "./builder"; export class MapChartBuilderSvg extends ChartBuilderSvg { scaleFactor; layout: MapLayout; component: MapComponentSvg; scaleContainerEnum: ScaleContainerTypeEnum; projectionTypeEnum: ProjectionTypeEnum; customColorScaleContainer: ScaleContainer; constructor(selector: string) { super(selector); this.scaleFactor = 0.9; this.layout = new MapLayout(); this.component = new MapComponentSvg(selector); this.scaleContainerEnum = ScaleContainerTypeEnum.COLOR_SEQUENTIAL_LIGHT; this.detailsBehavior = new DetailsBehavior(selector, this.component.selector); this.projectionTypeEnum = ProjectionTypeEnum.GEO_ALBERS_USA; } updateView(): MapChartBuilderSvg { let theme = Theme.getInstance(), viewModel: any; super.updateView(); this.dataModel.projection = this.layoutScale.getProjection(this.projectionTypeEnum, this.chartView); if (this.customColorScaleContainer){ this.layoutScale.addScaleContainer(this.customColorScaleContainer.key, this.customColorScaleContainer); } else{ this.layoutScale.createScaleContainer(this.layout.colorScaleKey, this.scaleContainerEnum) .setScaleDefaultValue(this.layout.colorScaleKey, theme.colors.colorSequentialMid); } viewModel = this.layout.layoutView(this.dataModel, this.layoutScale); //setScaleDomain this.component.updateView(this.chartView.stage, viewModel); this.updateComponents(); return this; } resizeView(){ if(this.chartView.isSmallViewBox) { this.chartView.syncViewBoxDimension(); this.updateView(); } return this; } }