Quantcast
Channel: Northwoods Software - Latest topics
Viewing all articles
Browse latest Browse all 7421

ElementFinished in makeSvg

$
0
0

@agv wrote:

Hello,

I tried using elementFinished in makeSVG to change all the white stroke to black stroke in a graphobject. But I´m obtaining this:

capturaforogo

At the Diagram i have this:

screenshot

This is my makeSVG method:

makeSvg() {
    console.log('svg');
    var svg = this.myDiagram.makeSvg({
        scale: 1,
        elementFinished: function(graphObject, SVGElement) {
               SVGElement.setAttribute("background", "white");
               SVGElement.setAttribute("stroke", "black");
               SVGElement.setAttribute("fill", "black");
        }
    });

    var svgstr = new XMLSerializer().serializeToString(svg);
    var blob = new Blob([svgstr], {
        type: "image/svg+xml"
    });

    this.util.myCallback(blob);

}

And this is the figure:

    go.Shape.defineFigureGenerator("Switch", function (shape, w, h) {
    // this figure takes one parameter, the size of the corner
    h = w / 2;
    if (shape !== null) {
        var param1 = shape.parameter1;
        if (!isNaN(param1) && param1 >= 0) p1 = param1; // can't be negative or NaN
    }

    var centerX = w / 2;
    var centerY = h;
    var inputX = 0;
    var inputY = h;
    var tdX = w;
    var tdY = h;
    var tiX = w;
    var tiY = 0;
    if (shape != null && shape.part !== null) {
        var pts = shape.part.data.point[0];
        if (pts.startX !== "" && pts.id === "input") {
            centerX = pts.startX;
            centerY = pts.startY;
            inputX = pts.endX;
            inputY = pts.endY;
        }
        pts = shape.part.data.point[1];

        if (pts.startX !== "" && pts.id === "td") {
            tdX = pts.endX;
            tdY = pts.endY;
        }

        pts = shape.part.data.point[2];

        if (pts.startX !== "" && pts.id === "ti") {
            tiX = pts.endX;
            tiY = pts.endY;
        }

    }
    var geo = new go.Geometry();
    // a single figure consisting of straight lines and quarter-circle arcs
    var input = new go.PathSegment(go.PathSegment.Line, inputX, inputY).close();
    input.name = "input";

    var td = new go.PathSegment(go.PathSegment.Line, tdX, tdY).close();
    td.name = "td";

    var ti = new go.PathSegment(go.PathSegment.Line, tiX, tiY).close();
    ti.name = "ti";

    geo.add(new go.PathFigure(centerX, centerY)
        .add(input));
    geo.add(new go.PathFigure(centerX, centerY)
        .add(ti));

    geo.add(new go.PathFigure(centerX, centerY)
        .add(td));


    // don't intersect with two top corners when used in an "Auto" Panel
    return geo;
});

Any idea what is the problem?

Greetings

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7421

Trending Articles