Commit 25356a2
Density layer (#110)
* build up scaffold
* bandwidth calculation
* add range utility
* working version for densities
* Add snapshot tests for density SQL generation
Add three tests verifying density SQL generation with normalized
whitespace comparison:
- test_density_sql_no_groups: validates CROSS JOIN without groups
- test_density_sql_with_two_groups: validates grouped density with join conditions
- test_density_sql_computed_bandwidth: validates Silverman's rule computation
Tests verify both SQL structure and executability.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Writing density follows area logic
* optimisations
* edit for clarity
* add test assumption that KDE for each group integrates to 1
* implement different kernels
* support 'weight' aesthetic
* write some docs
* try to build some violin infrastructure
* violin writer
* treat orthogonal `x` as yet another group
* add tests for violin geom
Adds two tests verifying violin stat transform behavior: one with only x/y aesthetics and another with additional color grouping. Ensures correct stat column generation and grouping logic.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* move detail wrangling upstream
* add docs for violin
* cargo fmt
* Add linewidth aesthetic to density geom
For consistency with violin and other area-based geoms that can have
strokes, density now supports the linewidth aesthetic.
* fix density column names
* fix stupid mistake
* include linetype aesthetics
* Update density query to include (unnormalised) intensity
* register columns properly
* violin can remap offset aesthetic
* polish docs
* dainty little docfix
* support NULL-containing groups in density
Use IS NOT DISTINCT FROM for NULL-safe group comparisons in density
computation. Allows density plots to include groups where grouping
columns contain NULL values.
Changes:
- build_data_cte: only filter NULLs in value column
- compute_density: use IS NOT DISTINCT FROM for bandwidth joins
- compute_density: use IS NOT DISTINCT FROM for grid matching
Benchmarked at 123ms vs 124ms (no performance regression).
Alternative ID mapping approach was 42x slower (5.3s).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* use QUANTILE_CONT for density bandwidth computation
Replace NTILE-based quartile computation with QUANTILE_CONT for IQR
calculation in Silverman's rule of thumb.
Changes:
- Replace 3-CTE approach (quartiles, metrics, bandwidth) with 1 CTE
- Use QUANTILE_CONT(x, 0.75) - QUANTILE_CONT(x, 0.25) for IQR
- Extract silverman_rule() function for clarity
- Remove unused partition variable
- Enhance test to validate exact SQL structure (grouped + ungrouped)
Benefits:
- Single aggregate pass over data (more efficient)
- Much more readable - formula directly visible
- Standard SQL aggregate functions vs complex window functions
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* add back violin detail encoding logic
* fix(violin): preserve upstream transforms instead of overwriting
ViolinRenderer was overwriting the entire transform array, which deleted
the source filter added upstream. This broke multi-layer plots where
violin data needs to be filtered from the unified dataset. Now follows
BoxplotRenderer's pattern: preserve existing transforms and extend with
violin-specific transforms.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* violin layer shows circle symbol in legend
* cargo fmt
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 9c529d1 commit 25356a2
8 files changed
Lines changed: 1729 additions & 13 deletions
File tree
- doc/syntax
- layer
- src
- plot/layer/geom
- writer/vegalite
- tree-sitter-ggsql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments