UI Toolbox logoUI Toolbox

SpiderChart

SpiderChart in UIToolbox is a radar chart of stats, as on a character sheet. Each SpiderAxis is a spoke from the center. The first axis points up, and the others follow clockwise. The chart fills a polygon through the values. With ShowCompare, it also outlines the Compare values, for example the stats with an item tried on. The Character sheet example uses it.

Video tutorial: Spider chart. All videos: Video tutorials.

<tb:SpiderChart name="stats" max-value="20" rings="4">
    <tb:SpiderAxis text="Strength" />
    <tb:SpiderAxis text="Agility" />
    <tb:SpiderAxis text="Vitality" />
</tb:SpiderChart>
var luck = chart.AddAxis("Luck", 3);
luck.Compare = 5;
chart.ShowCompare = true;
Member Description
MaxValue (max-value) The value at the tip of a spoke. Default 10. A larger value stops at the tip.
Rings (rings) The number of grid rings. Default 4.
LabelSpace (label-space) The pixels between the tips and the sides of the chart, for the axis labels. Default 48.
ShowCompare (show-compare) True outlines the Compare values, and each axis shows "value → compare" where the two differ.
ValueFormat (value-format) The number format of the values. Default "0".
Animate (animate) True moves the shape and the compare outline from the old values to the new values, with an ease-out. False makes the shape jump. Default true.
AnimationDuration (animation-duration) The time of the move, in milliseconds. Default 300. 0 makes the shape jump.
Axes, AddAxis(text, value) The axes, clockwise from the top. A child SpiderAxis in UXML is an axis too.
AxisPoint(index, value) The local point of a value on an axis.
SpiderAxis.Text, Value, Compare The label, the value and the compare value. A change draws the chart again.
SpiderAxis.ValueText The value text that the axis shows.
SpiderAxis.ShownValue, ShownCompare The values that the shape shows now. During a move, they go from the old values to Value and Compare.

Animation

<tb:SpiderChart name="weapons" animate="true" animation-duration="600" />

Styling

Class Element
tb-spider-chart The chart: 300 px. The variables are --tb-spider-chart-grid, the rings and the spokes (--tb-color-border); --tb-spider-chart-fill, the value polygon (--tb-color-preview); --tb-spider-chart-line, its outline (--tb-color-accent); and --tb-spider-chart-compare, the compare outline (--tb-color-warning).
tb-spider-chart__axes The layer of the axes. It fills the chart and has no look of its own.
tb-spider-chart__axis An axis, centered past the tip of its spoke with translate: -50% -50%.
tb-spider-chart__axis-label The axis label, in --tb-color-text-muted.
tb-spider-chart__axis-value The value, or "value → compare": bold, --tb-color-text.
tb-spider-chart__axis-value--up A value under its compare value: --tb-color-success.
tb-spider-chart__axis-value--down A value over its compare value: --tb-color-danger.