ChartGroup handbook
v0.4.3 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Combine charts in one area with shared category hover, overlaid drawing, and coordinated axes to compare related data.
When to use it
Use ChartGroup to coordinate charts under shared settings. Each child chart still owns its public data and visual props; do not modify private marks from the page.
Provide shared axis and interaction settings only. ChartGroup does not create charts, titles, or legends.
Compose BarChart and LineChart explicitly and coordinate their width, height, and position to share one canvas.
The default root accessible name follows LocaleProvider through
chartGroup.name; an explicitaria-labeltakes priority. The data-cell group useschartGroup.cells. When no corresponding xLabels entry is provided,chartGroup.celluses the complete{{index}}template with one-based numbering; explicit category names remain unchanged. Business names, data values, and numeric formatting remain controlled by the caller.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
HoverPanel shares a three-column layout. The dot-to-name gap prefers --gap-1 and the name-to-value gap prefers --gap-2; both retain a 4 CSS px floor in LTR and RTL. At a 16px root font size the defaults remain 4px / 8px, and larger tokens are preserved. This floor does not apply to vertical panel sections or chart center annotations.
Design principle
Chart composition host: ChartGroup coordinates axes and interaction state across chart components. It does not replace each chart’s public data and visual API.
Child charts remain independent: Pass each child its own data, colors, axes, and motion settings. ChartGroup does not copy private geometry.
Cell hover: When
hoverMode="cell", the container draws the classification cell hit layer on the top layer; each cell is based on the classification center, and the left and right half of the cell width, and the mouse enters the area to trigger the sharingactiveCellIndex.Coordinate axis control:
ChartGroupcan uniformly issue coordinate axis display, grid, auxiliary line, X/Y label thinning, Y axis domain / ticks / formatter and LineChart'sxAxisMode. When the sub-chart explicitly enters the prop of the same name, the sub-chart's own configuration is given priority.Responsive canvas: Root layer observes the final display size;
width="100%"/height="100%"share the hit layer and hover panel bounds to use the real canvas size.Complete classification semantics: ChartGroup always sends the complete
xLabelsand the complete classification cell to the subchart; the extraction is only performed by the subchart that actually draws the coordinate axis, without reducing the shared hit cell or active index range.Shared vertical boundary: The top uses the content-aware safe area; ChartGroup collects the graphics, marker and Y-axis requirements of the BarChart / LineChart sub-chart and takes the maximum value, so that all overlay layers and shared hit layers use the same top edge. The hover value does not increase the height of the shared top, and remains at
4pxabove the graphic. If necessary, it can overflow the top edge of the drawing area. Only the X-axis8pxspacing and16pxlabel height are reserved at the bottom.Overlay canvas: The root layer is a fixed-size canvas of
position: relative, and the sub-chart can be superimposed byclass="absolute top-0 left-0".Single axis renderer: In an overlay, let one child render axes and grid; disable duplicate axes, grid, and labels on the others.
No built-in business shell: No built-in title, card background, legend or toolbar; these are combined by external Frame / Card.
2.1 Props
The rest of the undeclared attributes will be passed to the root layer Frame.
2.2 Sub-chart protocol
ChartGroup exposes Chart to future generations through context:
Current access components:
BarChart: bars, segments, overlays, or grouped bars with the samegroupIndexrespond to a shared cell hover.LineChart: markers with the samepointIndexrespond to cell hover; their own transparent hit areas remain available.When
showHoverPanelis turned on, the sub-chart only reports the current hover panel data, andChartGrouprenders a shared panel uniformly; the sub-chart hides its own hover label by default, but it can still be displayed at the same time when explicitlyshowHoverLabel={true}.
Layout model
Main layout model: composite management layout.
The root layer is
Frame, which is used as a fixed-size combination canvas.The sub-chart is declared by the external explicit declaration level and positioning, and the common writing method is
absolute top-0 left-0.The shared cell hit layer is the SVG coverage layer of absolute positioning inside the container. By default, it is located above the sub-chart; each classification hit area is calculated according to the left and right half of the classification center.
Do not access the three-slot protocol, and do not undertake the title, description, legend or card layout.
See LayoutProtocol.md §12.6 for details (source code reference: specs/maintainers/LayoutProtocol.md).
Barrier-free integration with Frame
The root uses
role="group"and a locale-aware default accessible name ("Chart group" in en-US); an explicitaria-labeltakes priority.When the shared panel is not turned on and
hoverMode="cell",showHitLayer=true, each cell hit rect usesrole="button",tabindex="0"and classification label asaria-label.loadingretains the combination canvas, shared coordinates and sub-diagram nodes; the root Frame explicitly closes the Skeleton, and the sub-diagram synchronously restores to the starting point of the dynamic effect through the loading context.The explicit input
enableResponsive/enableContext/enableScaleObserver/enableDefaultMotion.class,styleand undeclared attributes are transmitted to the root Frame.
Give a demonstration
ChartGroup style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
ChartGroup type and status
Required Props: no named required Props.
Bindable Props: this component declares no named two-way binding; handle state updates through public callbacks or its host.
Inheritance statement: Omit<FrameProps, "children" | "skeleton" | "renderHints">. The inheritance ability is subject to the public document of the base class; the fields in Omit have been excluded and cannot be used as they are according to the base class.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
ChartGroupXAxisMode
Source: components/src/lib/chart/group-context.ts
ChartGroupPlotBounds
Source: components/src/components/ChartGroup.svelte
ChartGroupHoverMode
Source: components/src/lib/chart/group-context.ts
ChartHoverPanelVariant
Source: components/src/lib/chart/hover-panel.ts
ChartHoverPanelPlacement
Source: components/src/lib/chart/hover-panel.ts