Skip to contentSkip to navigationSkip to topbar
Paste assistant Assistant
Figma
Star

Chart Provider

Version 2.0.1GithubStorybookDesign assets pendingPeer review pending

Chart Provider is a data visualization component used to wrap an individual chart to store and share state to child charting elements.

Installation

Installation page anchor
yarn add @twilio-paste/chart-provider - or - yarn add @twilio-paste/core
import { ChartProvider } from '@twilio-paste/core/chart-provider';

const ChartProviderExample = () => {
  return (
    <ChartProvider {...config}>
      <BaseChart />
    </ChartProvider>
  );
};

ChartProvider

ChartProvider page anchor

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
string
Default
'CHART_PROVIDER'

highchartsOptions

Overrides the default element name to apply unique styles with the Customization Provider

Type
Options
Default
null

options

Type
ChartTypeOptions


The props below are used to configure supported chart types and can be imported from @twilio-paste/data-visualization-library. These are used to construct the chart options, ensuring type safety before providing them to the Chart Provider component.

import { LineChartConfig } from '@twilio-paste/data-visualization-library';

type RequiredRequired

The type of chart to render. This will determine what other chart specfic options are available.

Type
SupportedCharts

accessibility

Sets global accessiblity options such as formatting the point and series text that is read to users when they focus on elements.

Type
ChartAccessibilityConfig

chart

Sets metadata for the chart such as whether it is animated, the height and width of the chart, and other chart options.

Type
ChartConfig

enableCredits

Controls the display of teh watermark in the bottom right of the chart accrediting Highcharts. Not needed for projects with a license and disbaled by default.

Type
boolean

isAnimated

Controls whether the chart is animated.

Type
boolean
Default

isXTimeAxis

Render the X axis as a datetime.

Type
boolean

panningType

The type of panning to enable on the chart allowing users to move the region currently zoomed in on. This will determine whether users can pan in the x, y or both axis.

Type
OptionsZoomTypeValue

pointFormatter

A function that formats the point text for Highcharts native tooltips.

Type
(point: Point) => string

showLegend

Whether to show the native legend provided by Highcharts.

Type
boolean

subtitle

Configure the sub title of the chart. Optionall hide the sub title too. The purpose of setting text but hiding the sub title allows the sub title to still be included in any chart descritions read by screen readers.

Type
TitleConfig

title

Configure the title of the chart. Optionall hide the title too. The purpose of setting text but hiding the title allows the title to still be included in any chart descritions read by screen readers.

Type
TitleConfig

xAxisCategories

The data to be displayed on the x axis labels. This is useful when you do not have the x plot data in your series but need to set the tick labels on teh x axis.

Type
string[]

xAxisTitle

Configure the x axis of the chart. Optionall hide the x axis too. The purpose of setting text but hiding the x axis allows the x axis to still be included in any chart descritions read by screen readers.

Type
TitleConfig

yAxisTitle

Configure the y axis of the chart. Optionall hide the y axis too. The purpose of setting text but hiding the y axis allows the y axis to still be included in any chart descritions read by screen readers.

Type
TitleConfig

zoomingType

The type of zooming to enable on the chart. This will determine whether users can zoom in the x, y or both axis.

Type
OptionsZoomTypeValue

series RequiredRequired

The series data for a line chart.

The series data for a column chart.

The series data for an area chart.

Type
LineSeries[] | ColumnSeries[] | AreaSeries[]

type RequiredRequired

Specifies that this is a line chart.

Specifies that this is a column chart.

Specifies that this is an area chart.

Type
"line" | "column" | "area"

accessibility

Sets global accessiblity options such as formatting the point and series text that is read to users when they focus on elements.

Type
ChartAccessibilityConfig

chart

Sets metadata for the chart such as whether it is animated, the height and width of the chart, and other chart options.

Type
ChartConfig

enableCredits

Controls the display of teh watermark in the bottom right of the chart accrediting Highcharts. Not needed for projects with a license and disbaled by default.

Type
boolean

isAnimated

Controls whether the chart is animated.

Type
boolean
Default

isXTimeAxis

Render the X axis as a datetime.

Type
boolean

panningType

The type of panning to enable on the chart allowing users to move the region currently zoomed in on. This will determine whether users can pan in the x, y or both axis.

Type
OptionsZoomTypeValue

pointFormatter

A function that formats the point text for Highcharts native tooltips.

Type
(point: Point) => string

showLegend

Whether to show the native legend provided by Highcharts.

Type
boolean

subtitle

Configure the sub title of the chart. Optionall hide the sub title too. The purpose of setting text but hiding the sub title allows the sub title to still be included in any chart descritions read by screen readers.

Type
TitleConfig

title

Configure the title of the chart. Optionall hide the title too. The purpose of setting text but hiding the title allows the title to still be included in any chart descritions read by screen readers.

Type
TitleConfig

xAxisCategories

The data to be displayed on the x axis labels. This is useful when you do not have the x plot data in your series but need to set the tick labels on teh x axis.

Type
string[]

xAxisTitle

Configure the x axis of the chart. Optionall hide the x axis too. The purpose of setting text but hiding the x axis allows the x axis to still be included in any chart descritions read by screen readers.

Type
TitleConfig

yAxisTitle

Configure the y axis of the chart. Optionall hide the y axis too. The purpose of setting text but hiding the y axis allows the y axis to still be included in any chart descritions read by screen readers.

Type
TitleConfig

zoomingType

The type of zooming to enable on the chart. This will determine whether users can zoom in the x, y or both axis.

Type
OptionsZoomTypeValue

series RequiredRequired

The series data for an area chart.

Type
AreaSeries[]

series RequiredRequired

The series data for a column chart.

Type
ColumnSeries[]

showDataLabels

Show the number value for the column on top of the section. Works for regular and stacked variants.

Type
boolean

stackingType

The type of stacking to use for the column chart, whether to show percentage stacked or normal.

Type
"normal" | "percent"

series RequiredRequired

The series data for a line chart.

Type
LineSeries[]