private getCoordinates()

in src/tooltipService.ts [188:218]


    private getCoordinates(event, rootNode: Element, isPointerEvent: boolean): number[] {
        let coordinates: number[];

        if (isPointerEvent) {
            // DO NOT USE - WebKit bug in getScreenCTM with nested SVG results in slight negative coordinate shift
            // Also, IE will incorporate transform scale but WebKit does not, forcing us to detect browser and adjust appropriately.
            // Just use non-scaled coordinates for all browsers, and adjust for the transform scale later (see lineChart.findIndex)
            // coordinates = d3.mouse(rootNode);

            // copied from d3_eventSource (which is not exposed)
            let e = <MouseEvent>event, s;

            while (s = (<any>e).sourceEvent) e = s;

            let rect: ClientRect = rootNode.getBoundingClientRect();

            coordinates = [
                e.clientX - rect.left - rootNode.clientLeft,
                e.clientY - rect.top - rootNode.clientTop
            ];
        }
        else {
            let touchCoordinates = pointers(event);

            if (touchCoordinates && touchCoordinates.length > 0) {
                coordinates = touchCoordinates[0];
            }
        }

        return coordinates;
    }