|
9 | 9 | #import "../data.typ": column |
10 | 10 | #import "../utils/types.typ": infer-column-type, parse-number |
11 | 11 | #import "../utils/typst-markup.typ": is-typst-markup |
12 | | -#import "../utils/late-binding.typ": is-late-binding, late-binding-name |
| 12 | +#import "../utils/late-binding.typ": ( |
| 13 | + after-scale-source, is-late-binding, late-binding-name, |
| 14 | +) |
13 | 15 |
|
14 | 16 | #let _resolve-mapping(layer, plot-mapping) = { |
15 | 17 | if layer.at("inherit-aes", default: true) and plot-mapping != none { |
|
260 | 262 | for a in aes-list { |
261 | 263 | let raw = layer-mapping.at(a, default: none) |
262 | 264 | if raw == none { continue } |
263 | | - // Late-binding markers (`after-stat`, `from-theme`, ...) carry no |
264 | | - // column to train against; evaluation happens in `_prepare-layer` |
265 | | - // for `from-theme` and post-stat for `after-stat`. |
266 | | - if is-late-binding(raw) { continue } |
267 | | - let col-name = mapping-ref-col(raw) |
| 265 | + // Late-binding markers that carry a `source` column (an `after-scale` |
| 266 | + // derived from `stage(start: ...)`) train on that column so the per-row |
| 267 | + // resolver hands the closure the channel's scale-resolved value, as |
| 268 | + // documented on `@after-scale`. Source-less markers (`after-stat`, |
| 269 | + // `from-theme`, and a pure `after-scale` closure) are evaluated |
| 270 | + // elsewhere; skip them. |
| 271 | + let train-ref = if is-late-binding(raw) { after-scale-source(raw) } else { |
| 272 | + raw |
| 273 | + } |
| 274 | + if train-ref == none or is-late-binding(train-ref) { continue } |
| 275 | + let col-name = mapping-ref-col(train-ref) |
268 | 276 | let entry = cache.at(a) |
269 | 277 | entry.cols.push(( |
270 | 278 | name: col-name, |
271 | 279 | values: column(layer-data, col-name), |
272 | | - forced-type: _resolve-forced-type(raw, layer-data, col-name), |
| 280 | + forced-type: _resolve-forced-type(train-ref, layer-data, col-name), |
273 | 281 | levels: layer-factor-levels.at(col-name, default: none), |
274 | 282 | )) |
275 | | - if is-typst-markup(raw) { entry.typst-mark = true } |
| 283 | + if is-typst-markup(train-ref) { entry.typst-mark = true } |
276 | 284 | cache.insert(a, entry) |
277 | 285 | } |
278 | 286 | } |
|
0 commit comments