Skip to content

Viz.ProgressBar

Renders a progress bar as an SVG data URI showing value progression

DaxLib.SVG.Viz.ProgressBar( valueRefExpr, trackRefExpr, color, orientation, width, height )
Parameter Type Required Description
valueRefExpr NUMERIC EXPR Value expression
trackRefExpr NUMERIC EXPR Track measure (maximum value)
color STRING Optional fill color. Defaults to Power BI theme color
orientation STRING Optional orientation: "Horizontal" or "Vertical". Defaults to "Horizontal"
width INT64 Optional: SVG width. Defaults to 120
height INT64 Optional: SVG height. Defaults to 48

STRING SVG Progress Bar

DaxLib.SVG.Viz.ProgressBar(
    [Completed],        // valueRefExpr
    [Target],           // trackRefExpr
    BLANK(),            // color (uses default theme)
    "Horizontal",       // orientation
    200,                // width
    20                  // height
)
// Returns an SVG data URI with an embedded progress bar
// Set as a measure with DataCategory = "ImageUrl"
function 'DaxLib.SVG.Viz.ProgressBar' =
        (
            valueRefExpr: NUMERIC EXPR,
            trackRefExpr: NUMERIC EXPR,
            color: STRING,
            orientation: STRING,
            width: INT64,
            height: INT64
        ) =>

            VAR _W = IF( ISBLANK( width ), 120, width )
            VAR _H = IF( ISBLANK( height ), 48, height )
            VAR _Color = IF( NOT ISBLANK( color ), color, DaxLib.SVG.Color.Theme( "Power BI", 1 ) )
            VAR _Marks =
                DaxLib.SVG.Compound.ProgressBar(
                    0, 0, _W, _H, 0, 0,
                    valueRefExpr, trackRefExpr, _Color, "#E1DFDD", orientation
                )

            RETURN
                IF( NOT ISBLANK( _Marks ), DaxLib.SVG.SVG( "100%", "100%", "0 0 " & _W & " " & _H, _Marks, BLANK() ) )