Skip to content

Commit 8240a22

Browse files
authored
Update echarts to v6 (#1517)
1 parent 6779e58 commit 8240a22

File tree

3 files changed

+60
-46
lines changed

3 files changed

+60
-46
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"clsx": "^2.1.1",
2626
"dayjs": "^1.11.18",
2727
"docusaurus-plugin-sass": "^0.2.6",
28-
"echarts": "^5.6.0",
28+
"echarts": "^6.0.0",
2929
"embla-carousel-auto-scroll": "^8.6.0",
3030
"embla-carousel-react": "^8.6.0",
3131
"fetch-jsonp": "^1.3.0",
@@ -57,5 +57,10 @@
5757
},
5858
"engines": {
5959
"node": ">=20.0"
60+
},
61+
"overrides": {
62+
"@kbox-labs/react-echarts": {
63+
"echarts": "$echarts"
64+
}
6065
}
6166
}
Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1+
import type { SeriesOption } from 'echarts';
12
import type { ModuleDownloadsChart } from '@site/src/types/marketplace';
2-
import { EChart } from '@kbox-labs/react-echarts';
3+
import { useMemo } from 'react';
4+
import { EChart, EChartProps } from '@kbox-labs/react-echarts';
5+
6+
const eChartStaticProps: EChartProps = {
7+
renderer: 'svg',
8+
style: {
9+
height: '300px',
10+
width: '100%',
11+
},
12+
grid: {
13+
left: 40,
14+
top: 40,
15+
right: 0,
16+
bottom: 40,
17+
},
18+
xAxis: {
19+
type: 'category',
20+
axisLabel: {
21+
color: '#fff',
22+
},
23+
boundaryGap: false,
24+
},
25+
yAxis: {
26+
type: 'value',
27+
axisLabel: {
28+
color: '#fff',
29+
},
30+
},
31+
};
332

433
type Props = {
534
downloads: ModuleDownloadsChart[];
@@ -8,42 +37,22 @@ type Props = {
837
export default function MarketplaceDetailsChart({ downloads }: Props) {
938
if (!downloads.length) return null;
1039

11-
return (
12-
<EChart
13-
renderer={'svg'}
14-
style={{
15-
height: '300px',
16-
width: '100%',
17-
}}
18-
grid={{
19-
left: 40,
20-
top: 40,
21-
right: 0,
22-
bottom: 40,
23-
}}
24-
xAxis={{
25-
type: 'category',
26-
boundaryGap: false,
27-
}}
28-
yAxis={{
29-
type: 'value',
30-
}}
31-
textStyle={{
32-
color: '#fff',
33-
}}
34-
series={[
35-
{
36-
type: 'line',
37-
data: downloads,
38-
lineStyle: {
39-
color: 'var(--ifm-color-primary-darkest)',
40-
},
41-
areaStyle: {
42-
color: 'var(--ifm-color-primary-darkest)',
43-
},
44-
silent: true,
40+
const eChartSeries: SeriesOption[] = useMemo(
41+
() => [
42+
{
43+
type: 'line',
44+
data: downloads,
45+
lineStyle: {
46+
color: 'var(--ifm-color-primary-darkest)',
4547
},
46-
]}
47-
/>
48+
areaStyle: {
49+
color: 'var(--ifm-color-primary-darkest)',
50+
},
51+
silent: true,
52+
},
53+
],
54+
[],
4855
);
56+
57+
return <EChart {...eChartStaticProps} series={eChartSeries} />;
4958
}

0 commit comments

Comments
 (0)