Skip to main content
CartesianChart
@coinbase/cds-web-visualization@3.4.0-beta.20
A flexible, low-level chart component for displaying data in an x/y coordinate space. Provides a foundation for building custom chart visualizations with full control over rendering.
import { CartesianChart } from '@coinbase/cds-web-visualization'
Related components

CartesianChart is a customizable, SVG based component that can be used to display a variety of data in a x/y coordinate space. The underlying logic is handled by D3.

Basic Example

AreaChart, BarChart, and LineChart are built on top of CartesianChart and have default functionality for your chart.

Loading...

Series

Series are the data that will be displayed on the chart. Each series must have a defined id.

Series Data

You can pass in an array of numbers or an array of tuples for the data prop. Passing in null values is equivalent to no data at that index.

Loading...

Series Axis IDs

Each series can have a different yAxisId, allowing you to compare data from different contexts.

Loading...

Series Stacks

You can provide a stackId to stack series together.

Loading...

Axes

You can configure your x and y axes with the xAxis and yAxis props. xAxis accepts an object while yAxis accepts an object or array.

Loading...

For more info, learn about XAxis and YAxis configuration.

Inset

You can adjust the inset around the entire chart (outside the axes) with the inset prop. This is useful for when you want to have components that are outside of the drawing area of the data but still within the chart svg.

You can also remove the default inset, such as to have a compact line chart.

Loading...

Scrubbing

CartesianChart has built-in scrubbing functionality that can be enabled with the enableScrubbing prop. This will then enable the usage of onScrubberPositionChange to get the current position of the scrubber as the user interacts with the chart.

Loading...

Animations

CartesianChart delegates transition control to its child components. You can also disable all animations chart-wide by passing animate={false} on CartesianChart.

Enter Only

Disable the update morph animation while keeping a slow enter reveal. Data changes snap instantly but the initial chart appearance animates. Useful when new data arrives frequently and morphing would be distracting.

Loading...

Update Only

Disable the enter reveal animation while keeping a slow update morph. The chart appears instantly but data changes animate smoothly. Useful when the chart is embedded in content that should not animate on load.

Loading...

Mixed Transitions Per Child

Each child component can define its own transitions independently. Here, the Line uses a spring morph while the bars snap with no update animation. This lets you fine-tune each visual layer within a single chart.

Loading...

No Animations

You can disable all animations chart-wide by setting animate to false on CartesianChart. This is useful for static snapshots or when performance is a concern. Compare this to the animated examples above — data still updates, but changes snap instantly without any transition.

Loading...

Customization

Price with Volume

You can showcase the price and volume of an asset over time within one chart.

Loading...

Earnings History

You can also create your own type of cartesian chart by using getSeriesData, getXScale, and getYScale directly.

Loading...

You can have multiple axes with different domains and ranges to showcase different pieces of data over the time time period.

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.