constructor()

in packages/timebrush-powerbi/src/TimeBrushVisual.ts [87:109]


    constructor(options: powerbi.extensibility.visual.VisualConstructorOptions, timeBrushOverride?: TimeBrushImpl) {
        this.host = options.host;

        this.element = $(`<div><div class="timebrush"></div></div>`);

        const className = MY_CSS_MODULE && MY_CSS_MODULE.locals && MY_CSS_MODULE.locals.className;
        if (className) {
            $(options.element).append($("<style>" + MY_CSS_MODULE + "</style>"));
            this.element.addClass(className);
        }

        // HACK: PowerBI Swallows these events unless we prevent propagation upwards
        this.element.on("mousedown click pointerdown touchstart touchdown", (e: any) => e.stopPropagation());
        this._internalState = TimeBrushState.create<TimeBrushState>();
        this._doPBIFilter = debounce((range: [Date, Date]) => this.updatePBIFilter(range), 500);

        options.element.appendChild(this.element[0]);

         // Allow for overriding of the timebrush
        this.timeBrush = timeBrushOverride;
        this.timeBrush = this.timeBrush || new TimeBrushImpl(this.element.find(".timebrush"));
        this.timeBrush.events.on("rangeSelected", this.onTimeRangeSelected.bind(this));
    }