private getSvgPathForForwardLink()

in src/sankeyDiagram.ts [2183:2236]


    private getSvgPathForForwardLink(link: SankeyDiagramLink): string {
        let pathParams: string = "";
        const distanceBetweenLinks: number = 3;

        let x0: number,
            x1: number,
            xi: (t: number) => number,
            x2: number,
            x3: number,
            y0: number,
            y1: number;

        if (link.destination.x < link.source.x) {
            x0 = link.source.x;
            x1 = link.destination.x + link.destination.width;
        } else {
            x0 = link.source.x + link.source.width;
            x1 = link.destination.x;
        }

        // drawing area as combination of 4 lines in one path element of svg to fill this area with required color
        // upper border of link
        xi = d3.interpolateNumber(x0, x1);
        x2 = xi(this.curvatureOfLinks);
        x3 = xi(1 - this.curvatureOfLinks);
        y0 = link.source.y + link.dySource + link.height / SankeyDiagram.MiddleFactor - (link.height - distanceBetweenLinks) / 2;
        y1 = link.destination.y + link.dyDestination + link.height / SankeyDiagram.MiddleFactor - (link.height - distanceBetweenLinks) / 2;

        pathParams += ` M ${x0} ${y0} C ${x2} ${y0}, ${x3} ${y1}, ${x1} ${y1}`;

        // right border of link
        y0 = link.destination.y + link.dyDestination + (link.height - distanceBetweenLinks) / SankeyDiagram.MiddleFactor + (link.height - distanceBetweenLinks) / 2;
        y1 = link.destination.y + link.dyDestination + (link.height - distanceBetweenLinks) / SankeyDiagram.MiddleFactor - (link.height - distanceBetweenLinks) / 2;

        pathParams += ` L ${x1} ${y0}`;

        // bottom border of link
        xi = d3.interpolateNumber(x0, x1);
        x2 = xi(this.curvatureOfLinks);
        x3 = xi(1 - this.curvatureOfLinks);
        y0 = link.source.y + link.dySource + (link.height - distanceBetweenLinks) / SankeyDiagram.MiddleFactor + (link.height - distanceBetweenLinks) / 2;
        y1 = link.destination.y + link.dyDestination + (link.height - distanceBetweenLinks) / SankeyDiagram.MiddleFactor + (link.height - distanceBetweenLinks) / 2;

        pathParams += ` L ${x1} ${y1} C ${x2} ${y1}, ${x3} ${y0}, ${x0} ${y0}`;

        // left border of link
        y0 = link.source.y + link.dySource + (link.height - distanceBetweenLinks) / SankeyDiagram.MiddleFactor + (link.height - distanceBetweenLinks) / 2;
        y1 = link.source.y + link.dySource + (link.height - distanceBetweenLinks) / SankeyDiagram.MiddleFactor - (link.height - distanceBetweenLinks) / 2;

        // close path to get closed area
        pathParams += ` Z`;

        return pathParams;
    }