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.
67
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./plugins/build-web-data-visualization/skills/canvas2d-data-visualization/SKILL.mdUse 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.
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.
style.width and style.height in CSS pixelscanvas.width and canvas.height attributes to cssSize * pixelRatioglobalThis.devicePixelRatio || 1 as the page-zoom-aware ratiovisualViewport.scale only when deliberately redrawing for pinch-zoom crispnessctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0) so drawing code can stay in CSS pixelsPath2D geometry replay against candidate subsets with isPointInPath() and isPointInStroke()PointerEvent.clientX/clientY through getBoundingClientRect()setPointerCapture() for drags so movement continues outside the canvaspointerup, pointercancel, and lostpointercapturetouch-action deliberately for touch and pen surfacesThis is usually better than forcing all responsibilities into Canvas. Use absolutely positioned HTML overlays for elements that need native layout, selection, input, focus rings, links, or accessible semantics; keep them synchronized by deriving every overlay position from the same world-to-screen transform used by the Canvas renderer. For sparklines and other microcharts, nearby row labels, headers, and inline values usually work better than a shared detached legend.
OffscreenCanvas and workers when main-thread contention is significantwidth * height * pixelRatio^2 * 4 * layerCount * instanceCountgetContext("2d", { willReadFrequently: true }) only for canvases that repeatedly call getImageData(), such as color-picking buffersgetImageData() readback cost, and when the buffer invalidates.devicePixelRatio, and redraw invalidation are handled.../../references/foundations/perception-color-and-encoding.md../../references/foundations/mobile-first-responsive-visualization.md../../references/foundations/domain-contextual-surfaces.md../../references/foundations/implementation-design-and-tradeoffs.md./references/rendering-architecture.md./references/high-density-interaction.md./references/performance-playbook.md./references/sparklines-and-microcharts.md11c74d6
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.