Viz.Heatmap¶
Renders a heatmap as an SVG data URI showing data density using kernel density estimation
Kernel Density Estimation (KDE)
KDE is a statistical method that estimates the probability density function of your data by placing a "kernel" (typically a normal distribution) at each data point. The heatmap visualizes data density across the range, creating smooth gradients that reveal patterns and concentrations in your dataset.
Key Parameters:
-
Samples: Controls the resolution of the density calculation (higher = smoother, but slower performance)
-
Bandwidth: Controls the smoothing level - smaller values create sharper peaks around data points, larger values create broader, smoother distributions
| Parameter | Type | Required | Description |
|---|---|---|---|
| axisRef | ANYREF EXPR | Axis reference column | |
| measureRef | NUMERIC EXPR | Measure expression | |
| color | STRING | Optional color for high density areas. Defaults to Power BI theme color | |
| width | INT64 | Optional: SVG width. Defaults to 120 | |
| height | INT64 | Optional: SVG height. Defaults to 48 |
STRING SVG Heatmap
function 'DaxLib.SVG.Viz.Heatmap' =
(
axisRef: ANYREF EXPR,
measureRef: NUMERIC EXPR,
color: 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.Heatmap(
0, 0, _W, _H, 0, 0,
axisRef, measureRef, 50, 1, _Color
)
RETURN
IF( NOT ISBLANK( _Marks ), DaxLib.SVG.SVG( "100%", "100%", "0 0 " & _W & " " & _H, _Marks, BLANK() ) )