constructor()

in src/multiKpi.ts [76:133]


    constructor(options: powerbiVisualsApi.extensibility.visual.VisualConstructorOptions) {
        if (window.location !== window.parent.location) {
            require("core-js/stable");
        }

        const {
            element,
            host,
        } = options;

        this.host = host;

        this.tooltipServiceWrapper = new TooltipServiceWrapper(
            {
                handleTouchDelay: 0,
                rootElement: options.element,
                tooltipService: host.tooltipService,
            });

        this.dataConverter = new DataConverter({
            createSelectionIdBuilder: host.createSelectionIdBuilder.bind(host),
        });

        this.eventDispatcher.on(
            EventName.onChartChange,
            this.onChartChange.bind(this),
        );

        this.eventDispatcher.on(
            EventName.onChartViewChange,
            this.onChartViewChange.bind(this),
        );

        this.eventDispatcher.on(
            EventName.onChartViewReset,
            () => this.render(this.dataRepresentation, this.settings, this.viewport),
        );

        this.rootComponent = new RootComponent({
            element: d3Select(element),
            eventDispatcher: this.eventDispatcher,
            scaleService: new ScaleService(element),
            style: host.colorPalette,
            tooltipServiceWrapper: this.tooltipServiceWrapper,
        });

        this.selectionManager = this.host.createSelectionManager();

        const visualSelection = d3Select(element);
        visualSelection.on("contextmenu", (event) => {
            let dataPoint: any = d3Select(event.target).datum();
            this.selectionManager.showContextMenu(dataPoint ? dataPoint.selectionId : {}, {
                x: event.clientX,
                y: event.clientY
            });
            event.preventDefault();
        });
    }