Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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 with multiple: true map to ordered arrays. Narrow with Array.isArray(binding) before iterating. Read each id with getFormatted(row, fieldId) (display text) and getRaw(row, fieldId) (raw value).
  • fields — Record<string, { label, tableLabel?, format? }>: display metadata for each bound query field id. Name fields with getFieldLabel(context, fieldId) — the field's label ("Total revenue"), or the raw id only when the host sent no metadata. format is the semantic-layer format (type such as currency/percent/number, plus round, currency, compact, prefix, suffix) for formatters that have no cell to hand, such as axis ticks; per-value text still comes from getFormatted.
  • 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 declared default).
  • colorPalette — string[]: the Lightdash palette resolved for this chart. Always pushed, whether or not you declared colorPalette. Empty only when the host resolved none.
  • seriesColors — Record<string, string>: final host-resolved colours keyed by backend pivot column name. Read them through resolveSeriesColor(context, column, index).
  • valueColors — Record<string, Record<string, string>>: final host-resolved colours keyed by query field id then raw value. Read them through resolveValueColor(context, fieldId, rawValue, index).
  • pivotDetails — the complete backend-pivot layout, or null for 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 predate pointMenu. See "Data-point actions" below.
  • drillDown — host-mediated drill on a clicked data point; the fallback per-action dialog for hosts that predate pointMenu. See "Data-point actions" below.
  • subtotals — aggregated rows for the levels of a declared hierarchy. Declare hierarchy: { field: "<input name>" } in the schema, naming a dimension input with multiple: true ordered from the top level down. rows stays at the most detailed level. When subtotals.enabled, subtotals.dimensions lists the bound field ids and await subtotals.get({ level, parentValues }) returns { rows } for one level: level: 0 with parentValues: [] is the top level, level: 1 with 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 the rows they were fetched for: refetch when rows change, handle a rejected promise, and render from rows alone when subtotals.enabled is 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

Полный SKILL.md на GitHub

Установить 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), без исполняемых скриптов.

Похожие скиллы

Сравнить reusable-visualization с