Viz.Violin¶
Renders a violin plot as an SVG data URI showing probability density distribution
Kernel Density Estimation (KDE)
KDE creates a smooth estimate of your data's probability density by placing a "kernel" (normal distribution curve) at each data point and summing them together. The violin plot displays this density as a symmetrical shape - wider areas indicate higher probability/frequency of values.
Key Parameters:
-
Samples: Controls the resolution of the density calculation (higher = smoother, but slower performance)
-
Bandwidth: Controls how much each data point influences nearby areas. Smaller bandwidth values create sharper, more detailed curves that closely follow individual data points. Larger bandwidth values create smoother, more generalized shapes that show overall trends
| Parameter | Type | Required | Description |
|---|---|---|---|
| axisRef | ANYREF EXPR | Axis reference column | |
| measureRef | NUMERIC EXPR | Measure expression | |
| color | STRING | Optional fill color. Defaults to Power BI theme color | |
| width | INT64 | Optional: SVG width. Defaults to 120 | |
| height | INT64 | Optional: SVG height. Defaults to 48 |
STRING SVG Violin Plot
function 'DaxLib.SVG.Viz.Violin' =
(
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.Violin(
0, 0, _W, _H, 0, 0,
axisRef, measureRef, 50, 1, _Color, BLANK()
)
RETURN
IF( NOT ISBLANK( _Marks ), DaxLib.SVG.SVG( "100%", "100%", "0 0 " & _W & " " & _H, _Marks, BLANK() ) )