canvas2d-data-visualization
БесплатноБез исполняемых скриптовНе проверенRender data visualizations with Canvas2D. Use when the visualization needs high mark counts, fast redraws, immediate-mode rendering, custom hit testing, or a…
от openai★ 8 494 звезды на GitHubОб этом скилле
Canvas2D Data Visualization
Overview
Use this skill when raster rendering is the practical choice. Canvas2D is strong for dense scatterplots, sparkline walls, heatmaps, streaming traces, tiled timelines, draggable analytical workspaces, and other views where SVG or DOM overhead becomes the limiting factor.
Default assumption: keep a retained scene model in application state even if the actual drawing is immediate-mode Canvas. Any visualization or interaction that can be built in SVG can usually be built in Canvas2D too, but the retained geometry, hit testing, focus model, and accessibility layer become the application's responsibility. Choose Canvas for performance or rendering control; keep SVG/HTML when native DOM semantics, text, accessibility, or exportability matter more than redraw speed. Canvas2D can also be simpler or faster than WebGL for flat immediate-mode workloads because it avoids shader setup, buffer uploads, GPU context pressure, and custom WebGL lifecycle code. Move from Canvas2D to WebGL when GPU picking, shader effects, particle count, custom blending, smooth animation, true 3D, or high-volume geospatial layers justify that extra complexity.
For browser-facing Canvas work, use ../../references/foundations/mobile-first-responsive-visualization.md so backing-store size, hit testing, touch gestures, keyboard overlays, spotty connection states, and mobile performance budgets are part of the design contract.
Choose Canvas2D When
- the chart needs tens of thousands to millions of marks
- panning or zooming must feel fluid
- the view updates continuously
- the page needs many repeated microcharts such as sparklines in tables or KPI grids
- many chart instances are visible at once and SVG node count would dominate layout, style, and memory cost
- marks need custom clickable, hoverable, brushable, or draggable behavior over dense geometry
- you can tolerate raster output or provide separate export paths
- the chart benefits from layered drawing control, including static contextual backgrounds behind dense marks
Prefer SVG, HTML, or a declarative grammar when the chart is small, static, text-heavy, annotation-heavy, primarily accessibility-driven, or needs straightforward copy/paste/editable-vector export. Prefer WebGL or the Three.js/WebGL skill when the chart needs GPU-scale particles, custom shaders, instancing, very large graph or point layers, 3D, or map overlays that Canvas2D would struggle to animate or pick interactively.
Core Practices
- Scale the backing store for browser zoom and high-DPI output:
- set CSS
style.widthandstyle.heightin CSS pixels - set the
canvas.widthandcanvas.heightattributes tocssSize * pixelRatio - use
globalThis.devicePixelRatio || 1as the page-zoom-aware ratio - consider
visualViewport.scaleonly when deliberately redrawing for pinch-zoom crispness - reset the context with
ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0)so drawing code can stay in CSS pixels
- set CSS
- Keep world-to-screen transforms explicit.
- Use layered canvases for:
- static background, including any field, court, floor plan, schematic, or other contextual surface
- primary marks
- highlight or hover state
- interaction overlays
- Avoid full redraws when partial invalidation is possible.
- Build deterministic hit testing:
- spatial index
- color picking buffer
- nearest-point search
Path2Dgeometry replay against candidate subsets withisPointInPath()andisPointInStroke()- analytic tests for simple shapes such as points, line segments, rectangles, intervals, and bands
- Assess how many Canvas instances may be visible at once, because backing-store size and redraw cost multiply quickly at dashboard scale.
- Treat pointer interaction as a first-class subsystem:
- normalize
PointerEvent.clientX/clientYthroughgetBoundingClientRect() - invert the current pan/zoom transform before mapping to data coordinates
- use
setPointerCapture()for drags so movement continues outside the canvas - clean up drag state on
pointerup,pointercancel, andlostpointercapture - use
touch-actiondeliberately for touch and pen surfaces - provide non-drag alternatives and enlarged invisible hit regions for small marks on coarse pointers
- keep keyboard and screen-reader affordances in HTML when Canvas marks are semantically important
- normalize
- For mobile, define whether one-finger drag pans the chart or scrolls the page, whether pinch zoom is chart-owned or browser-owned, and how reset or explicit zoom controls work.
Hybrid Architecture
- Canvas for bulk marks
- SVG or HTML for axes, labels, legends, rich tooltips, menus, form controls, keyboard focus, and annotations
- shared scales and transforms across both layers
This is usually better than forcing all responsibilities into Canvas. Use absolutely positioned HTML overlays for elements that need native layout, selection, input, focus ri
Установить canvas2d-data-visualization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл canvas2d-data-visualization?
Render data visualizations with Canvas2D. Use when the visualization needs high mark counts, fast redraws, immediate-mode rendering, custom hit testing, or a hybrid Canvas plus SVG or HTML architecture.
Как установить скилл canvas2d-data-visualization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл canvas2d-data-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