reusable-visualization
БесплатноБез исполняемых скриптовНе проверенBuild ONE reusable chart visualization component that receives its data and its settings from the host application instead of fetching them, and declares the…
от lightdash★ 6 265 звёзд на GitHubОб этом скилле
Reusable visualization
This is ONE reusable chart component, not an app. It runs no query and owns no explore. Lightdash runs the query, then hands the component the result rows plus a mapping from the field names the component declared to the columns in those rows. The same component is reused across many different queries — every contract below follows from that: it cannot hardcode column names, so it declares a field mapping; it cannot hardcode display choices for queries it has never seen, so it declares config options.
No dashboard, navigation, multiple panels, filters or page chrome. Recharts, echarts, D3 or plain SVG all work.
Everything the viewer can reach later exists only because the component declared it: the columns they map, and every control in the chart's config panel. A literal hardcoded instead stays frozen until somebody regenerates the whole viz.
The hook
useVizContext() from @lightdash/query-sdk is the only channel to the host — data,
settings, and host actions all come from it. Do not add a message listener and do not
fetch anything yourself; the only host interaction is through the helpers the hook
returns.
const context = useVizContext();
const {
fieldMapping,
fields,
rows,
options,
colorPalette,
pivotDetails,
ready,
pointMenu,
underlyingData,
drillDown,
subtotals,
} = context;
fieldMapping—Record<string, string | string[]>: each single-field input maps to one query field id; inputs declared withmultiple: truemap to ordered arrays. Narrow withArray.isArray(binding)before iterating. Read each id withgetFormatted(row, fieldId)(display text) andgetRaw(row, fieldId)(raw value).fields—Record<string, { label, tableLabel?, format? }>: display metadata for each bound query field id. Name fields withgetFieldLabel(context, fieldId)— the field's label ("Total revenue"), or the raw id only when the host sent no metadata.formatis the semantic-layer format (typesuch ascurrency/percent/number, plusround,currency,compact,prefix,suffix) for formatters that have no cell to hand, such as axis ticks; per-value text still comes fromgetFormatted.rows— the host-fetched result rows, keyed by query field id.options—Record<string, boolean | number | string>: the current value of each config option you declared (the viewer's choice, else your declareddefault).colorPalette—string[]: the Lightdash palette resolved for this chart. Always pushed, whether or not you declaredcolorPalette. Empty only when the host resolved none.seriesColors—Record<string, string>: final host-resolved colours keyed by backend pivot column name. Read them throughresolveSeriesColor(context, column, index).valueColors—Record<string, Record<string, string>>: final host-resolved colours keyed by query field id then raw value. Read them throughresolveValueColor(context, fieldId, rawValue, index).pivotDetails— the complete backend-pivot layout, ornullfor ordinary rows. See "Backend-pivoted results" below.ready— false until the first context arrives.pointMenu— host-rendered data-point action menu for a clicked mark; this is the current data-point action contract. See "Data-point actions" below.underlyingData— host-mediated access to the raw rows behind a clicked data point; the fallback per-action dialog for hosts that predatepointMenu. See "Data-point actions" below.drillDown— host-mediated drill on a clicked data point; the fallback per-action dialog for hosts that predatepointMenu. See "Data-point actions" below.subtotals— aggregated rows for the levels of a declared hierarchy. Declarehierarchy: { field: "<input name>" }in the schema, naming a dimension input withmultiple: trueordered from the top level down.rowsstays at the most detailed level. Whensubtotals.enabled,subtotals.dimensionslists the bound field ids andawait subtotals.get({ level, parentValues })returns{ rows }for one level:level: 0withparentValues: []is the top level,level: 1with the raw value of one top-level group returns that group's children. Rows come back unsorted, one per group and one per series value when the result is pivoted. Subtotals belong to therowsthey were fetched for: refetch whenrowschange, handle a rejected promise, and render fromrowsalone whensubtotals.enabledis false.
Read all of them. Pass the complete context to the colour helpers; they preserve model
colours and shared dashboard assignments before falling back to colorPalette.
These app-level APIs do not apply to a viz
The sandbox skill (/app/skill.md) is written for data apps, which do run queries. A
reusable visualization does not. Do not use useLightdash(), filtersFor(EXPLORE),
addFilter({...}), or format(row, fieldName) — there is no explore to quer
Установить reusable-visualization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл reusable-visualization?
Build ONE reusable chart visualization component that receives its data and its settings from the host application instead of fetching them, and declares the fields and config options the host exposes to viewers. Use this whenever a single chart component is reused across many different queries rather than built for one — in Lightdash, the `data_app_viz` app template, also called a "viz". Covers the `useVizContext()` hook, the declaration contract, the config-option vocabulary, and series colours.
Как установить скилл reusable-visualization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл reusable-visualization запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic