public update()

in src/timeLine.ts [667:766]


    public update(options: powerbiVisualsApi.extensibility.visual.VisualUpdateOptions): void {
        try {
            this.host.eventService.renderingStarted(options);

            if (!Timeline.ARE_VISUAL_UPDATE_OPTIONS_VALID(options)) {
                this.clearData();
                return;
            }

            this.options = options;
            this.dataView = options.dataViews[0];
            // it contains dates from data view.
            this.datePeriod = this.createDatePeriod(this.dataView);

            // Setting parsing was moved here from createTimelineData because settings values may be modified before the function is called.
            this.settings = Timeline.parseSettings(
                this.dataView,
                <AdvancedFilter[]>(this.options.jsonFilters),
                this.host.colorPalette,
            );

            if (!this.initialized) {
                this.timelineData = {
                    cursorDataPoints: [],
                    timelineDataPoints: [],
                };
            }

            this.adjustHeightOfElements(options.viewport.width);

            this.timelineGranularityData = new GranularityData(this.datePeriod.startDate, this.datePeriod.endDate);

            this.createTimelineData(
                this.settings,
                this.datePeriod.startDate,
                this.datePeriod.endDate,
                this.timelineGranularityData,
                this.locale,
                this.localizationManager,
            );

            this.updateCalendar(this.settings);

            const adjustedPeriod: IAdjustedFilterDatePeriod = this.adjustFilterDatePeriod();
            const datePeriod: ITimelineDatePeriodBase = this.datePeriod;
            const granularity: GranularityType = this.settings.granularity.granularity;
            const isCurrentPeriodSelected: boolean = !this.isForceSelectionReset && this.settings.forceSelection.currentPeriod;
            const isLatestAvailableDateSelected: boolean = !this.isForceSelectionReset && this.settings.forceSelection.latestAvailableDate;
            const isForceSelected: boolean = !this.isForceSelectionReset && (isCurrentPeriodSelected || isLatestAvailableDateSelected);
            this.isForceSelectionReset = false; // Reset it to default state to allow re-enabling Force Selection
            let currentForceSelectionResult = { startDate: null, endDate: null };

            if (isCurrentPeriodSelected) {
                currentForceSelectionResult = ({
                    endDate: adjustedPeriod.period.endDate,
                    startDate: adjustedPeriod.period.startDate,
                } = Timeline.SELECT_CURRENT_PERIOD(datePeriod, granularity, this.calendar));
            }
            if (isLatestAvailableDateSelected
                && (
                    !isCurrentPeriodSelected
                    || (isCurrentPeriodSelected
                        && !currentForceSelectionResult.startDate
                        && !currentForceSelectionResult.endDate
                    )
                )
            ) {
                adjustedPeriod.period.endDate = adjustedPeriod.adaptedDataEndDate;
                ({
                    endDate: adjustedPeriod.period.endDate,
                    startDate: adjustedPeriod.period.startDate,
                } = Timeline.SELECT_PERIOD(datePeriod, granularity, this.calendar, this.datePeriod.endDate));
            }

            this.updatePrevFilterState(adjustedPeriod, isForceSelected, this.timelineData.filterColumnTarget);

            if (!this.initialized) {
                this.initialized = true;
            }

            if (adjustedPeriod.period.startDate && adjustedPeriod.period.endDate) {
                this.changeGranularity(this.settings.granularity.granularity, adjustedPeriod.period.startDate, adjustedPeriod.period.endDate);
                this.updateCalendar(this.settings);
            }

            this.renderGranularityFrame(granularity);

            this.render(
                this.timelineData,
                this.settings,
                this.timelineProperties,
                options,
            );

            this.handleContextMenu();
        } catch (ex) {
            this.host.eventService.renderingFailed(options, JSON.stringify(ex));
        }
        this.host.eventService.renderingFinished(options);
    }