Data visualization library
A library that helps theme data visualizations with Paste tokens.
This package is meant to be used with another data visualization library to style visualizations.
yarn add @twilio-paste/data-visualization-library - or - yarn add @twilio-paste/core
This is a React Hook to take a Highcharts config and add Paste colors and fonts.
import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import { usePasteHighchartsTheme } from "@twilio-paste/data-visualization-library";
const LineChartOptions = {
title: { text: "Solar Employment Growth by Sector, 2010-2016" },
subtitle: { text: "Source: thesolarfoundation.com" },
series: [
{
name: "Installation",
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
},
{
name: "Manufacturing",
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
},
{
name: "Sales & Distribution",
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
},
{
name: "Project Development",
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227],
},
{
name: "Other",
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
},
],
};
const LineChartExample = () => {
const themedLineChartOptions = usePasteHighchartsTheme(LineChartOptions);
return <HighchartsReact highcharts={Highcharts} options={themedLineChartOptions} />;
};
The hook adds the following styles:
colors: the colors Highcharts cycles through for the chart's serieschart: the background colortitle,subtitle,legend,credits,label, andtooltip: the font, text colors, and background colorxAxis,yAxis: the font, text colors, and the line and tick colors.
To learn more about the configurations available, check out the Highcharts API documentation.
This is a helper function to initiate Highcharts modules that are not included by default. The accessibility module is a mandatory module, but you can pass as many other modules as you want. This hook should be used at the component level where the Highcharts namespace is passed to HighchartsReact.
import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import HighchartsAccessibilityModule from "highcharts/modules/accessibility";
import HighchartsExportingModule from "highcharts/modules/exporting";
import { applyPasteHighchartsModules } from "@twilio-paste/data-visualization-library";
applyPasteHighchartsModules(Highcharts, HighchartsAccessibilityModule, HighchartsExportingModule);
const LineChartExample = () => {
return <HighchartsReact highcharts={Highcharts} />;
};
Changelog
@twilio-paste/data-visualization-library
6.1.0
Minor Changes
a88fdab49#4335 Thanks @krisantrobus! - [Data Visualization Library] added the ability to set accessibility options
3705495c7#4318 Thanks @krisantrobus! - [Data visualization library] added helper functions and types to provide support for creating highcharts options for supported chart types
6.0.2
Patch Changes
bf5666048#4312 Thanks @krisantrobus! - [Data Visualization Library] update Highcharts native tooltip styles to align more closely with Paste styles including correctly setting the font family
6.0.1
Patch Changes
262c1b715#4281 Thanks @PixeledCode! - [all packages]: add use client directive to the components and icons. This will make paste library compatible with server components
6.0.0
Major Changes
f48211e56#4258 Thanks @PixeledCode! - [all packages]: Upgrade to React 19 and drop support for React 16. Paste only supports the three latest versions of React. If you're using Paste in a React 17, 18, or 19 app, you should be able to upgrade with full backwards compatibility. If you experience any issues, please let us know on Github.
Patch Changes
- Updated dependencies [
f48211e56]:- @twilio-paste/animation-library@3.0.0
- @twilio-paste/styling-library@4.0.0
- @twilio-paste/theme@12.0.0
- @twilio-paste/types@7.0.0
5.1.0
Minor Changes
b20a3a1a8#4053 Thanks @krisantrobus! - [Data Visualization]: added a new helper function, applyPasteHighchartsModules, that applies any number of modules to Highcharts setting accesibility required.
5.0.0
Major Changes
733709127#3395 Thanks @SiTaggart! - Modified the compile target of our JavaScript bundles fromnodetobrowserto minimize the risk of clashing with RequireJS. This is marked as a major out of an abundance of caution. You shouldn't need to do anything but we wanted you to be aware of the change on the off chance it has unintended consequences
Patch Changes
- Updated dependencies [
733709127]:- @twilio-paste/color-contrast-utils@5.0.0
- @twilio-paste/design-tokens@10.0.0
- @twilio-paste/animation-library@2.0.0
- @twilio-paste/styling-library@3.0.0
- @twilio-paste/theme@11.0.0
- @twilio-paste/types@6.0.0
4.0.0
Major Changes
3ab2bb6f4#3114 Thanks @SiTaggart! - ### Breaking changeWe have moved
@types/reactand@types/react-domto peer dependencies of the library. This should allow for greater control and backwards compatibility with older versions of React as Paste is no longer bundling the type libraries.Your application likely has both of these as dependencies anyway, but it is now up to you to manage that version number.
Action needed
Ensure
@types/reactand@types/react-domare installed as dependencies of your application.
Patch Changes
- Updated dependencies [
bce889344,3ab2bb6f4]:- @twilio-paste/theme@10.0.0
- @twilio-paste/types@5.0.0
3.0.0
Major Changes
Patch Changes
- Updated dependencies [
dbd9bf992,3c89fd83d,0acdf3486,ef094db4a,0acdf3486]:- @twilio-paste/design-tokens@9.0.0
- @twilio-paste/animation-library@1.0.0
- @twilio-paste/styling-library@2.0.0
- @twilio-paste/theme@9.0.0
- @twilio-paste/types@4.0.0
- @twilio-paste/color-contrast-utils@4.0.0
2.0.2
Patch Changes
2.0.1
Patch Changes
a4c9e70b0#2763 Thanks @shleewhite! - Update ESLint rules, which changed some formatting.
2.0.0
Patch Changes
- Updated dependencies [
364083627,364083627,364083627,364083627]:- @twilio-paste/design-tokens@8.0.0
- @twilio-paste/theme@8.0.0
- @twilio-paste/color-contrast-utils@3.0.0
1.0.1
Patch Changes
ae9dd50f#2466 Thanks @TheSisb! - [All packages] Update our ESBuild version and remove minification of identifiers in our production builds.
1.0.0
Patch Changes
- Updated dependencies [
09762f0f1,09762f0f1]:- @twilio-paste/styling-library@1.0.0
- @twilio-paste/theme@7.0.0
0.1.2
Patch Changes
73c596919#2269 Thanks @SiTaggart! - Fixed a regression with the compilation script that caused incompatible ESM module importing of JSON files.
0.1.1
Patch Changes
33c43687#2236 Thanks @shleewhite! - [Data Visualization] add changelog
0.1.0
Minor Changes
f696cb17e#2200 Thanks @TheSisb! - [data-visualization] Add new package@twilio-paste/data-visualization-librarywhich exports a React hook to theme Highcharts.
Patch Changes
c867e3f48#2237 Thanks @SiTaggart! - Updated a build dependency (esbuild) which changes the output of our builds slightly, without materially changing anything about the code.