Compound.ProgressBar¶
Creates a ProgressBar compound SVG visual
DaxLib.SVG.Compound.ProgressBar( x, y, width, height, paddingX, paddingY, valueRef, trackRef, fillColor, trackColor, orientation )
| Parameter | Type | Required | Description |
|---|---|---|---|
| x | INT64 | The x position of the compound | |
| y | INT64 | The y position of the compound | |
| width | INT64 | The width of the compound | |
| height | INT64 | The height of the compound | |
| paddingX | DECIMAL | Optional: Horizontal padding percentage (0.0-1.0). Defaults to 0 | |
| paddingY | DECIMAL | Optional: Vertical padding percentage (0.0-1.0). Defaults to 0 | |
| valueRef | NUMERIC EXPR | Value expression (the bar measure) | |
| trackRef | NUMERIC EXPR | Optional: Track measure (maximum value, can vary per context). Defaults to MAX(1, ABS(valueRef)) | |
| fillColor | STRING | Optional: Progress color. Defaults to "#0F6CBD" | |
| trackColor | STRING | Optional: Track color. Defaults to "#E1DFDD" | |
| orientation | STRING | "Horizontal" or "Vertical". Defaults to "Horizontal" |
STRING SVG Progress Bar
function 'DaxLib.SVG.Compound.ProgressBar' =
(
x: INT64,
y: INT64,
width: INT64,
height: INT64,
paddingX: DOUBLE,
paddingY: DOUBLE,
valueRef: NUMERIC EXPR,
trackRef: NUMERIC EXPR,
fillColor: STRING,
trackColor: STRING,
orientation: STRING
) =>
VAR _X = x + (width * (IF(ISBLANK(paddingX), 0, paddingX) / 2))
VAR _Y = y + (height * (IF(ISBLANK(paddingY), 0, paddingY) / 2))
VAR _Width = width * (1 - IF(ISBLANK(paddingX), 0, paddingX))
VAR _Height = height * (1 - IF(ISBLANK(paddingY), 0, paddingY))
VAR _Orientation = IF( orientation = "Vertical", "Vertical", "Horizontal" )
VAR _FillColor = IF( NOT ISBLANK( fillColor ), fillColor, "#0F6CBD" )
VAR _TrackColor = IF( NOT ISBLANK( trackColor ), trackColor, "#E1DFDD" )
VAR _Value = valueRef
VAR _Max = IF( ISBLANK( trackRef ), MAX( 1, ABS( _Value ) ), MAX( 1, ABS( trackRef ) ) )
VAR _Pct = MIN( 1, MAX( 0, DIVIDE( _Value, _Max, 0 ) ) )
VAR _Track =
DaxLib.SVG.Element.Rect(
_X,
_Y,
_Width,
_Height,
3,
3,
DaxLib.SVG.Attr.Shapes( _TrackColor, 1, BLANK(), _TrackColor, 1, BLANK(), BLANK() ),
BLANK()
)
VAR _FillW = IF( _Orientation = "Horizontal", _Width * _Pct, _Width )
VAR _FillH = IF( _Orientation = "Horizontal", _Height, _Height * _Pct )
VAR _FillX = _X
VAR _FillY = IF( _Orientation = "Horizontal", _Y, _Y + ( _Height - _FillH ) )
VAR _Fill =
DaxLib.SVG.Element.Rect(
_FillX,
_FillY,
_FillW,
_FillH,
3,
3,
DaxLib.SVG.Attr.Shapes( _FillColor, 0.95, BLANK(), _FillColor, 1, BLANK(), BLANK() ),
BLANK()
)
RETURN
IF( NOT ISBLANK( _Value ) && _Width > 0 && _Height > 0, _Track & _Fill )