Skip to content

XRadar — Radar Chart ​

A hand-rolled SVG radar chart component, zero third-party dependencies (no ECharts / Canvas library needed). Supports custom dimension data, grid levels, and color themes; works for both single-series and multi-series comparisons.

Live Demo ​

VueReactTypeScriptNode.jsCSSWebpackVue:95React:85TypeScript:90Node.js:80CSS:92Webpack:75
vue
<XRadar :data="[
  { name: 'Vue', value: 95 },
  { name: 'React', value: 85 },
  { name: 'TypeScript', value: 90 },
  { name: 'Node.js', value: 80 },
  { name: 'CSS', value: 92 },
  { name: 'Webpack', value: 75 }
]" />

Uses default 6-dimension data when data is not provided.

Props ​

PropTypeDefaultDescription
data{ name, value }[]—Dimension data array
sizenumber300Container width & height (px), square
levelsnumber5Number of grid levels
nameGapnumber12Gap (px) between labels and the radar edge
areaColorstring'rgba(64,158,255,0.3)'Data area fill color
lineColorstring'#409eff'Data area stroke color
pointColorstring'#409eff'Data point color
pointRadiusnumber4Data point radius (px)
lineWidthnumber2Data stroke width (px)
labelColorstring'#666666'Dimension label color
labelFontSizenumber13Dimension label font size (px)
gridColorstring'#e4e7ed'Grid and radial line color
seriesObject[][]Multi-series comparison; takes priority over data when provided, auto-generates a legend and assigns colors
maxnumbernullAxis maximum; when omitted, uses the larger of the data maximum and 100

Multi-series Comparison ​

vue
<XRadar :series="[
  { name: 'Current', data: [{ name: 'Performance', value: 90 }, { name: 'Usability', value: 80 }] },
  { name: 'Competitor', data: [{ name: 'Performance', value: 75 }, { name: 'Usability', value: 85 }] }
]" />

Usage Notes ​

  • Purely SVG-based — no need to install echarts.
  • Dimensions are laid out clockwise starting from the top (12 o'clock).
  • Pure vector rendering, adapts to the container, no ResizeObserver needed.
  • Hovering a data point enlarges it and shows a "dimension: value" tooltip (native <title>).

基于 VitePress + Vue 3 构建