Skip to content

Commit 396b771

Browse files
authored
Update Charts package (#107591)
* Upgrade Charts to ^0.50.0 * Remove usage of deprecated Jetpack theme ThemeProvider is no longer necessary, as the line chart will create it's own global charts context with theme * Yarn dedupe
1 parent 3009186 commit 396b771

File tree

4 files changed

+97
-71
lines changed

4 files changed

+97
-71
lines changed

client/my-sites/stats/components/line-chart/index.tsx

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
LineChart,
3-
ThemeProvider,
4-
jetpackTheme,
5-
type EventHandlerParams,
6-
type DataPointDate,
7-
} from '@automattic/charts';
1+
import { LineChart, type EventHandlerParams, type DataPointDate } from '@automattic/charts';
82
import { formatNumber } from '@automattic/number-formatters';
93
import clsx from 'clsx';
104
import { translate } from 'i18n-calypso';
@@ -196,40 +190,38 @@ function StatsLineChart( {
196190
<div className={ clsx( 'stats-line-chart', className ) }>
197191
{ isEmpty && emptyState }
198192
{ ! isEmpty && (
199-
<ThemeProvider theme={ jetpackTheme }>
200-
<LineChart
201-
data={ chartData }
202-
withTooltips
203-
withGradientFill
204-
height={ height }
205-
curveType={ curveType }
206-
onPointerUp={ onPointerUp }
207-
margin={ {
208-
left: 20,
209-
top: 20,
210-
bottom: 20,
211-
right: Math.max( formatValue( maxValue ).length * 10, 40 ), //TODO: we should support this from the lib.
212-
} }
213-
options={ {
214-
yScale: {
215-
type: yScaleType,
216-
...( fixedDomain && { domain: [ 0, maxValue ] } ),
217-
zero: zeroBaseline,
193+
<LineChart
194+
data={ chartData }
195+
withTooltips
196+
withGradientFill
197+
height={ height }
198+
curveType={ curveType }
199+
onPointerUp={ onPointerUp }
200+
margin={ {
201+
left: 20,
202+
top: 20,
203+
bottom: 20,
204+
right: Math.max( formatValue( maxValue ).length * 10, 40 ), //TODO: we should support this from the lib.
205+
} }
206+
options={ {
207+
yScale: {
208+
type: yScaleType,
209+
...( fixedDomain && { domain: [ 0, maxValue ] } ),
210+
zero: zeroBaseline,
211+
},
212+
axis: {
213+
x: {
214+
tickFormat: formatTime,
218215
},
219-
axis: {
220-
x: {
221-
tickFormat: formatTime,
222-
},
223-
y: {
224-
orientation: 'right',
225-
tickFormat: formatValue,
226-
numTicks: yNumTicks,
227-
},
216+
y: {
217+
orientation: 'right',
218+
tickFormat: formatValue,
219+
numTicks: yNumTicks,
228220
},
229-
} }
230-
renderTooltip={ renderTooltip }
231-
/>
232-
</ThemeProvider>
221+
},
222+
} }
223+
renderTooltip={ renderTooltip }
224+
/>
233225
) }
234226
</div>
235227
);

client/my-sites/stats/pages/realtime/chart.tsx

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LineChart, ThemeProvider, jetpackTheme } from '@automattic/charts';
1+
import { LineChart } from '@automattic/charts';
22
import clsx from 'clsx';
33
import moment from 'moment';
44
import { useEffect, useState, useMemo } from 'react';
@@ -135,32 +135,30 @@ const RealtimeChart = ( { siteId }: { siteId: number } ) => {
135135

136136
return (
137137
<div className={ clsx( 'stats-line-chart', 'stats-realtime-chart' ) }>
138-
<ThemeProvider theme={ jetpackTheme }>
139-
<LineChart
140-
data={ chartDataSeries }
141-
withTooltips
142-
withGradientFill
143-
height={ 425 }
144-
margin={ { left: 15, top: 20, bottom: 20 } }
145-
options={ {
146-
yScale: {
147-
type: 'linear',
148-
domain: [ 0, maxViews ],
149-
zero: false,
138+
<LineChart
139+
data={ chartDataSeries }
140+
withTooltips
141+
withGradientFill
142+
height={ 425 }
143+
margin={ { left: 15, top: 20, bottom: 20 } }
144+
options={ {
145+
yScale: {
146+
type: 'linear',
147+
domain: [ 0, maxViews ],
148+
zero: false,
149+
},
150+
axis: {
151+
x: {
152+
tickFormat: formatTimeTick,
150153
},
151-
axis: {
152-
x: {
153-
tickFormat: formatTimeTick,
154-
},
155-
y: {
156-
orientation: 'right',
157-
tickFormat: formatViews,
158-
numTicks: maxViews > 4 ? 4 : 1,
159-
},
154+
y: {
155+
orientation: 'right',
156+
tickFormat: formatViews,
157+
numTicks: maxViews > 4 ? 4 : 1,
160158
},
161-
} }
162-
/>
163-
</ThemeProvider>
159+
},
160+
} }
161+
/>
164162
</div>
165163
);
166164
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"@automattic/calypso-products": "workspace:^",
156156
"@automattic/calypso-razorpay": "workspace:^",
157157
"@automattic/calypso-router": "workspace:^",
158-
"@automattic/charts": "^0.46.1",
158+
"@automattic/charts": "^0.50.0",
159159
"@automattic/color-studio": "^4.1.0",
160160
"@automattic/command-palette": "workspace:^",
161161
"@automattic/components": "workspace:^",

yarn.lock

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,43 @@ __metadata:
885885
languageName: unknown
886886
linkType: soft
887887

888-
"@automattic/charts@npm:>=0.14.0 <1.0.0, @automattic/charts@npm:^0.46.1":
888+
"@automattic/charts@npm:>=0.14.0 <1.0.0, @automattic/charts@npm:^0.50.0":
889+
version: 0.50.2
890+
resolution: "@automattic/charts@npm:0.50.2"
891+
dependencies:
892+
"@automattic/number-formatters": "npm:^1.0.15"
893+
"@babel/runtime": "npm:7.28.4"
894+
"@react-spring/web": "npm:9.7.5"
895+
"@visx/annotation": "npm:^3.12.0"
896+
"@visx/axis": "npm:^3.12.0"
897+
"@visx/curve": "npm:^3.12.0"
898+
"@visx/event": "npm:^3.12.0"
899+
"@visx/gradient": "npm:^3.12.0"
900+
"@visx/grid": "npm:^3.12.0"
901+
"@visx/group": "npm:^3.12.0"
902+
"@visx/legend": "npm:^3.12.0"
903+
"@visx/pattern": "npm:^3.12.0"
904+
"@visx/responsive": "npm:^3.12.0"
905+
"@visx/scale": "npm:^3.12.0"
906+
"@visx/shape": "npm:^3.12.0"
907+
"@visx/text": "npm:^3.12.0"
908+
"@visx/tooltip": "npm:^3.12.0"
909+
"@visx/xychart": "npm:^3.12.0"
910+
"@wordpress/i18n": "npm:^6.0.0"
911+
clsx: "npm:2.1.1"
912+
date-fns: "npm:^4.1.0"
913+
deepmerge: "npm:4.3.1"
914+
fast-deep-equal: "npm:3.1.3"
915+
gridicons: "npm:3.4.2"
916+
tslib: "npm:2.8.1"
917+
peerDependencies:
918+
react: ^17.0.0 || ^18.0.0
919+
react-dom: ^17.0.0 || ^18.0.0
920+
checksum: e0bdce896e10910973c422eb9626e86375731abd53223f06f77daa717da30fb04457d5ed71d54d51c323a037518c722d947d8b50b869cc65a3bcd4c0c690d76d
921+
languageName: node
922+
linkType: hard
923+
924+
"@automattic/charts@npm:^0.46.1":
889925
version: 0.46.1
890926
resolution: "@automattic/charts@npm:0.46.1"
891927
dependencies:
@@ -1800,14 +1836,14 @@ __metadata:
18001836
languageName: unknown
18011837
linkType: soft
18021838

1803-
"@automattic/number-formatters@npm:^1.0.1, @automattic/number-formatters@npm:^1.0.14":
1804-
version: 1.0.14
1805-
resolution: "@automattic/number-formatters@npm:1.0.14"
1839+
"@automattic/number-formatters@npm:^1.0.1, @automattic/number-formatters@npm:^1.0.14, @automattic/number-formatters@npm:^1.0.15":
1840+
version: 1.0.15
1841+
resolution: "@automattic/number-formatters@npm:1.0.15"
18061842
dependencies:
18071843
"@wordpress/date": "npm:^5.19.0"
18081844
debug: "npm:^4.4.0"
18091845
tslib: "npm:^2.5.0"
1810-
checksum: 271214c5a2b5363a5e85b12f4773ec02d52fcd214d41e6877f780287684f279e8c194128c7f4a57e66fde51f37f4243579666216ef437a4ed4b69e2229abfe8b
1846+
checksum: 033aee63dbb320d3ab6e34eec73453bf434911123371501014027fed5251793bedf96047d7158ef326cfc35fe75175dbe48a6c53f2343ec91004d43c007ea022
18111847
languageName: node
18121848
linkType: hard
18131849

@@ -38491,7 +38527,7 @@ __metadata:
3849138527
"@automattic/calypso-razorpay": "workspace:^"
3849238528
"@automattic/calypso-router": "workspace:^"
3849338529
"@automattic/calypso-storybook": "workspace:^"
38494-
"@automattic/charts": "npm:^0.46.1"
38530+
"@automattic/charts": "npm:^0.50.0"
3849538531
"@automattic/color-studio": "npm:^4.1.0"
3849638532
"@automattic/command-palette": "workspace:^"
3849738533
"@automattic/components": "workspace:^"

0 commit comments

Comments
 (0)