Skip to content

Add into= to lt_errorbar()/lt_dotplot() for a dedicated plot column - #42

Merged
yihui merged 2 commits into
mainfrom
errorbar-dotplot-into
Oct 9, 2026
Merged

yihui merged 2 commits into
mainfrom
errorbar-dotplot-into

Conversation

@yihui

@yihui yihui commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Implements #40.

Summary

lt_errorbar() and lt_dotplot() used to draw the plot into the first value column's cells, clobbering its text. into= names a dedicated target column to draw into instead; the series columns are still read by reference for their values and stay visible (unless hide drops them), so a table can show every value column as text and a plot in its own column. When into is omitted, behavior is unchanged.

How the extra column is added

Column creation is a generic, plot-agnostic core op. R emits an add_col op carrying only the column name (and an optional scalar fill), never a long empty array, so the JSON payload stays small for big tables. The runtime materializes the column client-side, and the rest of the pipeline treats it as an ordinary data column — counted in colspans, labelled, drawn into by a plot cell, etc. The op is internal (no exported lt_add()); the plot functions call it only when into names a missing column.

Because into becomes a genuine visible column, nCol-derived structure (full-width footer/axis rows, separator group headers, spanners) adjusts automatically.

Refactor

The error-bar and dot-plot cell renderers, which differ only in the per-cell SVG, now share one axisPlot() factory for their common resolve/cellClass/cell/foot (ticks, gridlines, footer axis, legend).

Verification

  • Static node build: errorbar + dotplot into render headers, SVGs, and value cells.
  • Colspan grows 3→4 with the extra column (group separator row + axis footer both span the new column).
  • Interactive path materializes the column client-side and draws the SVGs without touching real data.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Site preview: https://lt-pr-42.surge.sh

Updates on every push; removed when this PR closes.

@yihui
yihui force-pushed the errorbar-dotplot-into branch from 83f0595 to e328b2d Compare October 9, 2026 22:59
The plot used to be drawn into the first value column's cells, clobbering
its text, which forced callers who wanted both the values and a plot to
manufacture a throwaway anchor column (forestly does this today).

`into=` names a dedicated target column to draw into instead. The series
columns are still read by reference for their values and stay visible
(unless `hide` drops them), so a table can show every value column as text
*and* a plot in its own column.

Column creation is a generic, plot-agnostic core op: R emits an `add_col`
op carrying only the column name (and an optional scalar fill), never a
long empty array, so the JSON payload stays small for big tables. The
runtime materializes the column client-side and the rest of the pipeline
then treats it as an ordinary data column -- counted in colspans,
labelled, drawn into by a plot cell, etc. The op is internal (no exported
lt_add()); the plot functions call it when `into` names a missing column.

Because `into` becomes a genuine visible column, nCol-derived structure
(full-width footer/axis rows, separator group headers, spanners) adjusts
automatically -- verified colspan tracks the extra column, and the
interactive path renders it without touching real data.

The error-bar and dot-plot cell renderers, which differ only in the
per-cell SVG, now share one `axisPlot()` factory for their common
resolve/cellClass/cell/foot (ticks, gridlines, footer axis, legend).

Closes #40.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yihui
yihui force-pushed the errorbar-dotplot-into branch from e328b2d to d31e636 Compare October 9, 2026 23:08
Ships the updated lt.js/lt-plot.js assets (generic add_col op + the
shared axisPlot renderer) to the CDN for this branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yihui
yihui merged commit d3a06ee into main Oct 9, 2026
10 checks passed
@yihui
yihui deleted the errorbar-dotplot-into branch October 9, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant