UI Toolbox logoUI Toolbox
Support

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.

The six stats of a hero as a polygon, with the stats of a new helmet outlined for comparisonThe six stats of a hero as a polygon, with the stats of a new helmet outlined for comparison

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.
FormatString (format-string) 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 the curve of AnimationEasing. False makes the shape jump. Default true.
AnimationDuration (animation-duration) The time of the move, in milliseconds. Default 300. 0 makes the shape jump.
AnimationEasing (animation-easing) The curve of the move, one of the easing curves. Default OutCubic. With OutBack or OutElastic, the shape goes past the new values and comes back. It stays between the center and the tips.
Axes, AddAxis(text, value) The axes (a copy of the list), 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, and past them with a curve such as OutBack.

Animation

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

No data

A spider chart with no axes draws a faint web of two rings and spokes and a centered pill with the text "No data".

<tb:SpiderChart />
<tb:SpiderChart no-data-text="No stats yet" />
Member Description
NoDataText (no-data-text) The text of the pill. Empty (the default) shows the translated "No data" (the ToolboxText key tb.no-data, in nine languages), which follows a language change.
ShowNoData (show-no-data) True (the default) shows the faint shape and the pill. False leaves an empty chart.

In the examples

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-text-danger.

The SpiderChartDemo scene shows the stats of a hero with only the axes in the UXML, a skill wheel that adds and removes axes, a level up that previews a talent with the compare outline and the easing of the move, and three looks.