Skip to content

Def.RadialGradient

Create a radial gradient definition

DaxLib.SVG.Def.RadialGradient( defId, stops, cx, cy, r, fx, fy, fr )
Parameter Type Required Default Description
defId STRING The unique identifier for the gradient
stops STRING Concatenated list of one or more DaxLib.SVG.Def.GradientStop elements
cx STRING BLANK() Optional: Center X position
cy STRING BLANK() Optional: Center Y position
r STRING BLANK() Optional: Radius
fx STRING BLANK() Optional: Focus X position
fy STRING BLANK() Optional: Focus Y position
fr STRING BLANK() Optional: Focus radius

STRING definition

DaxLib.SVG.SVG(
    500,                    // width
    100,                    // height
    DaxLib.SVG.Element.Defs(
        DaxLib.SVG.Def.RadialGradient(
            "myGradient",   // defId
            DaxLib.SVG.Def.GradientStop( 
                "10%",      // offset
                DaxLib.SVG.Color.Theme(
                    "Power BI",
                    25
                ),          // color
                BLANK()     // opacity
            ) &
            DaxLib.SVG.Def.GradientStop( 
                "80%",      // offset
                DaxLib.SVG.Color.Theme(
                    "Power BI",
                    26
                ),          // color
                0.5         // opacity
            ) &
            DaxLib.SVG.Def.GradientStop( 
                "95%",      // offset
                DaxLib.SVG.Color.Theme(
                    "Power BI",
                    27
                ),          // color
                BLANK()     // opacity
            ),              // stops
            BLANK(),        // cx
            BLANK(),        // cy
            BLANK(),        // r
            BLANK(),        // fx
            BLANK(),        // fy
            BLANK()         // fr
        )
    ) &
    DaxLib.SVG.Element.Circle(
        "50%",              // cx
        "50%",              // cy
        15,                 // r
        DaxLib.SVG.Attr.Shapes(
            "url(""" & "#myGradient" & """)", // fill
            BLANK(),        // fillOpacity
            BLANK(),        // fillRule   
            BLANK(),        // stroke
            BLANK(),        // strokeWidth
            BLANK(),        // strokeOpacity
            BLANK()         // opacity
        ),                  // attributes
        BLANK()             // transforms
    ),                      // contents
    "0 0 100 20",           // viewbox
    BLANK()                 // sortValue
)
function 'DaxLib.SVG.Def.RadialGradient' =
        (
            defId: STRING,
            stops: STRING,
            cx: STRING = BLANK(),
            cy: STRING = BLANK(),
            r: STRING = BLANK(),
            fx: STRING = BLANK(),
            fy: STRING = BLANK(),
            fr: STRING = BLANK()
        ) =>

            "<radialGradient" & 
            " id='" & defId & "'" &
            IF( NOT ISBLANK( cx ), " cx='" & cx & "'" ) &
            IF( NOT ISBLANK( cy ), " cy='" & cy & "'" ) &
            IF( NOT ISBLANK( r ),  " r='" & r & "'" ) &
            IF( NOT ISBLANK( fx ), " fx='" & fx & "'" ) &
            IF( NOT ISBLANK( fy ), " fy='" & fy & "'" ) &
            IF( NOT ISBLANK( fr ), " fr='" & fr & "'" ) &
            ">" &
            stops &
            "</radialGradient>"