public updateCrosshair()

in src/EnhancedScatterChart.ts [2221:2259]


    public updateCrosshair(x: number, y: number): void {
        if (!this.viewportIn
            || !this.crosshairHorizontalLineSelection
            || !this.crosshairVerticalLineSelection
            || !this.crosshairTextSelection
            || !this.xAxisProperties) {

            return;
        }

        let crosshairTextMargin: number = EnhancedScatterChart.CrosshairTextMargin,
            xScale = <ScaleLinear<number, number>>this.xAxisProperties.scale,
            yScale = <ScaleLinear<number, number>>this.yAxisProperties.scale,
            xFormated: number,
            yFormated: number;

        this.crosshairHorizontalLineSelection
            .attr("x1", EnhancedScatterChart.CrosshairStartPosition)
            .attr("y1", y)
            .attr("x2", this.viewportIn.width)
            .attr("y2", y);

        this.crosshairVerticalLineSelection
            .attr("x1", x)
            .attr("y1", EnhancedScatterChart.CrosshairStartPosition)
            .attr("x2", x)
            .attr("y2", this.viewportIn.height);

        xFormated = Math.round(xScale.invert(x) * EnhancedScatterChart.CrosshairScaleFactor)
            / EnhancedScatterChart.CrosshairScaleFactor;

        yFormated = Math.round(yScale.invert(y) * EnhancedScatterChart.CrosshairScaleFactor)
            / EnhancedScatterChart.CrosshairScaleFactor;

        this.crosshairTextSelection
            .attr("x", x + crosshairTextMargin)
            .attr("y", y - crosshairTextMargin)
            .text(`(${xFormated}, ${yFormated})`);
    }