Skip to content

Commit a934444

Browse files
committed
chore: upgrade echarts-for-react version
1 parent c7b5d8a commit a934444

File tree

4 files changed

+122
-78
lines changed

4 files changed

+122
-78
lines changed

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@reactpress/client",
33
"version": "1.0.0",
4-
"private": true,
54
"scripts": {
65
"prebuild": "rimraf .next",
76
"build": "next build",
@@ -51,7 +50,9 @@
5150
"react-visibility-sensor": "^5.1.1",
5251
"showdown": "^1.9.1",
5352
"viewerjs": "^1.5.0",
54-
"xml": "^1.0.1"
53+
"xml": "^1.0.1",
54+
"echarts-for-react": "^3.0.2",
55+
"echarts": "^5.6.0"
5556
},
5657
"devDependencies": {
5758
"@types/node": "17.0.22",

client/pages/admin/article/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React, { useCallback, useEffect, useState } from 'react';
66

77
import { LocaleTime } from '@/components/LocaleTime';
88
import { PaginationTable } from '@/components/PaginationTable';
9-
// import { ViewChart } from '@/components/ViewChart';
9+
import { ViewChart } from '@/components/ViewChart';
1010
import { getRandomColor } from '@/constants';
1111
import { useAsyncLoading } from '@/hooks/useAsyncLoading';
1212
import { usePagination } from '@/hooks/usePagination';
@@ -338,7 +338,7 @@ const Article: NextPage = () => {
338338
>
339339
<div style={{ textAlign: 'center' }}>
340340
<Spin spinning={getViewsLoading}>
341-
{/* <ViewChart data={views} /> */}
341+
<ViewChart data={views} />
342342
</Spin>
343343
</div>
344344
</Modal>
Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dateFormat from 'date-fns/format';
2-
// import echarts from 'echarts';
3-
// import ReactEcharts from 'echarts-for-react';
2+
import ReactEcharts from 'echarts-for-react';
3+
import * as echarts from 'echarts';
44
import React from 'react';
55

66
import { groupBy } from '@/utils';
@@ -22,74 +22,73 @@ export const ViewChart: React.FC<IProps> = ({ data: propsData = [] }) => {
2222
return a;
2323
}, []);
2424

25-
// const option = {
26-
// grid: {
27-
// top: '3%',
28-
// left: '3%',
29-
// right: '4%',
30-
// bottom: '3%',
31-
// containLabel: true,
32-
// },
33-
// tooltip: {
34-
// trigger: 'axis',
35-
// formatter(d) {
36-
// const target = d && d[0] && data[d[0].dataIndex];
25+
const option = {
26+
grid: {
27+
top: '3%',
28+
left: '3%',
29+
right: '4%',
30+
bottom: '3%',
31+
containLabel: true,
32+
},
33+
tooltip: {
34+
trigger: 'axis',
35+
formatter(d) {
36+
const target = d && d[0] && data[d[0].dataIndex];
3737

38-
// return `日期:${target.updateAt}<br />访问量:${target.count}`;
39-
// },
40-
// },
41-
// xAxis: {
42-
// type: 'category',
43-
// boundaryGap: false,
44-
// data: data.map((d) => d.updateAt),
45-
// },
46-
// yAxis: {
47-
// type: 'value',
48-
// boundaryGap: [0, '100%'],
49-
// },
50-
// dataZoom: [
51-
// {
52-
// type: 'inside',
53-
// },
54-
// {
55-
// handleIcon:
56-
// 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
57-
// handleSize: '80%',
58-
// handleStyle: {
59-
// color: 'var(--bg)',
60-
// shadowBlur: 3,
61-
// shadowColor: 'rgba(0, 0, 0, 0.6)',
62-
// shadowOffsetX: 2,
63-
// shadowOffsetY: 2,
64-
// },
65-
// },
66-
// ],
67-
// series: [
68-
// {
69-
// type: 'line',
70-
// smooth: true,
71-
// symbol: 'none',
72-
// sampling: 'average',
73-
// itemStyle: {
74-
// color: 'rgb(255, 70, 131)',
75-
// },
76-
// areaStyle: {
77-
// color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
78-
// {
79-
// offset: 0,
80-
// color: 'rgb(255, 158, 68)',
81-
// },
82-
// {
83-
// offset: 1,
84-
// color: 'rgb(255, 70, 131)',
85-
// },
86-
// ]),
87-
// },
88-
// data: data.map((d) => d.count),
89-
// },
90-
// ],
91-
// };
92-
// TOOD: replace echarts with antd-charts
93-
// return <ReactEcharts option={option} />;
94-
return null;
38+
return `日期:${target.updateAt}<br />访问量:${target.count}`;
39+
},
40+
},
41+
xAxis: {
42+
type: 'category',
43+
boundaryGap: false,
44+
data: data.map((d) => d.updateAt),
45+
},
46+
yAxis: {
47+
type: 'value',
48+
boundaryGap: [0, '100%'],
49+
},
50+
dataZoom: [
51+
{
52+
type: 'inside',
53+
},
54+
{
55+
handleIcon:
56+
'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
57+
handleSize: '80%',
58+
handleStyle: {
59+
color: 'var(--bg)',
60+
shadowBlur: 3,
61+
shadowColor: 'rgba(0, 0, 0, 0.6)',
62+
shadowOffsetX: 2,
63+
shadowOffsetY: 2,
64+
},
65+
},
66+
],
67+
series: [
68+
{
69+
type: 'line',
70+
smooth: true,
71+
symbol: 'none',
72+
sampling: 'average',
73+
itemStyle: {
74+
color: 'rgb(255, 70, 131)',
75+
},
76+
areaStyle: {
77+
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
78+
{
79+
offset: 0,
80+
color: 'rgb(255, 158, 68)',
81+
},
82+
{
83+
offset: 1,
84+
color: 'rgb(255, 70, 131)',
85+
},
86+
]),
87+
},
88+
data: data.map((d) => d.count),
89+
},
90+
],
91+
};
92+
93+
return <ReactEcharts key={JSON.stringify(option)} option={option} />;
9594
};

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)