Z-Index and Layers
SVG elements don't support CSS z-index. Instead, rendering order is determined by document order — elements rendered later appear on top. vccs manages this with a layer system.
Default rendering order
Chart elements are rendered in this order (bottom to top):
<CartesianGrid>— grid lines (background)<ReferenceArea>/<ReferenceLine>— reference markers<Area>— filled area regions<Bar>— bar rectangles<Line>— line curves<Scatter>— scatter dots- Labels (
<LabelList>) - Tooltip cursor
<Tooltip>— tooltip (HTML overlay, above SVG)<Legend>— legend (HTML)
Teleport layer system
vccs uses Vue's <Teleport> to enforce consistent layering. The <Surface> component creates three SVG <g> layer refs:
- Graphical layer — where
Area,Line,Radarrender their paths - Label layer — where
LabelListrenders labels - Cursor layer — where tooltip cursors render
Components like <Area> and <Line> teleport their output into the graphical layer, ensuring they render in the correct z-order regardless of where they appear in your template.
Controlling overlap
When elements overlap, the rendering order above determines which appears on top. To change the visual stacking:
Reorder in template: Components rendered later in your template appear on top within the same layer:
<!-- Area renders behind Line -->
<ComposedChart :data="data">
<Area data-key="area" fill="#14b8a6" :fill-opacity="0.3" />
<Line data-key="line" stroke="#f97316" />
</ComposedChart>
Use ComposedChart for mixed types: <ComposedChart> lets you combine <Area>, <Bar>, and <Line> in a single chart with explicit ordering: