Skip to main content
CartesianChart
@coinbase/cds-web-visualization@3.4.0-beta.9
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
import { CartesianChart } from '@coinbase/cds-web-visualization'
SourceView source code
Peer dependencies
  • framer-motion: ^10.18.0
Related components
View as Markdown

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

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.