developing-chart-types-locally
Skill này làm gì
Skill này hướng dẫn chỉnh sửa một loại biểu đồ tùy chỉnh được tạo hoặc tải về bằng Lightdash CLI. Skill dành cho lập trình viên xây dựng thành phần hiển thị riêng cho Lightdash.
Khi nào nên dùng
- ✓Khi bạn muốn chỉnh sửa một loại biểu đồ tùy chỉnh đã tạo bằng Lightdash CLI.
- ✓Khi bạn cần tải một loại biểu đồ lên và kiểm tra xem nó hoạt động.
- ✓Khi bạn muốn xem trước loại biểu đồ trên máy với dữ liệu mẫu.
Liên kết skill
https://github.com/lightdash/lightdash/blob/main/packages/cli/src/handlers/apps/authoring/developing-chart-types-locally/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Chỉnh sửa loại biểu đồ bong bóng tùy chỉnh của tôi để hiển thị chú giải bên phải, rồi tải lên và kiểm tra xem nó hoạt động.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill giải thích các quy tắc mà một thành phần biểu đồ phải tuân theo, chẳng hạn chỉ lấy dữ liệu từ host. Sau đó skill hướng dẫn các bước tải lên và kiểm tra, cùng bản xem trước cục bộ với dữ liệu mẫu.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Một loại biểu đồ có thể tự chạy truy vấn không?
Không. Skill nêu rõ loại biểu đồ lấy dữ liệu từ Lightdash và không tự chạy truy vấn.
Tôi xem trước loại biểu đồ bằng cách nào?
Skill mô tả một bản xem trước cục bộ dùng dữ liệu mẫu có sẵn.
Còn các API bên ngoài thì sao?
Các yêu cầu đến bên ngoài đi qua một kết nối đã liên kết, do quản trị viên thiết lập trong dự án.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 6.2k
- Vị trí xếp hạng
- #14402
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
breakup-pr
6.2kGiúp agent của bạn tách một pull request lớn thành các phần nhỏ, xếp chồng lên nhau, để có thể xem xét và gộp từng phần một.
lightdash-agent-slack-messaging
6.2kGiúp agent của bạn viết báo cáo bảo trì và hoạt động cho quản trị viên Lightdash rõ ràng, thân thiện, chỉ dựa trên bằng chứng có sẵn.
developing-in-lightdash
6.2kGiúp agent của bạn đọc, tạo và chỉnh sửa dashboard và biểu đồ Lightdash dưới dạng JSON, kèm cài đặt của từng loại biểu đồ.
filter-expressions
6.2kGiúp agent của bạn viết biểu thức lọc đúng cho truy vấn số liệu Lightdash, kể cả lọc trên các chỉ số tùy chỉnh.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.