/** * Created by mm28969 on 1/31/17. */ import {Theme} from "../mmviz-common/index"; import {MapLayout, MapPointLayout, ScaleContainerTypeEnum, ProjectionTypeEnum} from "../mmviz-layout/index"; import {MapComponentSvg, MapPointComponentSvg} from "../mmviz-component-svg/index"; import {DetailsBehavior} from "../mmviz-behavior/index"; import {ChartBuilderSvg} from "./builder"; export class MapPointChartBuilder extends ChartBuilderSvg { scaleFactor; mapComponent; mapPointComponent; mapScaleContainerEnum: ScaleContainerTypeEnum; mapPointScaleContainerEnum: ScaleContainerTypeEnum; projectionTypeEnum: ProjectionTypeEnum; constructor(selector: string) { super(selector); this.scaleFactor = 0.9; this.mapComponent = new MapComponentSvg(selector); this.mapPointComponent = new MapPointComponentSvg(selector); this.mapScaleContainerEnum = ScaleContainerTypeEnum.COLOR_SEQUENTIAL_LIGHT; this.mapPointScaleContainerEnum = ScaleContainerTypeEnum.COLOR_CATEGORICAL_DARK; this.detailsBehavior = new DetailsBehavior(selector, this.mapPointComponent.selector); this.projectionTypeEnum = ProjectionTypeEnum.GEO_ALBERS_USA; } addColorLegend(title: string){ this.addLegend("colorPoint", title, "color"); return this; } updateView() { let theme = Theme.getInstance(), mapLayout: MapLayout = new MapLayout(), mapPointLayout: MapPointLayout, mapViewModel: any, mapPointViewModel: any, projection; super.updateView(); projection = this.layoutScale.getProjection(this.projectionTypeEnum, this.chartView); this.dataModel.pointModel.projection = projection; this.dataModel.geoModel.projection = projection; mapPointLayout = new MapPointLayout(this.dataModel.pointModel); this.layoutScale .createScaleContainer(mapPointLayout.areaScaleKey, ScaleContainerTypeEnum.AREA); mapPointLayout.extend(this.layoutScale); this.layoutScale.createScaleContainer(mapLayout.colorScaleKey, this.mapScaleContainerEnum) .setScaleDefaultValue(mapLayout.colorScaleKey, theme.colors.colorSequentialMid); mapViewModel = mapLayout.layoutView(this.dataModel.geoModel, this.layoutScale); this.mapComponent.updateView(this.chartView.stage, mapViewModel); this.layoutScale.createScaleContainer(mapPointLayout.colorScaleKey, this.mapPointScaleContainerEnum); mapPointViewModel = mapPointLayout.layoutView(this.layoutScale); this.mapPointComponent.updateView(this.chartView.stage, mapPointViewModel); this.updateComponents(); return this; } resizeView(){ if(this.chartView.isSmallViewBox) { this.chartView.syncViewBoxDimension(); this.updateView(); } return this; } }