Radar Chart
<wa-radar-chart>
Radar charts compare multiple variables at once by plotting data on a radial grid. They are well-suited for comparing profiles across several dimensions, such as skill assessments, product attributes, or performance metrics.
<wa-radar-chart id="radar-hero" label="Employee Skills" description="A radar chart comparing skill levels across six categories"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-hero'); chart.config = { data: { labels: ['Communication', 'Technical', 'Leadership', 'Creativity', 'Teamwork', 'Problem Solving'], datasets: [{ label: 'Alice', data: [85, 92, 70, 88, 95, 78], fill: true, backgroundColor: 'color-mix(in srgb, var(--wa-color-red-60) 20%, transparent)', borderColor: 'var(--wa-color-red-60)' }, { label: 'Bob', data: [72, 78, 90, 65, 80, 88], fill: true, backgroundColor: 'color-mix(in srgb, var(--wa-color-blue-60) 20%, transparent)', borderColor: 'var(--wa-color-blue-60)' }] } }; </script>
For advanced configuration such as custom plugins and direct Chart.js access, see <wa-chart>.
Examples
Jump to heading
Providing Data with JavaScript
Jump to heading
For dynamic data, set the config property directly. The chart will re-render automatically.
<wa-radar-chart id="radar-js-example" label="Feature Comparison" description="A radar chart comparing product features"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-js-example'); chart.config = { data: { labels: ['Speed', 'Reliability', 'Ease of Use', 'Features', 'Support'], datasets: [{ label: 'Product A', data: [85, 90, 75, 80, 70] }] } }; </script>
Note that config is shallowly reactive. If you mutate the existing object in place, you must reassign it to trigger a re-render!
Providing Data with JSON
Jump to heading
Place a <script type="application/json"> tag inside the component with your chart data. Each value in the data array maps to a label on the radial axis.
<wa-radar-chart label="Feature Comparison" description="A radar chart comparing features of a product across five dimensions"> <script type="application/json"> { "data": { "labels": ["Speed", "Reliability", "Ease of Use", "Features", "Support"], "datasets": [{ "label": "Product A", "data": [85, 90, 75, 80, 70] }] } } </script> </wa-radar-chart>
Multiple Datasets
Jump to heading
Add multiple datasets to overlay profiles for direct comparison.
<wa-radar-chart id="radar-multi" label="Product Comparison" description="A radar chart comparing two products across several dimensions"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-multi'); chart.config = { data: { labels: ['Speed', 'Reliability', 'Ease of Use', 'Features', 'Support', 'Value'], datasets: [ { label: 'Product A', data: [85, 90, 75, 80, 70, 88] }, { label: 'Product B', data: [70, 80, 90, 85, 92, 75] } ] } }; </script>
Custom Colors
Jump to heading
Override the default color palette using the --fill-color-* and --border-color-* CSS custom properties on the component.
<wa-radar-chart id="radar-colors" label="Custom Colors" description="A radar chart with custom colors" style=" --fill-color-1: color-mix(in srgb, var(--wa-color-purple-60) 50%, transparent); --border-color-1: var(--wa-color-purple-60); --fill-color-2: color-mix(in srgb, var(--wa-color-orange-60) 50%, transparent); --border-color-2: var(--wa-color-orange-60); " > </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-colors'); chart.config = { data: { labels: ['Offense', 'Defense', 'Speed', 'Stamina', 'Technique'], datasets: [ { label: 'Player A', data: [90, 65, 80, 75, 85] }, { label: 'Player B', data: [70, 88, 92, 80, 72] } ] } }; </script>
Border Width
Jump to heading
Use the --line-border-width CSS custom property to control the thickness of the radar lines.
<wa-radar-chart id="radar-border" style="--line-border-width: 4px" label="Thick Lines" description="A radar chart with thicker lines"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-border'); chart.config = { data: { labels: ['A', 'B', 'C', 'D', 'E'], datasets: [{ label: 'Values', data: [80, 60, 90, 70, 85] }] } }; </script>
Point Radius
Jump to heading
Use the --point-radius CSS custom property to control the size of the dots drawn at each vertex. Set it to 0 to hide them entirely.
<wa-radar-chart id="radar-points" style="--point-radius: 6px" label="Large Points" description="A radar chart with larger vertex dots"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-points'); chart.config = { data: { labels: ['A', 'B', 'C', 'D', 'E'], datasets: [{ label: 'Values', data: [80, 60, 90, 70, 85] }] } }; </script>
Filled Areas
Jump to heading
Set fill to true on each dataset to fill the area under the radar lines. This makes it easier to see the overall shape and overlap of each profile.
<wa-radar-chart id="radar-filled" label="Team Assessment" description="A filled radar chart comparing two team members across skill areas"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-filled'); chart.config = { data: { labels: ['Frontend', 'Backend', 'DevOps', 'Testing', 'Design', 'Communication'], datasets: [ { label: 'Alice', data: [90, 75, 60, 80, 85, 92], fill: true, backgroundColor: 'color-mix(in srgb, var(--wa-color-red-60) 20%, transparent)', borderColor: 'var(--wa-color-red-60)' }, { label: 'Bob', data: [70, 92, 85, 88, 60, 78], fill: true, backgroundColor: 'color-mix(in srgb, var(--wa-color-blue-60) 20%, transparent)', borderColor: 'var(--wa-color-blue-60)' } ] } }; </script>
Legend
Jump to heading
Use the legend-position attribute to control where the legend appears. Add without-legend to hide it entirely.
<wa-radar-chart id="radar-legend" legend-position="bottom" label="Legend at Bottom" description="A radar chart with the legend at the bottom"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-legend'); chart.config = { data: { labels: ['Strength', 'Agility', 'Intelligence', 'Wisdom', 'Charisma'], datasets: [ { label: 'Warrior', data: [95, 70, 50, 60, 65] }, { label: 'Mage', data: [40, 55, 95, 90, 70] } ] } }; </script>
Disabling Tooltips
Jump to heading
Use the without-tooltip attribute to hide the tooltips that appear when hovering over data points.
<wa-radar-chart id="radar-tooltip" without-tooltip label="No Tooltips" description="A radar chart with tooltips disabled"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-tooltip'); chart.config = { data: { labels: ['A', 'B', 'C', 'D', 'E'], datasets: [{ label: 'Values', data: [80, 60, 90, 70, 85] }] } }; </script>
Disabling Animations
Jump to heading
Use the without-animation attribute to disable chart transitions.
<wa-radar-chart id="radar-anim" without-animation label="No Animation" description="A radar chart with animation disabled"> </wa-radar-chart> <script type="module"> const chart = document.querySelector('#radar-anim'); chart.config = { data: { labels: ['A', 'B', 'C', 'D', 'E'], datasets: [{ label: 'Values', data: [80, 60, 90, 70, 85] }] } }; </script>
Importing
Jump to heading
Autoloading components via projects is the recommended way to import components. If you prefer to do it manually, use one of the following code snippets.
Let your project code do the work! Sign up for free to use a project with your very own CDN — it's the fastest and easiest way to use Web Awesome.
To manually import this component from NPM, use the following code.
import '@awesome.me/webawesome/dist/components/radar-chart/radar-chart.js';
To manually import this component from React, use the following code.
import WaRadarChart from '@awesome.me/webawesome/dist/react/radar-chart';
Slots
Jump to heading
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | An optional <script type="application/json"> element containing the Chart.js configuration object. |
Attributes & Properties
Jump to heading
Learn more about attributes and properties.
| Name | Description | Reflects | |
|---|---|---|---|
config |
The Chart.js configuration object. Setting this property will automatically re-render the chart.
Type
ChartJS['config'] |
||
css |
One or more CSSResultGroup to include in the component's shadow root. Host styles are automatically prepended.
Type
CSSResultGroup | undefinedDefault
[styles] |
||
descriptiondescription |
A description of the chart, used for accessibility.
Type
string | nullDefault
null |
||
gridgrid |
Which axes to show grid lines on.
Type
'x' | 'y' | 'both' | 'none'Default
'both' |
||
indexAxisindex-axis |
The base axis of the dataset. 'x' for vertical bars and 'y' for horizontal bars.
Type
'x' | 'y'Default
'x' |
||
labellabel |
A label for the chart, used for accessibility.
Type
string | nullDefault
null |
||
legendPositionlegend-position |
The position of the legend relative to the chart.
Type
LayoutPosition | 'start' | 'end'Default
'top' |
||
maxmax |
The maximum value for the value axis.
Type
number | nullDefault
null |
||
minmin |
The minimum value for the value axis.
Type
number | nullDefault
null |
||
pluginsplugins |
Additional Chart.js plugins to register for this chart instance.
Type
arrayDefault
[] |
||
stackedstacked |
Stacks datasets on top of each other along the value axis.
Type
booleanDefault
false |
||
typetype |
The type of chart to render. Valid types include
bar, line, pie, doughnut, polarArea, radar, scatter,
and bubble.Type
ChartTypeDefault
'radar' |
||
withoutAnimationwithout-animation |
Disables chart animations
Type
booleanDefault
false |
|
|
withoutLegendwithout-legend |
Hides the legend
Type
booleanDefault
false |
|
|
withoutTooltipwithout-tooltip |
Hides tooltips over data points
Type
booleanDefault
false |
|
|
xLabelxLabel |
A label for the x-axis.
Type
string | nullDefault
null |
||
yLabelyLabel |
A label for the y-axis.
Type
string | nullDefault
null |
CSS custom properties
Jump to heading
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--border-color-1 |
Border color for the first dataset.
Default
var(--wa-color-blue-60)
|
--border-color-2 |
Border color for the second dataset.
Default
var(--wa-color-pink-60)
|
--border-color-3 |
Border color for the third dataset.
Default
var(--wa-color-green-60)
|
--border-color-4 |
Border color for the fourth dataset.
Default
var(--wa-color-yellow-60)
|
--border-color-5 |
Border color for the fifth dataset.
Default
var(--wa-color-purple-60)
|
--border-color-6 |
Border color for the sixth dataset.
Default
var(--wa-color-orange-60)
|
--border-radius |
Border radius for bar charts.
Default
var(--wa-border-radius-s)
|
--border-width |
Border width for bars and arcs.
Default
var(--wa-border-width-s)
|
--fill-color-1 |
Fill color for the first dataset.
Default
color-mix(in srgb, var(--wa-color-blue-60) 40%, transparent)
|
--fill-color-2 |
Fill color for the second dataset.
Default
color-mix(in srgb, var(--wa-color-pink-60) 40%, transparent)
|
--fill-color-3 |
Fill color for the third dataset.
Default
color-mix(in srgb, var(--wa-color-green-60) 40%, transparent)
|
--fill-color-4 |
Fill color for the fourth dataset.
Default
color-mix(in srgb, var(--wa-color-yellow-60) 40%, transparent)
|
--fill-color-5 |
Fill color for the fifth dataset.
Default
color-mix(in srgb, var(--wa-color-purple-60) 40%, transparent)
|
--fill-color-6 |
Fill color for the sixth dataset.
Default
color-mix(in srgb, var(--wa-color-orange-60) 40%, transparent)
|
--grid-border-width |
Border width for chart grid lines and axis borders.
Default
var(--wa-border-width-s)
|
--grid-color |
Color of the chart grid lines and axis borders.
Default
var(--wa-color-neutral-border-quiet)
|
--line-border-width |
Border width for line and radar charts.
Default
var(--wa-border-width-m)
|
--point-radius |
Radius of data point dots.
Default
var(--wa-border-width-m)
|