Skip to content

feat(data-viz): add simple chart type support #4318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
fe7988b
feat(docs): data viz base structure
krisantrobus Apr 10, 2025
4654b80
feat(data-viz): wokring base chart
krisantrobus Apr 11, 2025
0cbd203
feat(data-viz): wip
krisantrobus Apr 11, 2025
97f8ac2
feat(data-viz): wip
krisantrobus Apr 11, 2025
1f696ac
feat(data-viz): wip
krisantrobus Apr 14, 2025
427a1bd
feat(data-viz): wip
krisantrobus Apr 14, 2025
3ba6789
feat(data-viz): sitemap
krisantrobus Apr 14, 2025
db40510
feat(data-viz): docs exmapleds
krisantrobus Apr 14, 2025
1b60202
feat(data-viz): ci checks
krisantrobus Apr 14, 2025
b82ba11
feat(data-viz): docs refinement
krisantrobus Apr 16, 2025
317220a
Merge branch 'main' of github.com:twilio-labs/paste into docs-data-vi…
krisantrobus Apr 16, 2025
1b5bc22
chore(cleanup): remove redundant story
krisantrobus Apr 16, 2025
bb8c48b
chore(cleanup): changeset
krisantrobus Apr 16, 2025
7d0d76b
fix(data-viz): fix urls
krisantrobus Apr 16, 2025
d828fb3
fix(data-viz): fix slugs
krisantrobus Apr 16, 2025
8b7fcf4
feat(data-vix): chart-provider in project.json
krisantrobus Apr 16, 2025
2297ca3
chore(data-vix): test chanpshots
krisantrobus Apr 16, 2025
882cefc
chore(ci): fix supabase
krisantrobus Apr 16, 2025
65f2844
chore(ci): fix supabase
krisantrobus Apr 16, 2025
3f21680
chore(ci): ignore generated files for linting
krisantrobus Apr 16, 2025
e4b069a
chore(data-vix): typos
krisantrobus Apr 16, 2025
856fa96
chore(data-vix): trigger rebuild
krisantrobus Apr 16, 2025
fa6c7b4
chore(data-vix): trigger rebuild
krisantrobus Apr 16, 2025
34bcf1e
chore(data-vix): trigger rebuild
krisantrobus Apr 16, 2025
dfcc8fc
feat(data-visualization): add initial supported charts
krisantrobus Apr 22, 2025
ffc2426
feat(data-visualization): axis titles
krisantrobus Apr 22, 2025
984f0b2
feat(data-visualization): include area chart
krisantrobus Apr 22, 2025
d3e2144
feat(data-visualization): additional example
krisantrobus Apr 23, 2025
718e80c
feat(data-visualization): tests
krisantrobus Apr 23, 2025
4ef5467
feat(data-visualization): refactor
krisantrobus Apr 23, 2025
4c6b80d
chore(data-visualization): lci checks
krisantrobus Apr 23, 2025
d5169fc
feat(data-visualization): changesets
krisantrobus Apr 23, 2025
c25b041
feat(data-visualization): animation boolean
krisantrobus Apr 24, 2025
26c20bc
feat(data-visualization): wip
krisantrobus Apr 25, 2025
ef8ccc2
feat(data-visualization): jsdoc and type cleanup
krisantrobus Apr 25, 2025
e67f1e3
feat(data-visualization): cedits and column styles
krisantrobus Apr 25, 2025
5a6b23a
feat(data-visualization): watermark on examples
krisantrobus Apr 25, 2025
aa47290
feat(data-visualization): update chart types content
krisantrobus Apr 28, 2025
6c1bce6
feat(data-visualization): adding typedocs
krisantrobus Apr 29, 2025
ff5cf14
Update packages/paste-website/src/components/site-wrapper/sidebar/Sid…
krisantrobus Apr 29, 2025
1609a2b
feat(data-visualization): chart option docs
krisantrobus Apr 29, 2025
f878f40
feat(data-visualization): cleanup chart options
krisantrobus Apr 29, 2025
cb420bf
Merge branch 'main' of github.com:twilio-labs/paste into docs-data-vi…
krisantrobus Apr 29, 2025
cd18f45
Merge branch 'docs-data-viz-base-chart' of github.com:twilio-labs/pas…
krisantrobus Apr 29, 2025
80bbe93
feat(data-visualization): vrt
krisantrobus Apr 29, 2025
e2b4870
Merge branch 'docs-data-viz-base-chart' of github.com:twilio-labs/pas…
krisantrobus Apr 29, 2025
835ff2e
feat(data-visualization): pr cleanup
krisantrobus Apr 29, 2025
65066c5
chore(typos): fix various typos
krisantrobus Apr 29, 2025
369105b
chore(typos): revert fix
krisantrobus Apr 29, 2025
069f892
chore(tests): add support for same title sidebar disclousres
krisantrobus Apr 29, 2025
a0b2ef3
Merge branches 'chart-types-line-column-support' and 'docs-data-viz-b…
krisantrobus Apr 29, 2025
ab7de86
feat(data-viz): update docs urls and release versioning
krisantrobus Apr 30, 2025
e6d8b1f
Merge branch 'docs-data-viz-base-chart' of github.com:twilio-labs/pas…
krisantrobus Apr 30, 2025
ba1e786
chore(data-viz): update urls
krisantrobus Apr 30, 2025
12a370d
Apply suggestions from code review
krisantrobus May 1, 2025
c9109cf
chore(data-viz): addressed PR comments
krisantrobus May 1, 2025
7138cc9
Merge branch 'docs-data-viz-base-chart' of github.com:twilio-labs/pas…
krisantrobus May 1, 2025
b4dfd0f
Merge branch 'docs-data-viz-base-chart' of github.com:twilio-labs/pas…
krisantrobus May 1, 2025
89f4c9d
Merge branch 'main' of github.com:twilio-labs/paste into chart-types-…
krisantrobus May 19, 2025
27a3b5f
fix(e2e): chage order of disclosure opening to account for multiple d…
krisantrobus May 19, 2025
09ac585
Merge branch 'main' of github.com:twilio-labs/paste into chart-types-…
krisantrobus May 28, 2025
7b12274
fix(data-viz): toolitp text color
krisantrobus May 28, 2025
a68a35a
feat(ci): fix tests
krisantrobus May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/serious-avocados-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/core": minor
"@twilio-paste/data-visualization-library": minor
---

[Data visualization library] added helper functions and types to provide support for creating highcharts options for supported chart types
6 changes: 6 additions & 0 deletions .changeset/twenty-rocks-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/chart-provider": minor
"@twilio-paste/core": minor
---

[Chart Provider] added the ability to use options for supported chart types
2 changes: 2 additions & 0 deletions packages/paste-core/components/chart-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@twilio-paste/box": "^11.0.0",
"@twilio-paste/color-contrast-utils": "^5.0.0",
"@twilio-paste/customization": "^9.0.0",
"@twilio-paste/data-visualization-library": "^6.0.1",
"@twilio-paste/design-tokens": "^10.3.0",
"@twilio-paste/style-props": "^10.0.0",
"@twilio-paste/styling-library": "^4.0.0",
Expand All @@ -45,6 +46,7 @@
"@twilio-paste/box": "^11.0.1",
"@twilio-paste/color-contrast-utils": "^5.0.0",
"@twilio-paste/customization": "^9.0.1",
"@twilio-paste/data-visualization-library": "^6.0.1",
"@twilio-paste/design-tokens": "^10.13.0",
"@twilio-paste/style-props": "^10.0.1",
"@twilio-paste/styling-library": "^4.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Box, safelySpreadBoxProps } from "@twilio-paste/box";
import type { BoxProps } from "@twilio-paste/box";
import { transformToHighchartsOptions } from "@twilio-paste/data-visualization-library";
import type { ChartTypeOptions } from "@twilio-paste/data-visualization-library";
import type { HTMLPasteProps } from "@twilio-paste/types";
import * as Highcharts from "highcharts";
import * as React from "react";
Expand All @@ -25,16 +27,47 @@ interface HighchartsOptions extends BaseChartProviderProps {
* @memberof ChartProviderProps
*/
highchartsOptions: Highcharts.Options;
pasteOptions?: never;
options?: never;
}

export type ChartProviderProps = HighchartsOptions;
interface ChartOptions extends BaseChartProviderProps {
/**
* Overrides the default element name to apply unique styles with the Customization Provider
* @default null
* @type {BoxProps['element']}
* @memberof ChartProviderProps
*/
highchartsOptions?: never;
options: ChartTypeOptions;
}

export type ChartProviderProps = HighchartsOptions | ChartOptions;

const ChartProvider = React.forwardRef<HTMLDivElement, ChartProviderProps>(
({ element = "CHART_PROVIDER", children, highchartsOptions, ...props }, ref) => {
({ element = "CHART_PROVIDER", children, highchartsOptions, options, ...props }, ref) => {
const [chart, setChart] = React.useState<Highcharts.Chart>();
const [chartRef, setChartRef] = React.useState<HTMLElement>();

if (highchartsOptions && !options) {
return (
<Box {...safelySpreadBoxProps(props)} ref={ref} element={element} position="relative">
<ChartContext.Provider
value={{
chart,
setChart,
chartRef,
setChartRef,
options: highchartsOptions,
}}
>
{children}
</ChartContext.Provider>
</Box>
);
}

const transformedOptions = transformToHighchartsOptions(options);

return (
<Box {...safelySpreadBoxProps(props)} ref={ref} element={element} position="relative">
<ChartContext.Provider
Expand All @@ -43,7 +76,7 @@ const ChartProvider = React.forwardRef<HTMLDivElement, ChartProviderProps>(
setChart,
chartRef,
setChartRef,
options: highchartsOptions,
options: transformedOptions,
}}
>
{children}
Expand Down
18 changes: 9 additions & 9 deletions packages/paste-core/components/chart-provider/type-docs.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{
"ChartProvider": {
"highchartsOptions": {
"type": "Options",
"defaultValue": "null",
"required": true,
"externalProp": false,
"description": "Overrides the default element name to apply unique styles with the Customization Provider"
},
"about": {
"type": "string",
"defaultValue": null,
Expand Down Expand Up @@ -486,6 +479,13 @@
"required": false,
"externalProp": true
},
"highchartsOptions": {
"type": "Options",
"defaultValue": "null",
"required": false,
"externalProp": false,
"description": "Overrides the default element name to apply unique styles with the Customization Provider"
},
"id": {
"type": "string",
"defaultValue": null,
Expand Down Expand Up @@ -1574,8 +1574,8 @@
"required": false,
"externalProp": true
},
"pasteOptions": {
"type": "never",
"options": {
"type": "ChartTypeOptions",
"defaultValue": null,
"required": false,
"externalProp": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Object {
"borderWidth": "1px",
"padding": 12,
"style": Object {
"color": "rgb(18, 28, 45)",
"color": "rgb(255, 255, 255)",
"fontFamily": "'Inter var experimental', 'Inter var', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
"fontSize": "0.875rem",
},
Expand Down Expand Up @@ -240,7 +240,7 @@ Object {
"borderWidth": "1px",
"padding": 12,
"style": Object {
"color": "rgb(18, 28, 45)",
"color": "rgb(255, 255, 255)",
"fontFamily": "'Inter var experimental', 'Inter var', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
"fontSize": "0.875rem",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { renderHook } from "@testing-library/react";
import { Theme } from "@twilio-paste/theme";
import React from "react";

import { AreaChartConfig, AreaSeries } from "../../src";
import { handleAreaOptions } from "../../src/transformers/areaChart";

const container: React.FC<{ children: React.ReactNode }> = ({ children }) => (
<Theme.Provider theme="default">{children}</Theme.Provider>
);

const seriesData: AreaSeries[] = [
{
name: "Installation",
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
},
{
name: "Manufacturing",
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
},
];

const options: AreaChartConfig = {
series: seriesData,
type: "area",
};

describe("Area Chart Transformer", () => {
it("should transform area chart data correctly", () => {
const { result } = renderHook(() => handleAreaOptions(options), { wrapper: container });

expect(result.current.chart).toEqual(
expect.objectContaining({
type: "area",
}),
);

expect(result.current.plotOptions).toEqual(
expect.objectContaining({
series: {
stickyTracking: false,
},
}),
);

expect(result.current.series).toEqual(
expect.arrayContaining([
{
name: "Installation",
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
type: "area",
},
]),
);
});
});
Loading
Loading