public update()

in src/visual.ts [781:871]


    public update(options: VisualUpdateOptions): void {
        let dataView = options.dataViews[0];
        if (!dataView
            || !dataView.categorical
            || !dataView.categorical.categories
            || !dataView.categorical.categories[0]
            || !dataView.categorical.categories[0].values
            || !(dataView.categorical.categories[0].values.length > 0)
        ) {
            return null;
        }

        try {
            this.events.renderingStarted(options);

            const dataView: DataView = options.dataViews[0];

            this.setViewportSize(options.viewport);

            this.updateElements(
                Math.max(options.viewport.height, Default.MinViewportSize),
                Math.max(options.viewport.width, Default.MinViewportSize));

            this.data = Visual.CONVERTER(
                dataView,
                this.visualHost,
                this.localizationManager,
                this.colorHelper
            );

            if (!this.isDataValid(this.data)) {
                this.clear();
                return;
            }

            this.updateViewportIn();

            // update Axes
            const maxWidthOfVerticalAxisLabel = Visual.getWidthOfLabel(
                this.data.borderValues.maxY,
                this.data.yLabelFormatter),
            maxWidthOfHorizontalAxisLabel = Visual.getWidthOfLabel(
                this.data.borderValues.maxX,
                this.data.xLabelFormatter),
            maxHeightOfVerticalAxisLabel = Visual.getHeightOfLabel(
                this.data.borderValues.maxX,
                this.data.xLabelFormatter),
            ySource = dataView.categorical.values &&
                dataView.categorical.values[0] &&
                dataView.categorical.values[0].values
                ? dataView.categorical.values[0].source
                : dataView.categorical.categories[0].source,
            xSource = dataView.categorical.categories[0].source;

            this.createScales();

            this.yAxisProperties = this.calculateYAxes(ySource, maxHeightOfVerticalAxisLabel);
            this.renderYAxis();

            this.updateViewportIn(maxWidthOfVerticalAxisLabel);
            this.createScales();

            this.xAxisProperties = this.calculateXAxes(xSource, maxWidthOfHorizontalAxisLabel, false);
            this.renderXAxis();

            this.columnsAndAxesTransform(maxWidthOfVerticalAxisLabel);

            this.createScales();
            this.applySelectionStateToData();

            // render
            const columnsSelection: Selection<any> = this.renderColumns();

            this.tooltipServiceWrapper.addTooltip(
                columnsSelection,
                (eventArgs: TooltipEventArgs<HistogramDataPoint>) => eventArgs.data.tooltipInfo
            );

            this.bindSelectionHandler(columnsSelection);

            this.renderLegend();

            this.renderLabels();

            this.events.renderingFinished(options);
        }
        catch (e) {
            console.error(e);
            this.events.renderingFailed(options);
        }
    }