원클릭으로
create-custom-viewer
Create a custom JavaScript viewer extending DG.JsViewer with properties and rendering
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Create a custom JavaScript viewer extending DG.JsViewer with properties and rendering
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use whenever you need the Datagrok browser to actually execute JavaScript — adding viewers, filtering, modifying the view, or returning a result widget to the chat. Open this skill before calling the datagrok_exec tool.
Filter rows of a Datagrok DataFrame inside a datagrok-exec block through the Filters panel — by range, equals/contains/in-set, multi-value, boolean, free-text row expressions, or substructure (SMILES / SMARTS / molblock). Also covers clearing, inverting, the show-only-filtered vs destructive-drop split, and the filter event lifecycle (onRowsFiltering / onFilterChanged / onRowsFiltered). Use whenever the user says "filter", "show only", "hide rows where", "narrow to subset", "find rows that", "contains", "substructure search", "categorical filter", "range filter", "invert", "clear the filter", "clear filters", "drop rows", or asks for the filtered subset as a new table. Does NOT cover selection (separate skill) or generic DataFrame cloning (datagrok-df-and-columns).
Add a calculated, formula-based column to a dataframe inside a datagrok-exec block. Use whenever the user asks to compute, derive, add, or create a new column from existing columns — LipE, ratios, log/round, heavy atom count, any expression in the Datagrok formula DSL. Replaces hand-written addNewFloat/addNewInt + for-loop with a single formula-attached column that recomputes when source columns change.
Find, describe, add, remove, rename, clone, or set metadata on columns of a Datagrok DataFrame inside a datagrok-exec block. Use whenever the user asks to locate "the X column", summarize a column, add a typed/empty/values-filled/virtual column, set semantic type / units / format / friendly name, apply linear or categorical or conditional color coding, drop or rename columns, or copy a DataFrame. Covers everything in DataFrame.columns and Column.meta — but not row filtering/selection (datagrok-filtering, datagrok-selection) and not formula-only columns (datagrok-calc-column).
Sort, hide, show, reorder, resize, pin, format, and color-code columns in a Datagrok TableView grid from a datagrok-exec block. Use whenever the user asks to sort by a column (any direction), multi-sort, hide / show / reorder / pin / resize columns, freeze the first N columns, change number-format display, color-code cells (defaults and grid-only tint here; full per-type reference in datagrok-df-and-columns), set row height, or reset the grid back to defaults. Distinct from datagrok-df-and-columns (which owns column-level data metadata like semType, units, friendlyName, and is also where canonical color-coding lives) and from datagrok-viewers (which owns scatter plot / histogram / etc.). Does NOT cover filtering (`datagrok-filtering`), selection (`datagrok-selection`), custom cell renderer authoring (`create-cell-renderer`), saving / restoring layouts, or grid event handlers.
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 inside a datagrok-exec block. 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.
| name | create-custom-viewer |
| description | Create a custom JavaScript viewer extending DG.JsViewer with properties and rendering |
| when-to-use | When user asks to create a viewer, chart, visualization, or custom rendering component |
| context | fork |
| effort | high |
| argument-hint | [viewer-name] [package-path] |
Help the user develop a custom interactive viewer for Datagrok by extending DG.JsViewer.
/create-custom-viewer [viewer-name] [--library <d3|echarts|plotly>]
From the package directory:
grok add viewer <ViewerName>
This creates a viewer class file. The naming convention is to add a Viewer postfix to the class name (e.g., AwesomeViewer).
Create a subclass of DG.JsViewer in a separate file (e.g., src/awesome-viewer.ts):
import * as DG from 'datagrok-api/dg';
import * as ui from 'datagrok-api/ui';
export class AwesomeViewer extends DG.JsViewer {
constructor() {
super();
// Register properties (appear in the context panel)
this.splitColumnName = this.string('splitColumnName', 'site');
this.valueColumnName = this.int('valueColumnName', 'age');
this.valueAggrType = this.string('valueAggrType', 'avg', { choices: ['avg', 'count', 'sum'] });
this.color = this.string('color', 'steelblue', { choices: ['darkcyan', 'seagreen', 'steelblue'] });
this.initialized = false;
}
onTableAttached() {
this.init();
this.subs.push(DG.debounce(this.dataFrame.selection.onChanged, 50).subscribe((_) => this.render()));
this.subs.push(DG.debounce(this.dataFrame.filter.onChanged, 50).subscribe((_) => this.render()));
this.subs.push(DG.debounce(ui.onSizeChanged(this.root), 50).subscribe((_) => this.render(false)));
this.render();
}
detach() {
this.subs.forEach(sub => sub.unsubscribe());
}
onPropertyChanged(property) {
super.onPropertyChanged(property);
if (this.initialized)
this.render();
}
render(computeData = true) {
// Rendering logic here
}
}
In src/package.ts, add the annotated function:
import {AwesomeViewer} from './awesome-viewer';
//name: AwesomeViewer
//description: Creates an awesome viewer
//tags: viewer
//meta.icon: images/icon.svg
//meta.toolbox: true
//meta.trellisable: true
//output: viewer result
export function awesome() {
return new AwesomeViewer();
}
Or use the decorator approach (requires datagrok-tools >= 4.12.x):
@grok.decorators.viewer({
icon: 'images/icon.png',
toolbox: true,
})
export class AwesomeViewer extends DG.JsViewer { /* ... */ }
Available property types in the constructor:
this.int(name, defaultValue, options) -- integerthis.float(name, defaultValue, options) -- floating pointthis.string(name, defaultValue, options) -- stringthis.stringList(name, defaultValue, options) -- string arraythis.bool(name, defaultValue, options) -- booleanthis.dateTime(name, defaultValue, options) -- datetimeProperty grouping in the UI is determined by naming:
Data tab: properties ending with ColumnNameColors tab: properties ending with colorAxes tab: properties containing axisLegend tab: properties starting with legendMargins tab: properties containing marginMisc tab: everything elseAlways respect the dataframe filter when preparing data:
render(computeData = true) {
if (computeData) {
this.data.length = 0;
this.aggregatedTable = this.dataFrame
.groupBy([this.splitColumnName])
.whereRowMask(this.dataFrame.filter)
.add(this.valueAggrType, this.valueColumnName, 'result')
.aggregate();
// Process aggregated data...
}
// Render using this.root as the container
}
Add tooltips and selection handling to visual elements:
// Row group tooltips on hover
element.on('mouseover', (event, d) => ui.tooltip.showRowGroup(this.dataFrame, i => {
return d.category === this.dataFrame.getCol(this.splitColumnName).get(i);
}, event.x, event.y));
element.on('mouseout', () => ui.tooltip.hide());
// Selection on click
element.on('mousedown', (event, d) => {
this.dataFrame.selection.handleClick(i => {
return d.category === this.dataFrame.getCol(this.splitColumnName).get(i);
}, event);
});
Add libraries (e.g., D3, ECharts) to package.json dependencies. Do NOT add platform-provided externals (datagrok-api, rxjs, cash-dom, dayjs, wu, openchemlib/full) to your bundle.
npm run build
grok publish dev
Test with: grok.shell.addTableView(grok.data.demo.demog()).addViewer('AwesomeViewer');
this.subs so they are cleaned up when the viewer is detached.DG.debounce on frequently firing events (selection, filter, resize) for performance.