Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

First TextBlock Disappears in Graduated Panel

$
0
0

@dustinormond wrote:

I have a graduated node with two stacked textblocks. The problem is that if I just have the day textblock then Sunday shows up, but when I have both textblocks Sunday disappears. How do I get Sunday to appear? See the following screenshot and code below:

    var dateScale =
    $(go.Node,  "Graduated",
        {
            background: "#ccc", //"#fff",
            height: 50,
            graduatedTickUnit: 25,
            layerName: "Foreground",
            isInDocumentBounds: false,
            pickable: false
        },
        $(go.Shape,
            {
                stroke: "#777",
                geometryString: "M0 0 H" + scaleWidth(canvasWidth)
            }
        ),
        $(go.Shape,
            {
                stroke: "#777",
                geometryString: "M 0 0 V25", interval: 7
            }
        ),
        $(go.Shape,
            {
                stroke: "#777",
                geometryString: "M 0 12 V25", interval: 1
            }
        ),
        $(go.TextBlock,
            {
                interval: 7,
                name: "labels",
                font: "10pt sans-serif",
                height: 25,
                width: 175,
                verticalAlignment: go.Spot.Center,
                alignmentFocus: new go.Spot(0, 0, 0, 25),
                graduatedFunction: function(v) {
                    var d = new Date(2020, 1, 9);
                    d.setDate(d.getDate() + v / 25);
                    return d.toLocaleDateString("en-US", { month: "short", day: "2-digit", year: "numeric" });
                }
            }
        ),
        $(go.TextBlock,
            {
                name: "labels",
                font: "10pt sans-serif",
                height: 25,
                width: 25,
                verticalAlignment: go.Spot.Center,
                textAlign: "center",
                alignmentFocus: new go.Spot(0, 0, 0, 0),
                graduatedFunction: function(v) {
                    var d = new Date(2020, 1, 9);
                    d.setDate(d.getDate() + v / 25);
                    var day = d.toLocaleDateString("en-US", { weekday: "short" });
                    day = day == "Sun" ? "Su" : (day == "Thu" ? "Th" : d.toLocaleDateString("en-US", { weekday: "narrow" }));
                    return day;
                }
            }
        )
    )

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles