private loadSettingsFromPowerBI()

in packages/tablesorter-powerbi/src/TableSorterVisual.ts [457:498]


    private loadSettingsFromPowerBI(oldState: TSSettings, newState: TSSettings) {
        if (this.dataView) {
            // Make sure we have the default values
            const updatedSettings: ITableSorterSettings =
                $.extend(true,
                    {},
                    this.tableSorter.settings,
                    TableSorterVisual.VISUAL_DEFAULT_SETTINGS,
                    this.initialSettings || { },
                    newState.toJSONObject());

            const unitsOrPrecisionChanged =
                oldState.presentation.labelPrecision !== newState.presentation.labelPrecision ||
                oldState.presentation.labelDisplayUnits !== newState.presentation.labelDisplayUnits;

            // If the units or precision changes, we need to update the formatter
            if (unitsOrPrecisionChanged) {
                this.numberFormatter = formatting.valueFormatter.create({
                    value: newState.presentation.labelDisplayUnits || 0,
                    format: "0",
                    precision: newState.presentation.labelPrecision || this.defaultPrecision,
                });
            }

            // If the header text color changes, we need to set the style
            const newHeaderTextColor = newState.presentation.headerTextColor;
            if (oldState.presentation.headerTextColor !== newHeaderTextColor) {
                this.element.find(".lu-header").css("color", newHeaderTextColor || ""); // tslint:disable-line
            }

            // If these things change, we need to force a rerender
            if (unitsOrPrecisionChanged ||
                (oldState.rankSettings.histogram !== newState.rankSettings.histogram) ||
                (oldState.presentation.textColor !== newState.presentation.textColor)) {
                this.tableSorter.rerenderValues();
            }

            this.tableSorter.settings = updatedSettings;

            this.restoreSelection();
        }
    }