Skip to content

Def.LinearGradient

Create a linear gradient definition

DaxLib.SVG.Def.LinearGradient( defId, stops, x1, y1, x2, y2 )
Parameter Type Required Description
defId STRING The unique identifier for the gradient
stops STRING Concatenated list of one or more DaxLib.SVG.Def.GradientStop elements
x1 STRING Optional: Start X position
y1 STRING Optional: Start Y position
x2 STRING Optional: End X position
y2 STRING Optional: End Y position

STRING definition

DaxLib.SVG.SVG(
    500,
    100,
    "0 0 100 20",
    DaxLib.SVG.Element.Defs(
        DaxLib.SVG.Def.LinearGradient(
            "myGradient",   // id
            DaxLib.SVG.Def.GradientStop(
                "20%",      // offset
                DaxLib.SVG.Colour.Theme(
                    "Power BI",
                    25
                ),          // colour
                BLANK()     // opacity
            ) &
            DaxLib.SVG.Def.GradientStop( 
                "80%",      // offset
                DaxLib.SVG.Colour.Theme(
                    "Power BI",
                    26
                ),           // colour
                BLANK()     // opacity
            ),              // stops
            BLANK(),        // x1
            BLANK(),        // y1
            BLANK(),        // x2
            BLANK()         // y2
        )                   // contents
    ) &
    DaxLib.SVG.Element.Rect(
        2,                  // x
        2,                  // y
        "80%",              // width
        "80%",              // height
        BLANK(),            // rx
        BLANK(),            // ry
        DaxLib.SVG.Attr.Shapes(
            "url(""" & "#myGradient" & """)", // fill
            BLANK(),        // fillOpacity
            BLANK(),        // fillRule   
            BLANK(),        // stroke
            BLANK(),        // strokeWidth
            BLANK(),        // strokeOpacity
            BLANK()         // opacity
        ),                  // attributes
        BLANK()             // transforms
    ),
    BLANK()                 // sortValue               
)
function 'DaxLib.SVG.Def.LinearGradient' =
        (
            defId: STRING,
            stops: STRING,
            x1: STRING,
            y1: STRING,
            x2: STRING,
            y2: STRING
        ) =>

            "<linearGradient" & 
            " id='" & defId & "'" &
            IF( NOT ISBLANK( x1 ), " x1='" & x1 & "'" ) &
            IF( NOT ISBLANK( y1 ), " y1='" & y1 & "'" ) &
            IF( NOT ISBLANK( x2 ), " x2='" & x2 & "'" ) &
            IF( NOT ISBLANK( y2 ), " y2='" & y2 & "'" ) &
            ">" &
            stops &
            "</linearGradient>"