Bubble Chart
Bubble charts add a third dimension to scatter plots by varying the size of each data point. They are useful for visualizing relationships where a third variable adds meaning beyond a simple x/y correlation.
-
Pro Components -
Native Styles -
CSS + Layout Utilities -
Ever-Growing Pattern Library -
Unlimited Hosted Projects -
Pre-Built Pro Themes -
Pro Theme Builder -
Pro Color Tools -
Official Figma Design Kit -
WA Pro Perpetual License -
Actual Human™ Support
Already have Pro? Log in
Unlike bar or line charts, bubble data is an array of {x, y, r} point objects:
| Property | Description |
|---|---|
x |
Position along the x-axis |
y |
Position along the y-axis |
r |
Bubble radius in pixels, fixed and not scaled to the axes |
See <wa-chart> for advanced configuration, custom plugins, and direct Chart.js access.
Examples
Providing Data with JSON
Place a <script type="application/json"> tag inside the component. Each data point is an object with x, y, and r properties. The JSON follows the Chart.js configuration format.
Providing Data with JavaScript
Set the config property from JavaScript when your data comes from code rather than static markup. The chart re-renders automatically each time you assign it. For data that updates at runtime, try the live controls in Accessing the Chart.js Instance.
config is shallowly reactive.
If you mutate the object in place, reassign it to trigger a re-render.
Custom Tooltips
Bubble tooltips show raw x, y, r values by default. Attach a property to each data point and read it in a tooltip callback to name points and spell out what the bubble size means.
Bubble Sizes
The r property on each data point sets the bubble radius in pixels. Unlike x and y, this value is absolute and not mapped to a chart scale. Use larger values to represent greater magnitude.
Multiple Datasets
Use multiple datasets to compare groups of bubbles. Each group gets its own color.
Colors
Override the default color palette using the --fill-color-* and --border-color-* CSS custom properties on the component.
Legend
Use the legend-position attribute to control where the legend appears. Add without-legend to hide it entirely.
Grid Lines
Use the grid attribute to control which axes show grid lines. Options are both (default), x, y, and none.
Axis Labels
Use the x-label and y-label attributes to add descriptive labels to each axis.
Disabling Features
Use without-tooltip to hide hover tooltips and without-animation to disable transitions.
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://ka-f.webawesome.com/[email protected]/components/bubble-chart/bubble-chart.js';
After installing Web Awesome via npm, import this component:
import '@awesome.me/webawesome/dist/components/bubble-chart/bubble-chart.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/bubble-chart/bubble-chart.js';
To import this component for React 18 or below, use the following code:
import WaBubbleChart from '@awesome.me/webawesome/dist/react/bubble-chart/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | An optional <script type="application/json"> element containing the Chart.js configuration object. |
Attributes & Properties
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']
|
|
descriptiondescription |
A description of the chart, used for accessibility.
Type
string | null
Default
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 | null
Default
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 | null
Default
null
|
|
minmin |
The minimum value for the value axis.
Type
number | null
Default
null
|
|
pluginsplugins |
Additional Chart.js plugins to register for this chart instance.
Type
array
Default
[]
|
|
stackedstacked |
Stacks datasets on top of each other along the value axis.
Type
boolean
Default
false
|
|
typetype |
The type of chart to render. Valid types include
bar, line, pie, doughnut, polarArea, radar, scatter,
and bubble.
Type
ChartType
Default
'bubble'
|
|
withoutAnimationwithout-animation |
Disables chart animations
Type
boolean
Default
false
|
|
withoutLegendwithout-legend |
Hides the legend
Type
boolean
Default
false
|
|
withoutTooltipwithout-tooltip |
Hides tooltips over data points
Type
boolean
Default
false
|
|
xLabelx-label |
A label for the x-axis.
Type
string | null
Default
null
|
|
yLabely-label |
A label for the y-axis.
Type
string | null
Default
null
|
CSS Custom Properties
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)
|