@wecodesolutions/shared-react-components-ts 0.12.6 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ChartProps {
|
|
3
|
+
startingAmount: number;
|
|
4
|
+
earnedAmount: number;
|
|
5
|
+
data: ChartData[];
|
|
6
|
+
}
|
|
7
|
+
interface ChartData {
|
|
8
|
+
date: string;
|
|
9
|
+
profit: number;
|
|
10
|
+
}
|
|
11
|
+
declare const Chart: React.FC<ChartProps>;
|
|
12
|
+
export default Chart;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.13.0",
|
|
3
3
|
"name": "@wecodesolutions/shared-react-components-ts",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"@storybook/react": "^8.4.5",
|
|
63
63
|
"@types/react": "^18.3.12",
|
|
64
64
|
"@types/react-dom": "^18.3.1",
|
|
65
|
+
"@types/recharts": "^1.8.29",
|
|
65
66
|
"babel-loader": "^9.2.1",
|
|
66
67
|
"husky": "^9.1.7",
|
|
67
68
|
"postcss": "^8.4.49",
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
79
|
"react-icons": "^5.3.0",
|
|
79
|
-
"react-router-dom": "^7.0.2"
|
|
80
|
+
"react-router-dom": "^7.0.2",
|
|
81
|
+
"recharts": "^2.14.1"
|
|
80
82
|
}
|
|
81
83
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* src/components/Chart.module.css */
|
|
2
|
+
|
|
3
|
+
.chartContainer {
|
|
4
|
+
max-width: 800px;
|
|
5
|
+
margin: 0 auto;
|
|
6
|
+
padding: 20px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
text-align: center;
|
|
11
|
+
margin-bottom: 30px;
|
|
12
|
+
color: #333;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.chartSummary {
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: space-around;
|
|
18
|
+
margin-bottom: 40px;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.summaryItem {
|
|
23
|
+
background-color: #f5f5f5;
|
|
24
|
+
padding: 20px;
|
|
25
|
+
border-radius: 8px;
|
|
26
|
+
text-align: center;
|
|
27
|
+
width: 45%;
|
|
28
|
+
margin-bottom: 20px;
|
|
29
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.summaryItem h3 {
|
|
33
|
+
margin-bottom: 10px;
|
|
34
|
+
color: #555;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.summaryItem p {
|
|
38
|
+
font-size: 1.5rem;
|
|
39
|
+
color: #000;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.chartArea {
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 400px;
|
|
45
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/components/Chart.tsx
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
LineChart,
|
|
5
|
+
Line,
|
|
6
|
+
XAxis,
|
|
7
|
+
YAxis,
|
|
8
|
+
CartesianGrid,
|
|
9
|
+
Tooltip,
|
|
10
|
+
Legend,
|
|
11
|
+
ResponsiveContainer,
|
|
12
|
+
} from 'recharts';
|
|
13
|
+
import styles from './Chart.module.css';
|
|
14
|
+
|
|
15
|
+
interface ChartProps {
|
|
16
|
+
startingAmount: number;
|
|
17
|
+
earnedAmount: number;
|
|
18
|
+
data: ChartData[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ChartData {
|
|
22
|
+
date: string;
|
|
23
|
+
profit: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Chart: React.FC<ChartProps> = ({
|
|
27
|
+
startingAmount,
|
|
28
|
+
earnedAmount,
|
|
29
|
+
data,
|
|
30
|
+
}) => {
|
|
31
|
+
// Formatter for currency display
|
|
32
|
+
const formatCurrency = (value: number): string => {
|
|
33
|
+
return `$${value.toLocaleString()}`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className={styles.chartContainer}>
|
|
38
|
+
<h2 className={styles.title}>Profit Overview (Daily)</h2>
|
|
39
|
+
<div className={styles.chartSummary}>
|
|
40
|
+
<div className={styles.summaryItem}>
|
|
41
|
+
<h3>Starting Amount</h3>
|
|
42
|
+
<p>{formatCurrency(startingAmount)}</p>
|
|
43
|
+
</div>
|
|
44
|
+
<div className={styles.summaryItem}>
|
|
45
|
+
<h3>Earned Amount</h3>
|
|
46
|
+
<p>{formatCurrency(earnedAmount)}</p>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div className={styles.chartArea}>
|
|
50
|
+
<ResponsiveContainer width="100%" height={400}>
|
|
51
|
+
<LineChart
|
|
52
|
+
data={data}
|
|
53
|
+
margin={{ top: 20, right: 30, left: 20, bottom: 5 }}
|
|
54
|
+
>
|
|
55
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
56
|
+
<XAxis
|
|
57
|
+
dataKey="date"
|
|
58
|
+
tick={{ fontSize: 12 }}
|
|
59
|
+
angle={-45}
|
|
60
|
+
textAnchor="end"
|
|
61
|
+
height={60}
|
|
62
|
+
/>
|
|
63
|
+
<YAxis tick={{ fontSize: 12 }} />
|
|
64
|
+
<Tooltip formatter={(value: number) => formatCurrency(value)} />
|
|
65
|
+
<Legend />
|
|
66
|
+
<Line
|
|
67
|
+
type="monotone"
|
|
68
|
+
dataKey="profit"
|
|
69
|
+
name="Cumulative Profit"
|
|
70
|
+
stroke="#82ca9d"
|
|
71
|
+
activeDot={{ r: 8 }}
|
|
72
|
+
/>
|
|
73
|
+
</LineChart>
|
|
74
|
+
</ResponsiveContainer>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Chart;
|