Add support for a new curve data format in the Curves package converter system
日本語の概要は準備中です。原文の説明を表示しています。
Add a viewer, configure a viewer, change viewer options, find viewer, close viewer, view a scatter plot, bar chart, histogram, line chart, box plot, pie chart, heat map, correlation plot, 3D scatter, trellis, density plot, statistics, on a Datagrok TableView via the datagrok_exec tool. Use whenever the user asks to plot, chart, visualize, show a graph, draw a distribution, color by a column, swap a viewer's axis, toggle a legend / regression line / log scale, replace one viewer with another, close every chart, reset the view to just the grid, or find an existing viewer by type. Plugin viewers like "Chem space", "sequence space", "activity cliffs" are NOT viewer types — they're registered functions — route those to `grok.functions.call`. Does NOT cover filtering (separate skill `datagrok-filtering`), selection (`datagrok-selection`), grid cell rendering (`datagrok-grid-customization`), layout save/restore, or custom-viewer authoring.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Add, configure, find, and close viewers on a DG.TableView via the
datagrok_exec tool. Globals injected by the runtime: grok, ui, DG,
view, t (the current DG.DataFrame, when the view is a TableView).
| Need | Call |
|---|---|
| Add a viewer | view.addViewer(DG.VIEWER.SCATTER_PLOT, {xColumnName: 'a', ...}) |
| Configure an existing viewer | viewer.setOptions({colorColumnName: 'logP'}) |
| All non-grid viewers | Array.from(view.viewers).slice(1) |
| First viewer of a type | Array.from(view.viewers).slice(1).find((v) => v.type === DG.VIEWER.SCATTER_PLOT) |
| Close one viewer | viewer.close() (wrap in try/catch — throws if never attached) |
| Close every non-grid viewer | Array.from(view.viewers).slice(1).forEach((v) => { try { v.close(); } catch {} }) |
| Inspect a viewer's option schema | viewer.getProperties() → DG.Property[] (each has .name) |
| Standalone (detached) viewer | DG.Viewer.fromType(DG.VIEWER.SCATTER_PLOT, t, {...}) |
ColumnName(s)Users say "x is mw, y is logp". You must emit xColumnName / yColumnName —
never bare x / y / color. Bare aliases are inconsistent across viewer
types and may silently do nothing for the canonical addViewer/setOptions
path. Always use the full *ColumnName(s) form.
| User says | Emit (single column) | Emit (multiple columns) |
|---|---|---|
x is mw | xColumnName: 'mw' | xColumnNames: ['mw', ...] |
y is logp | yColumnName: 'logp' | yColumnNames: ['logp', ...] |
color by activity | colorColumnName: 'activity' | — |
size by mw | sizeColumnName: 'mw' | — |
label by smiles | labelColumnName: 'smiles' | — |
split by class | splitColumnName: 'class' | splitColumnNames: ['class'] |
value is ic50 | valueColumnName: 'ic50' | valueColumnNames: ['ic50'] |
category is class | categoryColumnName: 'class' | categoryColumnNames: ['class'] |
columns are a, b | — | columnNames: ['a', 'b'] |
<role>ColumnName (string).<role>ColumnNames (array of strings).xColumnName for the x axis and yColumnNames for the series).viewer.getProperties() returns
DG.Property[]. Each has .name (canonical), .propertyType, .choices.Other naming conventions across viewers:
show: showRegressionLine, showXAxis,
showLegend, showStatistics, showColorSelector. Not regressionLine
/ legend / statistics.xAxisType: 'linear' | 'logarithmic' (and y, z,
colorAxisType). Not logX, not logScale.xMin, xMax, yMin, yMax. Not xRange: [a, b].Options not documented here must be confirmed against the live schema before
setting: viewer.getProperties() → match .name, respect .propertyType and
.choices. Values are scalars — never objects/arrays: a wrong-typed value is
stored unchecked.
view.viewers is a synchronous array snapshot:
view.viewers[0] is always the grid. Closing it breaks the table widget.
Every iteration must .slice(1) (or filter out v.type === DG.VIEWER.GRID)..type (a string equal to
one of the DG.VIEWER.* constants) and .dataFrame.Always use the DG.VIEWER.* constants, never literal strings:
| Constant | String value | Primary properties |
|---|---|---|
DG.VIEWER.SCATTER_PLOT | 'Scatter plot' | xColumnName, yColumnName, colorColumnName, sizeColumnName, showRegressionLine |
DG.VIEWER.HISTOGRAM | 'Histogram' | valueColumnName, splitColumnName, bins |
DG.VIEWER.LINE_CHART | 'Line chart' | xColumnName, yColumnNames (array) |
DG.VIEWER.BAR_CHART | 'Bar chart' | splitColumnName, valueColumnName, valueAggrType |
DG.VIEWER.PIE_CHART | 'Pie chart' | categoryColumnName |
DG.VIEWER.BOX_PLOT | 'Box plot' | valueColumnName, categoryColumnName |
DG.VIEWER.HEAT_MAP | 'Heat map' | (returns a Grid subclass — column tag-driven color coding) |
DG.VIEWER.STATISTICS | 'Statistics' | columnNames |
DG.VIEWER.CORR_PLOT | 'Correlation plot' | columnNames (or xs / ys) |
DG.VIEWER.DENSITY_PLOT | 'Density plot' | xColumnName, yColumnName |
DG.VIEWER.SCATTER_PLOT_3D | '3d scatter plot' | xColumnName, yColumnName, zColumnName, colorColumnName |
DG.VIEWER.TRELLIS_PLOT | 'Trellis plot' | xColumnNames, yColumnNames, viewerType |
DG.VIEWER.PC_PLOT | 'PC Plot' | columnNames |
DG.VIEWER.TREE_MAP | 'Tree map' | splitColumnNames, sizeColumnName |
DG.VIEWER.MATRIX_PLOT | 'Matrix plot' | xColumnNames, yColumnNames |
DG.VIEWER.FILTERS | 'Filters' | columnNames (see datagrok-filtering for the real filtering API) |
DG.VIEWER.FORM | 'Form' | columnNames |
DG.VIEWER.MARKUP | 'Markup' | content (string) |
DG.VIEWER.NETWORK_DIAGRAM | 'Network diagram' | node1ColumnName, node2ColumnName |
DG.VIEWER.WORD_CLOUD | 'Word cloud' | column |
DG.VIEWER.TILE_VIEWER | 'Tile Viewer' | per-row cards |
DG.VIEWER.PIVOT_TABLE | 'Pivot table' | grouped aggregates |
DG.VIEWER.SHAPE_MAP | 'Shape Map' | choropleth |
DG.VIEWER.CALENDAR | 'Calendar' | dateColumnName |
DG.VIEWER.GLOBE | 'Globe' | latitudeColumnName, longitudeColumnName |
DG.VIEWER.GOOGLE_MAP | 'Google map' | latitudeColumnName, longitudeColumnName |
DG.VIEWER.TIMELINES | 'Timelines' | startColumnName, endColumnName |
DG.VIEWER.RADAR_VIEWER | 'Radar' | columnNames |
DG.VIEWER.GRID | 'Grid' | (the main grid — view.grid is the typed accessor) |
Full canonical list at runtime: Object.values(DG.VIEWER).
Use the in-scope view global, not grok.shell.tv (the globally active
view, which may be a different tab when the user has several open).
// Scatter plot of MW vs LogP, colored by activity, with regression line.
view.addViewer(DG.VIEWER.SCATTER_PLOT, {
xColumnName: 'MW',
yColumnName: 'LogP',
colorColumnName: 'activity',
showRegressionLine: true,
});
// Line chart with multiple y series — yColumnNames is the plural form (array).
view.addViewer(DG.VIEWER.LINE_CHART, {
xColumnName: 'date',
yColumnNames: ['revenue', 'expenses', 'profit'],
});
// Bar chart of count by category.
view.addViewer(DG.VIEWER.BAR_CHART, {
splitColumnName: 'category',
valueColumnName: 'count',
valueAggrType: 'sum',
});
viewer.setOptions({...}) applies a batch of property changes and re-renders
once. Same property-name rules as addViewer.
// Recolor the existing scatter plot by a different column.
const sp = Array.from(view.viewers).slice(1)
.find((v) => v.type === DG.VIEWER.SCATTER_PLOT);
if (sp)
sp.setOptions({colorColumnName: 'logP'});
view.addViewer(...) returns the freshly attached viewer, so you can chain
create + configure:
const sp = view.addViewer(DG.VIEWER.SCATTER_PLOT, {
xColumnName: 'height',
yColumnName: 'weight',
showRegressionLine: true,
});
sp.setOptions({xMin: 150, xMax: 200, colorColumnName: 'age'});
To discover property names, ask the viewer:
const v = view.addViewer(DG.VIEWER.SCATTER_PLOT);
const names = v.getProperties().map((p) => p.name);
return ui.divText(names.join(', '));
view.viewers is an array; index 0 is always the grid, so iteration always
starts with .slice(1).
// First scatter plot on the view (or undefined).
const sp = Array.from(view.viewers).slice(1)
.find((v) => v.type === DG.VIEWER.SCATTER_PLOT);
// All histograms.
const hs = Array.from(view.viewers).slice(1)
.filter((v) => v.type === DG.VIEWER.HISTOGRAM);
viewer.close() closes and detaches the viewer. It throws if the viewer
was never attached to a view, so wrap in try/catch.
// Close every scatter plot on the view.
Array.from(view.viewers).slice(1)
.filter((v) => v.type === DG.VIEWER.SCATTER_PLOT)
.forEach((v) => { try { v.close(); } catch {} });
// Close every non-grid viewer (reset the view to just the grid).
Array.from(view.viewers).slice(1)
.forEach((v) => { try { v.close(); } catch {} });
Close-and-replace pattern for "show me X instead of Y":
// Close all scatter plots, then add a histogram.
Array.from(view.viewers).slice(1)
.filter((v) => v.type === DG.VIEWER.SCATTER_PLOT)
.forEach((v) => { try { v.close(); } catch {} });
view.addViewer(DG.VIEWER.HISTOGRAM, {valueColumnName: 'activity'});
Some "viewers" users name are actually package-registered functions that
create a viewer as a side effect. They aren't in DG.VIEWER. Route via
grok.functions.call:
| User phrase | Function call |
|---|---|
| "chem space" / "chemical space" | grok.functions.call('Chem:chemSpaceTopMenu', {table: t, molecules: t.col('smiles'), methodName: 'UMAP', similarityMetric: 'Tanimoto', plotEmbeddings: true}) |
| "sequence space" | grok.functions.call('Bio:sequenceSpaceTopMenu', {table: t, molecules: t.col('sequence'), methodName: 'UMAP', similarityMetric: 'Levenshtein', plotEmbeddings: true}) |
| "activity cliffs" | grok.functions.call('Chem:activityCliffs', {table: t, molecules: t.col('smiles'), activities: t.col('activity'), similarity: 80, methodName: 'UMAP'}) |
| "elemental analysis" | grok.functions.call('Chem:elementalAnalysis', {table: t, molecules: t.col('smiles')}) |
Each mutates the DataFrame and attaches a viewer to the current TableView.
Only the *Space functions return the freshly-attached viewer (Chem:chemSpaceTopMenu,
Bio:sequenceSpaceTopMenu). Chem:activityCliffs and Chem:elementalAnalysis
return void, so to keep configuring you must find the new viewer via
view.viewers:
const sp = await grok.functions.call('Chem:chemSpaceTopMenu', {
table: t, molecules: t.col('smiles'),
methodName: 'UMAP', similarityMetric: 'Tanimoto', plotEmbeddings: true,
});
if (sp)
sp.setOptions({colorColumnName: 'activity'});
Use DG.Viewer.fromType only when embedding a viewer in a custom UI
element you return from the block. The caller is responsible for placing the
result. For everything else, prefer view.addViewer.
// Build a scatter plot of t and embed its DOM root in the chat.
const sp = DG.Viewer.fromType(DG.VIEWER.SCATTER_PLOT, t, {
xColumnName: 'mw', yColumnName: 'logp',
});
return sp.root;
x / y / color in options — {x: 'mw', y: 'logp'} silently
does nothing. The property is xColumnName.DG.VIEWER.* — use DG.VIEWER.SCATTER_PLOT,
not 'scatter plot'.view.scatterPlot(opts) / view.histogram(opts) / view.barChart(opts) —
per-type shorthands are deprecated. Use view.addViewer(DG.VIEWER.*, opts).new DG.Viewer(...) — internal constructor over a Dart handle. Use
view.addViewer(type, opts) or DG.Viewer.fromType(type, df, opts?).grok.shell.addViewer(...) — no such method. Use view.addViewer(...).grok.shell.tv when view is in scope — view is the in-scope
TableView. grok.shell.tv is the globally active view and may be a
different tab.grok.functions.call.view.viewers without .slice(1) — index 0 is the grid.
view.viewers.forEach(v => v.close()) closes the grid.viewer.close() on a never-attached viewer — throws. Guard with
try/catch.await view.addViewer(...) — synchronous for built-in types. Only
plugin viewers via grok.functions.call(...) are async.df.filter) — datagrok-filtering.datagrok-grid-customization; column color coding —
datagrok-df-and-columns.DG.VIEWER.FILTERS) — view.getFiltersGroup()
is the right API and is covered by datagrok-filtering. Only add a
Filters viewer here if the user explicitly says "add a filter panel as a
viewer".まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Add support for a new curve data format in the Curves package converter system
日本語の概要は準備中です。原文の説明を表示しています。
Create info panels that appear in the context panel based on semantic types
日本語の概要は準備中です。原文の説明を表示しています。
Add a new single-objective optimization algorithm to the sci-comp library. Use when the user asks to implement a new optimizer (e.g. gradient descent, BFGS, simulated annealing, differential evolution).
日本語の概要は準備中です。原文の説明を表示しています。
Add unit tests to a Datagrok package
日本語の概要は準備中です。原文の説明を表示しています。
Answer a "how do I …" question about the platform with a Gherkin scenario on @datagrok-libraries/bdd that is filmed into a how-to video (grok-bdd guide), so the answer is demonstrated, sent as a video plus numbered steps, and kept as a regression test
日本語の概要は準備中です。原文の説明を表示しています。
Translate hand-written Playwright specs (or any existing UI tests) into Gherkin features on @datagrok-libraries/bdd, then prove the features test what they claim by backward-matching them against the originals with independent reviewers, and fix the gaps in the core, the library and the features
日本語の概要は準備中です。原文の説明を表示しています。