pixel-react-excel-sheet 1.0.38 → 1.0.40
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.
- package/lib/components/Button/Button.d.ts +2 -2
- package/lib/components/Charts/DashboardDonutChart/types.d.ts +3 -0
- package/lib/components/Charts/LineChart/types.d.ts +1 -0
- package/lib/components/ChooseFile/ChooseFile.d.ts +3 -2
- package/lib/components/Comment/Comments.d.ts +1 -1
- package/lib/components/Comment/type.d.ts +3 -3
- package/lib/components/ConditionalDropdown/types.d.ts +4 -0
- package/lib/components/DatePicker/types.d.ts +2 -0
- package/lib/components/Drawer/Types.d.ts +3 -0
- package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +11 -10
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.d.ts +10 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.d.ts +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +9 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +0 -3
- package/lib/components/Excel/Types.d.ts +15 -11
- package/lib/components/FF_Captcha/Recaptcha.d.ts +2 -1
- package/lib/components/FF_Captcha/types.d.ts +11 -2
- package/lib/components/Input/types.d.ts +4 -0
- package/lib/components/LabelEditTextField/types.d.ts +2 -0
- package/lib/components/MobileSkin/MobileSkin.d.ts +5 -0
- package/lib/components/MobileSkin/MobileSkinInterface.d.ts +13 -0
- package/lib/components/MobileSkin/index.d.ts +1 -0
- package/lib/components/MobileSkin/types.d.ts +32 -0
- package/lib/components/Search/Search.d.ts +1 -1
- package/lib/components/Search/types.d.ts +1 -0
- package/lib/components/Select/components/types.d.ts +3 -2
- package/lib/components/Select/types.d.ts +10 -2
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/Branches/types.d.ts +1 -0
- package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/types.d.ts +1 -0
- package/lib/components/SequentialConnectingBranch/types.d.ts +1 -0
- package/lib/components/TableTree/types.d.ts +4 -4
- package/lib/components/Tabs/types.d.ts +1 -0
- package/lib/index.d.ts +96 -40
- package/lib/index.esm.js +4816 -1669
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +4829 -1669
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/formData/ConvertFormDataToObject.d.ts +1 -0
- package/lib/utils/keyBoardActionUtil/UseKeyboardActions.d.ts +2 -0
- package/lib/utils/keyBoardActionUtil/types.d.ts +4 -0
- package/lib/validations/regex.d.ts +11 -1
- package/package.json +6 -1
- package/src/assets/Themes/BaseTheme.scss +3 -1
- package/src/assets/Themes/DarkTheme.scss +10 -1
- package/src/assets/icons/clear_cache.svg +5 -0
- package/src/assets/icons/external_user.svg +13 -0
- package/src/assets/icons/group_user.svg +12 -0
- package/src/assets/icons/single_user.svg +12 -0
- package/src/assets/icons/test_freshers_logo.svg +8 -0
- package/src/assets/icons/unfollow_icon.svg +3 -0
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +7 -45
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +5 -0
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +76 -64
- package/src/components/Button/Button.scss +0 -1
- package/src/components/Button/Button.tsx +3 -4
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +38 -6
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +10 -4
- package/src/components/Charts/DashboardDonutChart/types.ts +4 -1
- package/src/components/Charts/LineChart/LineChart.stories.tsx +27 -88
- package/src/components/Charts/LineChart/LineChart.tsx +138 -42
- package/src/components/Charts/LineChart/types.ts +1 -0
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.scss +3 -3
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.tsx +47 -43
- package/src/components/ChooseFile/ChooseFile.tsx +3 -4
- package/src/components/Comment/Comments.scss +0 -1
- package/src/components/Comment/Comments.stories.tsx +22 -4
- package/src/components/Comment/Comments.tsx +20 -1
- package/src/components/Comment/type.ts +3 -3
- package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +1 -0
- package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +2 -1
- package/src/components/ConditionalDropdown/types.ts +4 -0
- package/src/components/DatePicker/DatePicker.scss +307 -2
- package/src/components/DatePicker/DatePicker.tsx +27 -19
- package/src/components/DatePicker/types.ts +4 -0
- package/src/components/Drawer/Drawer.stories.tsx +1 -1
- package/src/components/Drawer/Types.ts +4 -2
- package/src/components/Editor/Editor.scss +23 -18
- package/src/components/Editor/Editor.tsx +2 -2
- package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +6 -3
- package/src/components/Excel/ExcelFile/ExcelFile.scss +45 -41
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +70 -64
- package/src/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.tsx +29 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +1 -37
- package/src/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.tsx +1 -40
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +3 -3
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +14 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +3 -0
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +8 -74
- package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +0 -5
- package/src/components/Excel/ExcelFile.stories.tsx +116 -125
- package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +10 -11
- package/src/components/Excel/Types.ts +18 -16
- package/src/components/FF_Captcha/Recaptcha.tsx +19 -9
- package/src/components/FF_Captcha/types.ts +12 -4
- package/src/components/Icon/Icon.stories.tsx +56 -8
- package/src/components/Icon/iconList.ts +13 -1
- package/src/components/Input/Input.stories.tsx +12 -0
- package/src/components/Input/Input.tsx +3 -1
- package/src/components/Input/types.ts +4 -0
- package/src/components/InputWithDropdown/types.ts +1 -1
- package/src/components/LabelEditTextField/LabelEditTextField.scss +4 -0
- package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +2 -1
- package/src/components/LabelEditTextField/LabelEditTextField.tsx +14 -10
- package/src/components/LabelEditTextField/types.ts +2 -0
- package/src/components/LazyLoad/LazyLoad.stories.tsx +1 -0
- package/src/components/LazyLoad/LazyLoading.tsx +10 -1
- package/src/components/MachineInputField/MachineInputField.scss +5 -1
- package/src/components/MachineInputField/MachineInputField.tsx +1 -0
- package/src/components/MobileSkin/MobileSkin.scss +67 -0
- package/src/components/MobileSkin/MobileSkin.stories.tsx +93 -0
- package/src/components/MobileSkin/MobileSkin.tsx +89 -0
- package/src/components/MobileSkin/MobileSkinInterface.ts +13 -0
- package/src/components/MobileSkin/index.ts +1 -0
- package/src/components/MobileSkin/types.ts +32 -0
- package/src/components/Modal/Modal.stories.tsx +7 -0
- package/src/components/Modal/Modal.tsx +17 -20
- package/src/components/Search/Search.scss +8 -0
- package/src/components/Search/Search.tsx +17 -6
- package/src/components/Search/types.ts +1 -0
- package/src/components/Select/Select.stories.tsx +85 -0
- package/src/components/Select/Select.tsx +10 -2
- package/src/components/Select/components/Dropdown.tsx +23 -15
- package/src/components/Select/components/types.ts +3 -2
- package/src/components/Select/types.ts +12 -2
- package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.tsx +2 -0
- package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +65 -57
- package/src/components/SequentialConnectingBranch/components/Branches/types.ts +1 -0
- package/src/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.tsx +2 -0
- package/src/components/SequentialConnectingBranch/components/ConnectingBranches/types.ts +1 -0
- package/src/components/SequentialConnectingBranch/types.ts +5 -1
- package/src/components/TableTree/Components/TableCell.tsx +3 -3
- package/src/components/TableTree/TableTree.scss +0 -7
- package/src/components/TableTree/TableTree.tsx +3 -22
- package/src/components/TableTree/types.ts +4 -4
- package/src/components/Tabs/Tabs.scss +19 -0
- package/src/components/Tabs/Tabs.tsx +9 -0
- package/src/components/Tabs/types.ts +1 -0
- package/src/index.ts +27 -0
- package/src/utils/formData/ConvertFormDataToObject.stories.tsx +27 -0
- package/src/utils/formData/ConvertFormDataToObject.ts +14 -0
- package/src/utils/getExtension/getExtension.stories.tsx +1 -0
- package/src/utils/keyBoardActionUtil/UseKeyboardAction.stories.tsx +53 -0
- package/src/utils/keyBoardActionUtil/UseKeyboardActions.tsx +20 -0
- package/src/utils/keyBoardActionUtil/types.ts +4 -0
- package/src/validations/regex.stories.tsx +63 -0
- package/src/validations/regex.ts +34 -0
- package/src/assets/images/photo.png +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
2
|
import './Button.scss';
|
|
3
3
|
import '../../assets/styles/_colors.scss';
|
|
4
4
|
import Icon from '../Icon';
|
|
@@ -6,8 +6,7 @@ import { ButtonProps } from './types';
|
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import Typography from '../Typography';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
prevProps.selectedFile?.name === nextProps.selectedFile?.name;
|
|
9
|
+
|
|
11
10
|
|
|
12
11
|
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
13
12
|
(
|
|
@@ -88,4 +87,4 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
88
87
|
);
|
|
89
88
|
}
|
|
90
89
|
);
|
|
91
|
-
export default
|
|
90
|
+
export default Button;
|
|
@@ -22,16 +22,47 @@ export const Default: Story = {
|
|
|
22
22
|
legendDetailsType: 'Scripts',
|
|
23
23
|
isLegendDetails: true,
|
|
24
24
|
statusValues: [
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
{
|
|
26
|
+
key: 'Passed',
|
|
27
|
+
value: 60,
|
|
28
|
+
color: 'var(--status-success-text-color)',
|
|
29
|
+
percentage: '',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: 'failed',
|
|
33
|
+
value: 20,
|
|
34
|
+
color: 'var(--status-rejected-text-color)',
|
|
35
|
+
percentage: '',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'Warning',
|
|
39
|
+
value: 10,
|
|
40
|
+
color: 'var(--status-warning-text-color)',
|
|
41
|
+
percentage: '',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: 'skipped',
|
|
45
|
+
value: 10,
|
|
46
|
+
color: 'var(--status-button-text-skipped)',
|
|
47
|
+
percentage: '',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: 'Warning',
|
|
51
|
+
value: 0,
|
|
52
|
+
color: 'var(--status-warning-text-color)',
|
|
53
|
+
percentage: '',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'skipped',
|
|
57
|
+
value: 7,
|
|
58
|
+
color: 'var(--status-button-text-skipped)',
|
|
59
|
+
percentage: '',
|
|
60
|
+
},
|
|
31
61
|
],
|
|
32
62
|
gapAngle: 0,
|
|
33
63
|
legendType: 'numberLegend',
|
|
34
64
|
showOnlyLabel: false,
|
|
65
|
+
apiDataLabel:""
|
|
35
66
|
},
|
|
36
67
|
};
|
|
37
68
|
|
|
@@ -54,5 +85,6 @@ export const MemoryLegend: Story = {
|
|
|
54
85
|
],
|
|
55
86
|
gapAngle: 0,
|
|
56
87
|
legendType: 'memoryLegend',
|
|
88
|
+
apiDataLabel:""
|
|
57
89
|
},
|
|
58
90
|
};
|
|
@@ -48,6 +48,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
|
|
|
48
48
|
isLegendDetails = true,
|
|
49
49
|
legendType = 'numberLegend',
|
|
50
50
|
showOnlyLabel = false,
|
|
51
|
+
apiDataLabel,
|
|
51
52
|
unit,
|
|
52
53
|
showUnit = true,
|
|
53
54
|
labelFontSize = 24,
|
|
@@ -104,6 +105,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
|
|
|
104
105
|
color: item.color,
|
|
105
106
|
unit: item.unit,
|
|
106
107
|
labelValue: item.labelValue,
|
|
108
|
+
percentage: item.percentage,
|
|
107
109
|
}));
|
|
108
110
|
|
|
109
111
|
const total = chartValues?.reduce((acc, { value }) => acc + value, 0);
|
|
@@ -368,9 +370,13 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
|
|
|
368
370
|
<Typography fontSize={10}>{item.key}</Typography>
|
|
369
371
|
</td>
|
|
370
372
|
<td className="ff-legend-percentage">
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
373
|
+
<td className="ff-legend-percentage">
|
|
374
|
+
{item.percentage
|
|
375
|
+
? item.percentage
|
|
376
|
+
: typeof item.value === 'string'
|
|
377
|
+
? ((parseFloat(item.value) / total) * 100).toFixed(1)
|
|
378
|
+
: ((item.value / total) * 100).toFixed(1)}
|
|
379
|
+
</td>
|
|
374
380
|
</td>
|
|
375
381
|
<td className="ff-legend-count">{item.value}</td>
|
|
376
382
|
</tr>
|
|
@@ -509,7 +515,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
|
|
|
509
515
|
dy={index === 0 ? 0 : labelFontSize}
|
|
510
516
|
key={index}
|
|
511
517
|
>
|
|
512
|
-
{line}
|
|
518
|
+
{apiDataLabel ? apiDataLabel : line}
|
|
513
519
|
</tspan>
|
|
514
520
|
))}
|
|
515
521
|
</text>
|
|
@@ -17,6 +17,7 @@ export type ChartItem = {
|
|
|
17
17
|
key: string;
|
|
18
18
|
value: string | number;
|
|
19
19
|
color?: string;
|
|
20
|
+
percentage?: string | number;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export type NormalizedChartItem = {
|
|
@@ -26,6 +27,7 @@ export type NormalizedChartItem = {
|
|
|
26
27
|
normalizedValue?: number;
|
|
27
28
|
unit?: string;
|
|
28
29
|
labelValue?: number;
|
|
30
|
+
percentage?: string | number;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
export type LegendType =
|
|
@@ -42,6 +44,7 @@ export type DashboardDonutChartProps = {
|
|
|
42
44
|
isLegendDetails: boolean;
|
|
43
45
|
gapAngle?: number;
|
|
44
46
|
legendType: LegendType;
|
|
47
|
+
apiDataLabel: string | number;
|
|
45
48
|
showOnlyLabel?: boolean;
|
|
46
49
|
unit?: string;
|
|
47
50
|
showUnit?: boolean;
|
|
@@ -51,7 +54,7 @@ export type DashboardDonutChartProps = {
|
|
|
51
54
|
chartGap?: number;
|
|
52
55
|
legendGap?: number;
|
|
53
56
|
tableWidth?: number;
|
|
54
|
-
tableHeight?:number;
|
|
57
|
+
tableHeight?: number;
|
|
55
58
|
legendValueFontSize?: number;
|
|
56
59
|
legendKeyFontSize?: number;
|
|
57
60
|
labelYoffSet?: number;
|
|
@@ -22,31 +22,24 @@ export const DefaultLineChart: StoryObj<LineChartProps> = {
|
|
|
22
22
|
data: [
|
|
23
23
|
{
|
|
24
24
|
date: '25 Oct',
|
|
25
|
-
totalMemory:
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
date: '26 Oct',
|
|
29
|
-
totalMemory: 9.86,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
date: '27 Oct',
|
|
33
|
-
totalMemory: 9.86,
|
|
25
|
+
totalMemory: '1 GB',
|
|
34
26
|
},
|
|
27
|
+
|
|
35
28
|
{
|
|
36
|
-
date: '
|
|
37
|
-
totalMemory:
|
|
29
|
+
date: '29 Oct',
|
|
30
|
+
totalMemory: '200 KB',
|
|
38
31
|
},
|
|
39
32
|
{
|
|
40
|
-
date: '
|
|
41
|
-
totalMemory:
|
|
33
|
+
date: '30 Oct',
|
|
34
|
+
totalMemory: '40 MB',
|
|
42
35
|
},
|
|
43
36
|
{
|
|
44
37
|
date: '3 Nov',
|
|
45
|
-
totalMemory:
|
|
38
|
+
totalMemory: '20 MB',
|
|
46
39
|
},
|
|
47
40
|
{
|
|
48
41
|
date: '23 Nov',
|
|
49
|
-
totalMemory:
|
|
42
|
+
totalMemory: '90 MB',
|
|
50
43
|
},
|
|
51
44
|
],
|
|
52
45
|
},
|
|
@@ -60,7 +53,8 @@ export const DefaultLineChart: StoryObj<LineChartProps> = {
|
|
|
60
53
|
xAxisColor: '#D9D9D9',
|
|
61
54
|
yAxisColor: '#252C37',
|
|
62
55
|
numberSize: '10px',
|
|
63
|
-
proportionalSpacing
|
|
56
|
+
proportionalSpacing: false,
|
|
57
|
+
chartName: 'memory',
|
|
64
58
|
},
|
|
65
59
|
render: (args) => (
|
|
66
60
|
<div className="linechart-container">
|
|
@@ -72,74 +66,18 @@ export const DefaultLineChart: StoryObj<LineChartProps> = {
|
|
|
72
66
|
export const multiLineScriptsChart: StoryObj<LineChartProps> = {
|
|
73
67
|
args: {
|
|
74
68
|
data: [
|
|
75
|
-
{
|
|
76
|
-
color: '#179C5F',
|
|
77
|
-
name: 'Success',
|
|
78
|
-
show: true,
|
|
79
|
-
data: [
|
|
80
|
-
{ date: '1 oct', value: 10 },
|
|
81
|
-
{ date: '2 oct', value: 20 },
|
|
82
|
-
{ date: '3 oct', value: 30 },
|
|
83
|
-
{ date: '4 oct', value: 26 },
|
|
84
|
-
{ date: '5 oct', value: 90 },
|
|
85
|
-
{ date: '6 oct', value: 10 },
|
|
86
|
-
{ date: '7 oct', value: 12 },
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
color: '#9C1732',
|
|
91
|
-
name: 'Failed',
|
|
92
|
-
show: true,
|
|
93
|
-
data: [
|
|
94
|
-
{ date: '1 oct', value: 50 },
|
|
95
|
-
{ date: '2 oct', value: 30 },
|
|
96
|
-
{ date: '3 oct', value: 40 },
|
|
97
|
-
{ date: '4 oct', value: 20 },
|
|
98
|
-
{ date: '5 oct', value: 90 },
|
|
99
|
-
{ date: '6 oct', value: 70 },
|
|
100
|
-
{ date: '7 oct', value: 30 },
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
color: '#E2750F',
|
|
105
|
-
name: 'Warning',
|
|
106
|
-
show: true,
|
|
107
|
-
data: [
|
|
108
|
-
{ date: '1 oct', value: 10 },
|
|
109
|
-
{ date: '2 oct', value: 20 },
|
|
110
|
-
{ date: '3 oct', value: 99 },
|
|
111
|
-
{ date: '4 oct', value: 20 },
|
|
112
|
-
{ date: '5 oct', value: 10 },
|
|
113
|
-
{ date: '6 oct', value: 10 },
|
|
114
|
-
{ date: '7 oct', value: 10 },
|
|
115
|
-
],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
color: '#A83FC4',
|
|
119
|
-
name: 'Skipped',
|
|
120
|
-
show: true,
|
|
121
|
-
data: [
|
|
122
|
-
{ date: '1 oct', value: 40 },
|
|
123
|
-
{ date: '2 oct', value: 10 },
|
|
124
|
-
{ date: '3 oct', value: 10 },
|
|
125
|
-
{ date: '4 oct', value: 20 },
|
|
126
|
-
{ date: '5 oct', value: 10 },
|
|
127
|
-
{ date: '6 oct', value: 30 },
|
|
128
|
-
{ date: '7 oct', value: 10 },
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
69
|
{
|
|
132
70
|
color: '#3F5AC4',
|
|
133
71
|
name: 'Flaky',
|
|
134
72
|
show: true,
|
|
135
73
|
data: [
|
|
136
|
-
{ date: '1 oct', value:
|
|
137
|
-
{ date: '2 oct', value:
|
|
138
|
-
{ date: '3 oct', value:
|
|
139
|
-
{ date: '4 oct', value:
|
|
140
|
-
{ date: '5 oct', value:
|
|
141
|
-
{ date: '6 oct', value:
|
|
142
|
-
{ date: '7 oct', value:
|
|
74
|
+
{ date: '1 oct', value: 10 },
|
|
75
|
+
{ date: '2 oct', value: 0 },
|
|
76
|
+
{ date: '3 oct', value: 0 },
|
|
77
|
+
{ date: '4 oct', value: 0 },
|
|
78
|
+
{ date: '5 oct', value: 0 },
|
|
79
|
+
{ date: '6 oct', value: 0 },
|
|
80
|
+
{ date: '7 oct', value: 0 },
|
|
143
81
|
],
|
|
144
82
|
},
|
|
145
83
|
],
|
|
@@ -154,8 +92,8 @@ export const multiLineScriptsChart: StoryObj<LineChartProps> = {
|
|
|
154
92
|
yAxisColor: '#252C37',
|
|
155
93
|
yAxisLabelColor: '#252C37',
|
|
156
94
|
textSize: '12px',
|
|
157
|
-
proportionalSpacing
|
|
158
|
-
|
|
95
|
+
proportionalSpacing: false,
|
|
96
|
+
chartName: 'scripts',
|
|
159
97
|
},
|
|
160
98
|
render: (args) => (
|
|
161
99
|
<div className="linechart-container">
|
|
@@ -186,12 +124,12 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
|
|
|
186
124
|
show: true,
|
|
187
125
|
data: [
|
|
188
126
|
{ date: '1 oct', value: 50 },
|
|
189
|
-
{ date: '2 oct', value:
|
|
127
|
+
{ date: '2 oct', value: 0 },
|
|
190
128
|
{ date: '3 oct', value: 40 },
|
|
191
129
|
{ date: '4 oct', value: 20 },
|
|
192
130
|
{ date: '5 oct', value: 90 },
|
|
193
131
|
{ date: '6 oct', value: 70 },
|
|
194
|
-
{ date: '7 oct', value:
|
|
132
|
+
{ date: '7 oct', value: 0 },
|
|
195
133
|
],
|
|
196
134
|
},
|
|
197
135
|
{
|
|
@@ -201,7 +139,7 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
|
|
|
201
139
|
data: [
|
|
202
140
|
{ date: '1 oct', value: 10 },
|
|
203
141
|
{ date: '2 oct', value: 20 },
|
|
204
|
-
{ date: '3 oct', value:
|
|
142
|
+
{ date: '3 oct', value: 0 },
|
|
205
143
|
{ date: '4 oct', value: 20 },
|
|
206
144
|
{ date: '5 oct', value: 10 },
|
|
207
145
|
{ date: '6 oct', value: 10 },
|
|
@@ -213,13 +151,13 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
|
|
|
213
151
|
name: 'Skipped',
|
|
214
152
|
show: true,
|
|
215
153
|
data: [
|
|
216
|
-
{ date: '1 oct', value:
|
|
154
|
+
{ date: '1 oct', value: 0 },
|
|
217
155
|
{ date: '2 oct', value: 20 },
|
|
218
156
|
{ date: '3 oct', value: 10 },
|
|
219
157
|
{ date: '4 oct', value: 20 },
|
|
220
158
|
{ date: '5 oct', value: 10 },
|
|
221
159
|
{ date: '6 oct', value: 30 },
|
|
222
|
-
{ date: '7 oct', value:
|
|
160
|
+
{ date: '7 oct', value: 0 },
|
|
223
161
|
],
|
|
224
162
|
},
|
|
225
163
|
{
|
|
@@ -231,7 +169,7 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
|
|
|
231
169
|
{ date: '2 oct', value: 40 },
|
|
232
170
|
{ date: '3 oct', value: 30 },
|
|
233
171
|
{ date: '4 oct', value: 20 },
|
|
234
|
-
{ date: '5 oct', value:
|
|
172
|
+
{ date: '5 oct', value: 0 },
|
|
235
173
|
{ date: '6 oct', value: 40 },
|
|
236
174
|
{ date: '7 oct', value: 20 },
|
|
237
175
|
],
|
|
@@ -249,7 +187,8 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
|
|
|
249
187
|
yAxisLabelColor: '#252C37',
|
|
250
188
|
textSize: '12px',
|
|
251
189
|
fontWeight: 'semi-bold',
|
|
252
|
-
proportionalSpacing
|
|
190
|
+
proportionalSpacing: false,
|
|
191
|
+
chartName: 'defects',
|
|
253
192
|
},
|
|
254
193
|
render: (args) => (
|
|
255
194
|
<div className="linechart-container">
|
|
@@ -2,6 +2,11 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { LineChartProps } from './types';
|
|
3
3
|
import './LineChart.scss';
|
|
4
4
|
import Typography from '../../Typography';
|
|
5
|
+
import {
|
|
6
|
+
MEMORY_VALIDATION_REGEX,
|
|
7
|
+
NUMBER_REGEX,
|
|
8
|
+
UNIT_REGEX,
|
|
9
|
+
} from '../../../validations/regex';
|
|
5
10
|
|
|
6
11
|
interface HoverState {
|
|
7
12
|
cursorX: number | null;
|
|
@@ -26,53 +31,121 @@ const LineChart: React.FC<LineChartProps> = ({
|
|
|
26
31
|
fontWeight,
|
|
27
32
|
numberSize,
|
|
28
33
|
proportionalSpacing,
|
|
34
|
+
chartName,
|
|
29
35
|
}) => {
|
|
30
36
|
const margin = 40;
|
|
31
37
|
const xMax = width - margin * 2;
|
|
32
38
|
const yMax = height - margin * 2;
|
|
33
39
|
|
|
40
|
+
const roundUp = (value: any, decimals = 2) => {
|
|
41
|
+
let unit = '';
|
|
42
|
+
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
const match = value.match(NUMBER_REGEX);
|
|
45
|
+
const unitMatch = value.match(UNIT_REGEX);
|
|
46
|
+
if (match) {
|
|
47
|
+
value = parseFloat(match[0]);
|
|
48
|
+
}
|
|
49
|
+
if (unitMatch) {
|
|
50
|
+
unit = unitMatch[0];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const multiplier = Math.pow(10, decimals);
|
|
55
|
+
const roundedValue = Math.ceil(value * multiplier) / multiplier;
|
|
56
|
+
|
|
57
|
+
return `${roundedValue} ${unit}`.trim();
|
|
58
|
+
};
|
|
59
|
+
function convertToMB(input: any) {
|
|
60
|
+
if (!isNaN(input)) {
|
|
61
|
+
return parseFloat(input);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const regex = MEMORY_VALIDATION_REGEX;
|
|
65
|
+
const match = input.match(regex);
|
|
66
|
+
|
|
67
|
+
if (!match) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"Invalid input format. Use '<value> <unit>' format (e.g., '10.9580078125 KB') or just a number."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const value = parseFloat(match[1]);
|
|
74
|
+
const unit = match[2] ? match[2].toUpperCase() : null;
|
|
75
|
+
|
|
76
|
+
switch (unit) {
|
|
77
|
+
case 'GB':
|
|
78
|
+
return parseFloat((value * 1024).toFixed(2));
|
|
79
|
+
case 'MB':
|
|
80
|
+
return parseFloat(value.toFixed(2));
|
|
81
|
+
case 'KB':
|
|
82
|
+
return parseFloat((value / 1024).toFixed(2));
|
|
83
|
+
default:
|
|
84
|
+
throw new Error('Invalid unit. Supported units are GB, MB, and KB.');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
34
88
|
const isDefaultLineChart =
|
|
35
89
|
data[0]?.data[0]?.hasOwnProperty('date') &&
|
|
36
90
|
data[0]?.data[0]?.hasOwnProperty('totalMemory');
|
|
37
91
|
const xKey = isDefaultLineChart ? 'date' : 'date';
|
|
38
92
|
const yKey = isDefaultLineChart ? 'totalMemory' : 'value';
|
|
39
93
|
const xScale = (x: string) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
94
|
+
if (proportionalSpacing) {
|
|
95
|
+
const date = new Date(x);
|
|
96
|
+
const time = date.getTime();
|
|
97
|
+
const minDate = new Date(
|
|
98
|
+
Math.min(...data[0].data.map((d: any) => new Date(d[xKey]).getTime()))
|
|
99
|
+
);
|
|
100
|
+
const maxDate = new Date(
|
|
101
|
+
Math.max(...data[0].data.map((d: any) => new Date(d[xKey]).getTime()))
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
((time - minDate.getTime()) / (maxDate.getTime() - minDate.getTime())) *
|
|
106
|
+
xMax
|
|
107
|
+
);
|
|
108
|
+
} else {
|
|
109
|
+
const index = data[0].data.findIndex((point: any) => point[xKey] === x);
|
|
110
|
+
if (index === -1) return 0;
|
|
111
|
+
const totalPoints = data[0].data.length;
|
|
112
|
+
return (index / (totalPoints - 1)) * xMax;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
61
115
|
|
|
116
|
+
const maxValue = Math.max(
|
|
117
|
+
...data.flatMap((line) =>
|
|
118
|
+
line.data.map((point: any) => convertToMB(point[yKey]))
|
|
119
|
+
)
|
|
120
|
+
);
|
|
62
121
|
|
|
63
|
-
const yScale = (y: number) =>
|
|
122
|
+
const yScale = (y: number) => {
|
|
123
|
+
if (chartName === 'memory') {
|
|
124
|
+
const maxMemoryValue = Math.max(
|
|
125
|
+
...data.flatMap((line) =>
|
|
126
|
+
line.data.map((point: any) => convertToMB(point[yKey]))
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const scaleMax = maxMemoryValue > 1024 ? maxMemoryValue : 1024;
|
|
131
|
+
|
|
132
|
+
return yMax - (y * yMax) / scaleMax;
|
|
133
|
+
} else {
|
|
134
|
+
return yMax - (y * yMax) / (maxValue === 0 ? 1024 : maxValue);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
64
137
|
|
|
65
138
|
const generateLinePath = (lineData: { [key: string]: any }[]) =>
|
|
66
139
|
lineData.reduce((path, point, i) => {
|
|
67
140
|
const x = xScale(point[xKey]);
|
|
68
|
-
const y = yScale(point[yKey]);
|
|
141
|
+
const y = yScale(convertToMB(point[yKey]));
|
|
69
142
|
if (i === 0) {
|
|
70
143
|
return `M ${x} ${y}`;
|
|
71
144
|
}
|
|
72
145
|
|
|
73
146
|
const prevPoint = lineData[i - 1];
|
|
74
147
|
const prevX = prevPoint ? xScale(prevPoint[xKey]) : 0;
|
|
75
|
-
const prevY = prevPoint ? yScale(prevPoint[yKey]) : 0;
|
|
148
|
+
const prevY = prevPoint ? yScale(convertToMB(prevPoint[yKey])) : 0;
|
|
76
149
|
|
|
77
150
|
return `${path} C ${prevX + (x - prevX) / 2} ${prevY}, ${
|
|
78
151
|
x - (x - prevX) / 2
|
|
@@ -108,10 +181,10 @@ const LineChart: React.FC<LineChartProps> = ({
|
|
|
108
181
|
|
|
109
182
|
if (nearestPoint) {
|
|
110
183
|
nearestXValue = nearestPoint[xKey];
|
|
111
|
-
nearestValues.hoverValues[lineIndex] = nearestPoint[yKey];
|
|
184
|
+
nearestValues.hoverValues[lineIndex] = roundUp(nearestPoint[yKey]);
|
|
112
185
|
nearestValues.dotPositions[lineIndex] = {
|
|
113
186
|
x: nearestXValue ? xScale(nearestXValue) : 0,
|
|
114
|
-
y: yScale(nearestPoint[yKey]),
|
|
187
|
+
y: yScale(convertToMB(nearestPoint[yKey])),
|
|
115
188
|
};
|
|
116
189
|
}
|
|
117
190
|
});
|
|
@@ -243,22 +316,45 @@ const LineChart: React.FC<LineChartProps> = ({
|
|
|
243
316
|
</text>
|
|
244
317
|
))}
|
|
245
318
|
|
|
246
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
319
|
+
{chartName === 'memory'
|
|
320
|
+
? Array.from({ length: 6 }).map((_, i) => {
|
|
321
|
+
const dynamicMaxValue = maxValue < 1024 ? 1024 : maxValue;
|
|
322
|
+
const isSmallScale = maxValue < 1024;
|
|
323
|
+
const yValue = (i * dynamicMaxValue) / 5;
|
|
324
|
+
const displayValue = isSmallScale
|
|
325
|
+
? yValue / 1024
|
|
326
|
+
: yValue / 1024;
|
|
327
|
+
|
|
328
|
+
return (
|
|
329
|
+
<text
|
|
330
|
+
key={yValue}
|
|
331
|
+
x={-10}
|
|
332
|
+
y={yScale(yValue)}
|
|
333
|
+
textAnchor="end"
|
|
334
|
+
fill={yAxisValueColor}
|
|
335
|
+
className="ff-line-chart-y-axis-text"
|
|
336
|
+
style={{ fontSize: numberSize }}
|
|
337
|
+
>
|
|
338
|
+
{displayValue.toFixed(1)}
|
|
339
|
+
</text>
|
|
340
|
+
);
|
|
341
|
+
})
|
|
342
|
+
: Array.from({ length: 6 }).map((_, i) => {
|
|
343
|
+
const yValue = (i * maxValue) / 5;
|
|
344
|
+
return (
|
|
345
|
+
<text
|
|
346
|
+
key={yValue}
|
|
347
|
+
x={-10}
|
|
348
|
+
y={yScale(yValue)}
|
|
349
|
+
textAnchor="end"
|
|
350
|
+
fill={yAxisValueColor}
|
|
351
|
+
className="ff-line-chart-y-axis-text"
|
|
352
|
+
style={{ fontSize: numberSize }}
|
|
353
|
+
>
|
|
354
|
+
{yValue.toFixed(0)}
|
|
355
|
+
</text>
|
|
356
|
+
);
|
|
357
|
+
})}
|
|
262
358
|
</g>
|
|
263
359
|
</svg>
|
|
264
360
|
{hoverState.tooltip.visible && (
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
display: flex;
|
|
6
6
|
align-items: center;
|
|
7
|
-
|
|
7
|
+
gap: 16px;
|
|
8
8
|
&.ff-multi-radial-chart-number {
|
|
9
9
|
flex-direction: column;
|
|
10
10
|
}
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
background-color: var(--status-success-text-color);
|
|
69
69
|
color: var(--text-color);
|
|
70
70
|
border-radius: 15px;
|
|
71
|
-
min-width:
|
|
72
|
-
height:
|
|
71
|
+
min-width: 21px;
|
|
72
|
+
height: 15px;
|
|
73
73
|
display: flex;
|
|
74
74
|
justify-content: center;
|
|
75
75
|
align-items: center;
|