Skip to content

Viz.Pill

Renders a pill-shaped badge as an SVG data URI with centered text

DaxLib

DaxLib.SVG.Viz.Pill( txt, color, width, height )
Parameter Type Required Default Description
txt STRING The text to display
color STRING BLANK() Optional pill color. Defaults to Power BI theme color
width INT64 120 Optional: SVG width. Defaults to 120
height INT64 48 Optional: SVG height. Defaults to 48

STRING SVG Pill

DaxLib.SVG.Viz.Pill(
    "Active",           // txt
    "#EC008C",        // color
    120,                // width
    28                  // height
)
// Returns an SVG data URI with a pill-shaped badge
// Set as a measure with DataCategory = "ImageUrl"
function 'DaxLib.SVG.Viz.Pill' =
        (
            txt: STRING,
            color: STRING = BLANK(),
            width: INT64 = 120,
            height: INT64 = 48
        ) =>

            VAR _Marks =
                DaxLib.SVG.Compound.Pill(
                    0, 
                    0, 
                    width, 
                    height, 
                    txt, 
                    color
                )

            RETURN
                IF( NOT ISBLANK( _Marks ), DaxLib.SVG.SVG( "100%", "100%", _Marks, "0 0 " & width & " " & height ) )