Axes.MaxTickLabelWidth¶
Estimates the maximum Y-axis tick label width for layout reservation
DaxLib.SVG.Axes.MaxTickLabelWidth( axisMin, axisMax, tickCount, axisFontSize, labelWidthFactor, axisIsDate )
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| axisMin | NUMERIC VAL | Axis minimum value | ||
| axisMax | NUMERIC VAL | Axis maximum value | ||
| tickCount | INT64 | 1 |
Optional: Number of ticks to estimate. Defaults to 1 | |
| axisFontSize | INT64 | 10 |
Optional: Axis font size. Defaults to 10 | |
| labelWidthFactor | DECIMAL | 0.56 |
Optional: Font width factor. Defaults to 0.56 (Segoe UI) | |
| axisIsDate | BOOLEAN | FALSE() |
Optional: Whether the axis values represent dates. Defaults to FALSE |
NUMERIC Estimated max label width in pixels
function 'DaxLib.SVG.Axes.MaxTickLabelWidth' =
(
axisMin: NUMERIC VAL,
axisMax: NUMERIC VAL,
tickCount: INT64 = 1,
axisFontSize: INT64 = 10,
labelWidthFactor: DOUBLE = 0.56,
axisIsDate: BOOLEAN = FALSE()
) =>
VAR _NumericSpan = ABS( axisMax - axisMin )
VAR _NumericDecimals = IF( _NumericSpan >= 100, 0, IF( _NumericSpan >= 10, 1, 2 ) )
VAR _TickBase =
ADDCOLUMNS(
GENERATESERIES( 0, tickCount - 1, 1 ),
"@TickValue",
IF(
tickCount = 1,
axisMin,
axisMin + DIVIDE( [Value], tickCount - 1, 0 ) * ( axisMax - axisMin )
)
)
VAR _LabelTable =
ADDCOLUMNS(
_TickBase,
"@Label",
FORMAT(
IF( axisIsDate, [@TickValue], ROUND( [@TickValue], _NumericDecimals )),
IF( axisIsDate, "dd-mmm-yy", "General Number")
)
)
VAR _MeasuredLabelTable =
ADDCOLUMNS(
_LabelTable,
"@EstimatedWidth", LEN( [@Label] ) * axisFontSize * labelWidthFactor
)
RETURN
MAXX( _MeasuredLabelTable, [@EstimatedWidth] )