@data-ui/radial-chart
demo at williaster.github.io/data-ui
Overview
This package exports declarative react <RadialChart />
s implemented with @vx which (for the time being) can be used to render both donut and pie charts depending on props. As demonstrated in the demo, in combination with @vx/legend and
@vx/scale these can be used to create re-usable radial charts.
Usage
See the demo at williaster.github.io/data-ui for more example outputs.
import { scaleOrdinal } from '@vx/scale';
import { LegendOrdinal } from '@vx/legend';
import { colors } from '@data-ui/theme';
import { RadialChart, ArcSeries, ArcLabel } from '@data-ui/radial-chart';
const colorScale = scaleOrdinal({ range: colors.categories });
export default () => (
<div style={{ display: 'flex', alignItems: 'center' }}>
<RadialChart
ariaLabel="This is a radial-chart chart of..."
width={width}
height={height}
margin={{ top, right, bottom, left }}
>
<ArcSeries
data={data}
pieValue={d => d.value}
fill={arc => colorScale(arc.data.label)}
stroke="#fff"
strokeWidth={1}
label{arc => `${(arc.data.value).toFixed(1)}%`}
labelComponent={<ArcLabel />}
innerRadius={radius => 0.35 * radius}
outerRadius={radius => 0.6 * radius}
labelRadius={radius => 0.75 * radius}
/>
</RadialChart>
<LegendOrdinal
direction="column"
scale={colorScale}
shape="rect"
fill={({ datum }) => colorScale(datum)}
labelFormat={label => label}
/>
</div>
);
Roadmap
- more types of radial series
- interactions (eg tooltips)
- animations / transitions
NOTE ‼️
Although pie 🍰 and donut 🍩 charts are frequently encountered, they are not the most effective visualization for conveying quantitative information. With that caveat, when used well they can effectively give an overview of population makeup which is an entirely reasonable use of these charts. We don't recommend using >7 slices for user readability.
@data-ui packages
v0.0.59
[xy-chart]
🏆 Enhancements
- expose
tickComponent
prop in XAxis
and YAxis
components for fully-custom tick rendering #110 - bump all
vx
packages, which adds much better default support for tick labels (Fixes #109) #110
[demo]
- added tick label props playground example to demo new functionality #110
🏠 Internal
[shared]
Changes:
- @data-ui/theme: 0.0.48 => 0.0.59
- @data-ui/demo: 0.0.58 => 0.0.59 (private)
- @data-ui/event-flow: 0.0.54 => 0.0.59
- @data-ui/histogram: 0.0.58 => 0.0.59
- @data-ui/network: 0.0.56 => 0.0.59
- @data-ui/radial-chart: 0.0.54 => 0.0.59
- @data-ui/shared: 0.0.54 => 0.0.59
- @data-ui/sparkline: 0.0.54 => 0.0.59
- @data-ui/xy-chart: 0.0.54 => 0.0.59