zWebUI
v0.1.0 中 Dark

z-chart

Chart component family: bar, line, area, pie, donut, radar, sparkline and GeoJSON choropleth map. SVG and Canvas dual engines, tooltip, legend and enter animations.

Bar

Bar chart with legend toggle, hover tooltip, canvas rendering and mixed bar+line dual-axis series.

Categories

Show Code
<z-chart type="bar" title="Monthly Revenue" width="620" height="300">
  <z-chart-axis position="bottom" type="category" title="Month"></z-chart-axis>
  <z-chart-axis position="left" type="value" format="currency"></z-chart-axis>
  <z-chart-series name="Online"></z-chart-series>
  <z-chart-series name="Retail"></z-chart-series>
  <z-chart-series name="Wholesale"></z-chart-series>
</z-chart>
// data 是 DOM property(attribute 不生效),需 JS 设置:
const series = document.querySelector("z-chart-series");
series.data = [{ label: "Jan", value: 4200 }, { label: "Feb", value: 5100 }];

Mixed Series & Dual Axis

Rendered with the canvas engine
Show Code
<z-chart type="bar" title="Revenue vs Growth" width="620" height="300" renderer="canvas">
  <z-chart-axis position="bottom" type="category" title="Quarter"></z-chart-axis>
  <z-chart-axis position="left" type="value" title="Revenue" format="currency"></z-chart-axis>
  <z-chart-axis position="right" type="value" title="Growth %" format="percent"></z-chart-axis>
  <z-chart-series name="Revenue" type="bar"></z-chart-series>
  <z-chart-series name="Growth" type="line" y-axis="right"></z-chart-series>
</z-chart>

Line & Area

Trend charts with enter animation. Click the legend to hide series.

Show Code
<z-chart type="line" title="Weekly Active Users" width="620" height="260">
  <z-chart-axis position="bottom" type="category" title="Week"></z-chart-axis>
  <z-chart-axis position="left" type="value"></z-chart-axis>
  <z-chart-series name="Desktop"></z-chart-series>
  <z-chart-series name="Mobile"></z-chart-series>
</z-chart>
// 数字数组也可直接作为 series.data:
series.data = [12, 18, 16, 24, 22, 30, 28, 36];
Show Code
<z-chart type="area" title="Downloads" width="620" height="260">
  <z-chart-series name="App Store"></z-chart-series>
  <z-chart-series name="Google Play"></z-chart-series>
</z-chart>
// 不写 z-chart-axis 时自动生成分类 x 轴与数值 y 轴

Pie & Donut

Share of total. Donut shows the total in the center; the canvas renderer falls back to SVG.

Show Code
<z-chart type="pie" title="Traffic Sources" width="340" height="300">
  <z-chart-series name="Traffic"></z-chart-series>
</z-chart>
// 饼图仅支持 SVG 渲染(renderer="canvas" 自动回退)
series.data = [{ label: "Organic", value: 45 }, { label: "Paid", value: 25 }];
Show Code
<z-chart type="donut" title="Budget Allocation" width="340" height="300">
  <z-chart-series name="Budget"></z-chart-series>
</z-chart>
// type="donut" 时中心显示合计;环形图仅支持 SVG 渲染(canvas 自动回退)
series.data = [{ label: "Engineering", value: 320 }, { label: "Marketing", value: 180 }];

Radar

Multi-axis profile. Each axis is normalized by the largest value across series, so axes can carry different units (¥, cups, %). Series sharing an axis must be the same metric (store vs region average, this year vs last) — two different metrics in one radar squash the smaller one. Fewer than 3 axes is treated as no data.

Show Code
<z-chart type="radar" title="Store Profile: Binjiang vs Region Average" width="440" height="360">
  <z-chart-series name="滨江店"></z-chart-series>
  <z-chart-series name="区域均值"></z-chart-series>
</z-chart>
// 每个系列一组 {label, value};label 即轴名,各系列顺序必须一致
shop.data = [{ label: "营业额", value: 128000 }, { label: "出杯量", value: 820 }, { label: "客单价", value: 32.5 }, { label: "实收率", value: 0.86 }, { label: "复购率", value: 0.42 }, { label: "达成率", value: 1.08 }];
// 逐轴归一:每根轴的分母是「所有系列在该轴上的最大值」→ 顶点越靠外 = 该轴越强
// 系列必须是同一指标的不同主体(本店 vs 区域均值);销售额与订单数混在一张雷达里,小的会被压到圆心
Show Code
<z-chart type="radar" title="Store Inspection Score" width="400" height="340">
  <z-chart-series name="巡检得分"></z-chart-series>
</z-chart>
// 单系列:分母取「全图最大值」(此处 92)—— 最外圈是它,不是满分 100
series.data = [{ label: "服务", value: 92 }, { label: "出杯速度", value: 78 }, { label: "卫生", value: 85 }, { label: "陈列", value: 66 }, { label: "客诉处理", value: 88 }];

Sparkline

Compact single-series trend, ideal for CPU and latency monitoring.

Show Code
<z-chart type="sparkline" title="CPU %" width="280" height="48" legend="false" show-grid="false">
  <z-chart-series name="CPU"></z-chart-series>
</z-chart>
// 迷你图默认高度 48px,单系列折线 + 渐变填充
series.data = [22, 18, 25, 30, 28, 35, 32, 40];
Show Code
<z-chart type="sparkline" title="Latency (ms)" width="280" height="48" legend="false" show-grid="false">
  <z-chart-series name="Latency"></z-chart-series>
</z-chart>
// 迷你图只画单系列,适合 CPU/延迟等指标监控
series.data = [120, 95, 110, 88, 130, 105, 92, 118];

Map

GeoJSON choropleth: pass your own GeoJSON, region values drive the color scale.

Show Code
<z-chart type="map" title="Regional Sales" width="620" height="360"></z-chart>
// geojson / values 是 DOM property(attribute 不生效),需 JS 设置:
chart.geojson = { type: "FeatureCollection", features: [...] };
chart.values = { north: 1200, east: 3400, south: 2100, west: 980, center: 2600 };

API Reference

Properties

Property Type Default Description
typestring"bar"Chart type: bar, line, area, pie, donut, sparkline, map
rendererstring"svg"Render engine: svg or canvas (pie/donut/sparkline always SVG)
width / heightstring"auto"Size: "auto" or a pixel string like "600"
titlestring""Chart title (also used as aria-label)
legendbooleantrueShow legend
tooltipbooleantrueEnable hover tooltip
animationbooleantrueEnter animation (respects prefers-reduced-motion)
show-gridbooleantrueShow grid lines
localestring"en-US"Locale for number and date formatting
colorsstring[]nullCustom categorical palette (hex array)
geojsonobjectnullGeoJSON FeatureCollection for choropleth map
valuesobject | arraynullRegion values: {id: value} or [{id, value}]
projectionstring"auto"Map projection: auto, equirectangular, mercator, none
map-id-keystring"id"Property key used to match region id with values
map-name-keystring"name"Property key used as region display name

z-chart-series (child element)

Property Type Description
namestringSeries display name (legend and tooltip)
typestringSeries kind: auto (inherits chart type), bar, line, area
dataarraySeries data: numbers, {value}, {label, value} or {x, value}
colorstringSeries color (defaults to the categorical palette)
y-axisstringBind to left or right axis
formatstringValue format: "auto", "percent", "currency" or a template with {value}
visiblebooleanSeries visibility (toggled by the legend)

z-chart-axis (child element)

Property Type Description
positionstringAxis position: bottom (x), left (y), right (secondary y)
typestringAxis kind: auto, category, value, time
titlestringAxis title
min / maxnumberExplicit min / max (only applied when the attribute is present)
tick-countnumberApproximate tick count (0 = automatic)
gridbooleanOverride the chart show-grid for this axis

Events

EventDetailDescription
z-ready{ type, width, height }Fired once after first layout
z-resize{ width, height }Fired when the chart size changes
z-tooltip-change{ visible, seriesIndex, dataIndex, label, values }Fired when tooltip shows/hides
z-series-toggle{ index, name, visible, hidden }Fired when a legend item is toggled
z-marker-click{ seriesIndex, dataIndex, value, formatted }Fired when a data marker is clicked