fix(engine): compile leaf layers in the primary layout's chart area#89
Conversation
compileLayer compiled each leaf spec raw, without the layer-level chrome, legend, and theme that buildPrimarySpec merges into the primary spec. Each leaf therefore computed its own chart area: no title/subtitle reservation, a default legend position instead of the layer's, and default theme fonts. Leaf marks landed in that private coordinate space while axes, gridlines, and annotations rendered in the primary's, so on a layered scatter with a title and top legend every bubble drew up-and-left of where the axis said it should be (about 130px vertical and 128px horizontal drift at 766px). Freeze the primary layout's area into CompileOptions.frozenChartArea for leaf compiles so every layer's scales and marks share the primary's coordinate space, and inherit the layer-level theme/darkMode so leaf mark styling matches the primary.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds an optional ChangesFrozen Chart Area for Leaf Layer Alignment
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant compileLayer
participant compileChart
Caller->>compileLayer: compile(spec, options)
compileLayer->>compileLayer: compute primaryLayout
compileLayer->>compileLayer: build themedLeaf (inherit theme/darkMode)
compileLayer->>compileLayer: build leafOptions with frozenChartArea = primaryLayout.area
compileLayer->>compileChart: compileChart(themedLeaf, leafOptions)
compileChart->>compileChart: chartArea = frozenChartArea ?? dims.chartArea
compileChart-->>compileLayer: leaf marks positioned in primary coordinate space
compileLayer-->>Caller: compiled layered chart
Compact metadata
Related PRs: None specified Suggested labels: enhancement, engine Suggested reviewers: None specified Poem ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
compileLayercompiled each leaf spec raw, without the layer-levelchrome,legend, andthemethatbuildPrimarySpecmerges into the primary spec. Each leaf computed its own chart area (no title/subtitle reservation, default legend position, default theme fonts) and positioned its marks there, while axes, gridlines, and annotations rendered in the primary's area.On a layered scatter with a title + top legend (the AISD D/F scatter on labs), every bubble drew ~130px up and ~128px left of where the axes said it should be, compressing the whole cloud into the upper-left of the plot.
Fix
CompileOptions.frozenChartArea: when set,compileChartuses it instead of the computed area.compileLayerpasses the primary layout's area to every leaf compile, so all layers share one coordinate space.theme/darkModeso mark styling matches the primary.Testing
Summary by CodeRabbit