developing-chart-types-locally
它能做什么
这项技能指导编辑使用 Lightdash CLI 创建或下载的自定义图表类型。适合为 Lightdash 构建自己视觉组件的开发者。
适用场景
- ✓当你想编辑用 Lightdash CLI 创建的自定义图表类型时。
- ✓当你需要上传图表类型并检查其能否正常工作时。
- ✓当你想用示例数据在本地预览图表类型的时候。
技能链接
https://github.com/lightdash/lightdash/blob/main/packages/cli/src/handlers/apps/authoring/developing-chart-types-locally/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请编辑我的自定义气泡图类型,让图例显示在右侧,然后上传并检查它是否正常工作。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能说明图表组件必须遵循的规则,例如只能从宿主获取数据。然后它指导上传和验证步骤,以及使用测试数据进行本地预览。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Developing Lightdash Custom Chart Types Locally
You are editing a Lightdash custom chart type (a reusable visualization, the data_app_viz template) that was created or downloaded with the Lightdash CLI. It is ONE chart component that Lightdash hands data and settings to — not a data app.
The contract is the reusable-visualization skill
Read the reusable-visualization skill before editing. It defines everything the component may do: useVizContext() is the only channel to the host for data, options and resolved colours; the component runs no query and owns no explore. App-level query APIs (query builder, useLightdash, filters) do not apply here and must not be introduced.
Never hand-build a data-point action menu when useVizContext().pointMenu.enabled — call pointMenu.open({ x, y, row, metric }) and let Lightdash render it; an in-viz menu is only the fallback for hosts that predate the capability.
External HTTP APIs go through linked connections
A chart type's rows always come from useVizContext(). Anything else it needs from outside Lightdash, such as reference data from a third-party API or images from a URL, goes through an external connection, the same way it does for data apps.
- The one sanctioned path to a third-party API is
client.externalFetch('<alias>', ...), with the client fromuseLightdashClient(), against an external connection a project admin configured and linked to this chart type. Do not add directfetchor REST calls; the sandbox blocks them. - Images load only from a linked connection that has public images enabled, from its exact origin. Never put Lightdash data in an image URL.
- Links are declared in this folder's
lightdash-app.ymlunderexternalConnections(- alias: stripe/connectionSlug: stripe-api). When the key is present, upload reconciles the chart type's links to match it exactly, so to link a connection that already exists in the project, add its{alias, connectionSlug}entry and upload. Do not remove entries casually: an entry removed from the list (or an empty list) unlinks on upload, and a manifest without the key leaves links unchanged. - Watch the upload output: a
connectionSlugthat doesn't exist in the target project is skipped with a warning (the chart type uploads, butexternalFetchon that alias fails at runtime). If a link is skipped or forbidden, report it to the user instead of retrying. - If the chart type needs an API with no existing connection, stop and say so. An admin must create the connection first; then it can be linked via the manifest as above.
- Connections are not emulated by the local fixture preview. Test them after upload, in the explorer.
The declaration lives in lightdash-app.yml — keep it in lockstep
In the in-product builder the declaration is emitted by the generation run; locally it is the vizSchema block in this folder's lightdash-app.yml, and upload round-trips it to the server (without it the chart type never appears in the explorer's chart type picker).
The correspondence must be exact in both directions: every key the component reads from fieldMapping or options is declared in vizSchema, and everything declared there is read by the component. When an edit changes what the component reads — a new field, a renamed option, a removed control — update vizSchema in the same edit. A declared option nothing reads is a dead control; a read key nothing declares never receives a value.
The edit → validate → upload → verify loop
Run these commands from this folder under chart-types/<slug>/. The upload path ../.. selects the Lightdash content root.
- Edit files under
src/(andvizSchemawhen the declaration changes). lightdash apps validatechecks source and manifest (including thatvizSchemaparses);lightdash apps validate --buildadds the Cloud-parity Vite production build. A build failure is a validation error with the Vite output.lightdash upload --chart-types <slug> --path ../..(theslugfromlightdash-app.yml) — the server rebuilds and serves it.- Verify in Lightdash: open any explore, run a query with at least the required fields' shapes (e.g. a dimension and a metric), pick this chart type in the chart type picker, and map its fields. Check every config option you declared actually changes the chart.
Saved charts already using this chart type may pin a version; unpinned charts move to the newly uploaded version right away. W
常见问题
图表类型可以运行自己的查询吗?
不可以。技能说明,图表类型从 Lightdash 获取数据,不运行自己的查询。
我如何预览它?
技能描述了一种使用示例测试数据的本地预览。
外部 API 呢?
外部请求通过项目管理员配置的已链接连接进行。
详情
作者的原始描述
Use when editing a locally created or downloaded Lightdash custom chart type (data_app_viz) — the vizSchema/component lockstep contract, the upload-and-verify loop, the local fixture preview, and how a chart type reaches the official registry.
repo: lightdash/lightdash
热度
- GitHub 星标
- 6.2k
- 排名
- #14402
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
breakup-pr
6.2k帮你的智能体把一个大型拉取请求拆分成较小的、可堆叠的切片,每次可以审阅并合并一个。
lightdash-agent-slack-messaging
6.2k帮你的智能体根据现有证据,为 Lightdash 管理员撰写简短、友好的维护与活动报告。
developing-in-lightdash
6.2k帮你的智能体以 JSON 形式读取、创建和编辑 Lightdash 仪表板与图表,包括每种图表类型的设置。
filter-expressions
6.2k帮你的智能体为 Lightdash 指标查询编写正确的筛选表达式,包括针对自定义指标的筛选。