/** * Created by michaelbessey on 10/30/16. */ import {createBinModel} from "../mmviz-data"; import {ScaleTypeEnum, histogramLayoutCreator} from "../mmviz-layout/index"; import {HistogramComponentSvg} from "../mmviz-component-svg/index"; import {DetailsBehavior} from "../mmviz-behavior/index"; import {ChartBuilderSvg} from "./builder"; import {createBoxModel} from "../mmviz-data/index"; export class HistogramChartBuilderSvg extends ChartBuilderSvg { component: HistogramComponentSvg; constructor(selector: string) { super(selector); this.component = new HistogramComponentSvg(selector); this.detailsBehavior = new DetailsBehavior(selector, this.component.selector); } setDataArray(dataArray, valueMap: Function, binWidth: number){ return this.setDataModel(createBinModel(dataArray, valueMap, binWidth)); } createView(){ super.createView(); this.chartView.addContentTypeClass("histogram-content"); return this; } updateView(): HistogramChartBuilderSvg { let viewModel: any, layouter: Function, layoutExtender = histogramLayoutCreator(), axisViewModel: any; super.updateView(); 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(); } }