@tsiky/components-r19 1.0.0 → 1.2.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.
- package/index.ts +35 -33
- package/package.json +1 -1
- package/src/components/AnnouncementPanel/FlexRowContainer.css +17 -17
- package/src/components/AnnouncementPanel/FlexRowContainer.stories.tsx +329 -329
- package/src/components/AnnouncementPanel/FlexRowContainer.tsx +24 -24
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.css +56 -56
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.stories.tsx +292 -292
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.tsx +106 -106
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.css +57 -57
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.stories.tsx +189 -189
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.tsx +138 -138
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.css +61 -61
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.stories.tsx +257 -257
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.tsx +90 -90
- package/src/components/AnnouncementPanel/ListBox/index.ts +3 -3
- package/src/components/AnnouncementPanel/ListContentContainer.css +23 -23
- package/src/components/AnnouncementPanel/ListContentContainer.stories.tsx +212 -212
- package/src/components/AnnouncementPanel/ListContentContainer.tsx +33 -33
- package/src/components/AnnouncementPanel/index.ts +3 -3
- package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +129 -89
- package/src/components/Charts/bar-chart/BarChart.tsx +171 -132
- package/src/components/Charts/boxplot-chart/BoxPlotChart.tsx +114 -114
- package/src/components/Charts/mixed-chart/MixedChart.tsx +65 -9
- package/src/components/Charts/sankey-adaptation/sankey.tsx +70 -70
- package/src/components/Charts/sankey-chart/SankeyChart.tsx +183 -155
- package/src/components/Confirmationpopup/ConfirmationPopup.module.css +88 -0
- package/src/components/Confirmationpopup/ConfirmationPopup.stories.tsx +94 -0
- package/src/components/Confirmationpopup/ConfirmationPopup.tsx +47 -0
- package/src/components/Confirmationpopup/index.ts +6 -0
- package/src/components/Confirmationpopup/useConfirmationPopup.ts +48 -0
- package/src/components/DayStatCard/DayStatCard.tsx +96 -69
- package/src/components/DraggableSwitcher/DraggableSwitcherButton.tsx +58 -58
- package/src/components/DraggableSwitcher/context/useDraggableSwitcher.tsx +45 -45
- package/src/components/DraggableSwitcher/index.ts +2 -2
- package/src/components/DynamicInput/input/SelectInput.tsx +75 -75
- package/src/components/DynamicInput/input/assets/SelectInput.module.css +95 -95
- package/src/components/DynamicTable/TableCell.tsx +38 -30
- package/src/components/DynamicTable/TableHeader.tsx +39 -34
- package/src/components/DynamicTable/TableauDynamique.module.css +1333 -1287
- package/src/components/DynamicTable/TableauDynamique.tsx +154 -154
- package/src/components/DynamicTable/tools/tableTypes.ts +63 -63
- package/src/components/Grid/Grid.tsx +5 -0
- package/src/components/Grid/grid.css +285 -285
- package/src/components/Header/Header.tsx +4 -2
- package/src/components/Header/header.css +61 -31
- package/src/components/MetricsPanel/MetricsPanel.module.css +688 -636
- package/src/components/MetricsPanel/MetricsPanel.tsx +220 -282
- package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +148 -125
- package/src/components/NavBar/NavBar.tsx +1 -1
- package/src/components/NavItem/NavItem.tsx +58 -58
- package/src/components/PeriodRange/PeriodRange.module.css +158 -158
- package/src/components/PeriodRange/PeriodRange.tsx +130 -130
- package/src/components/SearchBar/SearchBar.css +40 -40
- package/src/components/SelectFilter/SelectFilter.module.css +249 -0
- package/src/components/SelectFilter/SelectFilter.stories.tsx +321 -0
- package/src/components/SelectFilter/SelectFilter.tsx +219 -0
- package/src/components/SelectFilter/index.ts +2 -0
- package/src/components/SelectFilter/types.ts +19 -0
- package/src/components/TranslationKey/TranslationKey.css +272 -272
- package/src/components/TranslationKey/TranslationKey.tsx +266 -245
- package/src/components/TrendList/TrendList.tsx +72 -45
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Chart from 'react-apexcharts';
|
|
3
|
-
import type { ApexOptions } from 'apexcharts';
|
|
4
|
-
|
|
5
|
-
export interface BoxPoint {
|
|
6
|
-
x: string | number;
|
|
7
|
-
y: [number, number, number, number, number]; // [min, q1, median, q3, max]
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface BoxPlotData {
|
|
11
|
-
series: BoxPoint[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface BoxPlotConfig {
|
|
15
|
-
colorUpper?: string;
|
|
16
|
-
colorLower?: string;
|
|
17
|
-
color?: string;
|
|
18
|
-
showOutliers?: boolean;
|
|
19
|
-
tooltipFormatter?: (val: number) => string;
|
|
20
|
-
height?: number;
|
|
21
|
-
responsive?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface Props {
|
|
25
|
-
data: BoxPlotData;
|
|
26
|
-
config?: BoxPlotConfig;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const defaultConfig: BoxPlotConfig = {
|
|
30
|
-
colorUpper: '#2db85bff',
|
|
31
|
-
colorLower: '#b3761bff',
|
|
32
|
-
color: '#5f9ec4',
|
|
33
|
-
showOutliers: true,
|
|
34
|
-
tooltipFormatter: (v) => String(v),
|
|
35
|
-
height: 420,
|
|
36
|
-
responsive: true,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/** Série locale pour boxPlot */
|
|
40
|
-
type BoxPlotSeries = ReadonlyArray<{
|
|
41
|
-
name: string;
|
|
42
|
-
data: ReadonlyArray<{ x: string | number; y: [number, number, number, number, number] }>;
|
|
43
|
-
}>;
|
|
44
|
-
|
|
45
|
-
const BoxPlotChart: React.FC<Props> = ({ data, config = defaultConfig }) => {
|
|
46
|
-
const cfg: BoxPlotConfig = { ...defaultConfig, ...config };
|
|
47
|
-
|
|
48
|
-
const seriesPoints = Array.isArray(data?.series) ? data.series : [];
|
|
49
|
-
const apexSeries: BoxPlotSeries = [
|
|
50
|
-
{
|
|
51
|
-
name: 'Distribution',
|
|
52
|
-
data: seriesPoints.map((p) => ({ x: p.x, y: p.y })),
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
const options: ApexOptions = {
|
|
56
|
-
chart: {
|
|
57
|
-
foreColor: 'var(--color-text)',
|
|
58
|
-
type: 'boxPlot',
|
|
59
|
-
toolbar: { show: false },
|
|
60
|
-
height: cfg.height,
|
|
61
|
-
},
|
|
62
|
-
yaxis: {
|
|
63
|
-
tickAmount: 10,
|
|
64
|
-
labels: {
|
|
65
|
-
formatter: function (val: number) {
|
|
66
|
-
return val.toFixed(0);
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
plotOptions: {
|
|
71
|
-
boxPlot: {
|
|
72
|
-
colors: {
|
|
73
|
-
upper: cfg.colorUpper,
|
|
74
|
-
lower: cfg.colorLower,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
stroke: { show: true, width: 1, colors: ['var(--color-secondary)'] },
|
|
79
|
-
markers: { size: 0 },
|
|
80
|
-
tooltip: {
|
|
81
|
-
shared: false,
|
|
82
|
-
y: {
|
|
83
|
-
formatter: (val: number | string | unknown) => {
|
|
84
|
-
if (typeof val === 'number') return cfg.tooltipFormatter!(val);
|
|
85
|
-
return String(val);
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
grid: { borderColor: '#e6e6e6' },
|
|
90
|
-
dataLabels: { enabled: false },
|
|
91
|
-
legend: { show: false },
|
|
92
|
-
responsive: cfg.responsive
|
|
93
|
-
? [
|
|
94
|
-
// {
|
|
95
|
-
// breakpoint: 768,
|
|
96
|
-
// options: {
|
|
97
|
-
// chart: { height: Math.max(220, Math.round((cfg.height ?? 380) * 0.6)) },
|
|
98
|
-
// },
|
|
99
|
-
// },
|
|
100
|
-
]
|
|
101
|
-
: undefined,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<Chart
|
|
106
|
-
options={options}
|
|
107
|
-
series={apexSeries as unknown as ApexOptions['series']}
|
|
108
|
-
type='boxPlot'
|
|
109
|
-
height={cfg.height}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export default BoxPlotChart;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Chart from 'react-apexcharts';
|
|
3
|
+
import type { ApexOptions } from 'apexcharts';
|
|
4
|
+
|
|
5
|
+
export interface BoxPoint {
|
|
6
|
+
x: string | number;
|
|
7
|
+
y: [number, number, number, number, number]; // [min, q1, median, q3, max]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface BoxPlotData {
|
|
11
|
+
series: BoxPoint[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface BoxPlotConfig {
|
|
15
|
+
colorUpper?: string;
|
|
16
|
+
colorLower?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
showOutliers?: boolean;
|
|
19
|
+
tooltipFormatter?: (val: number) => string;
|
|
20
|
+
height?: number;
|
|
21
|
+
responsive?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
data: BoxPlotData;
|
|
26
|
+
config?: BoxPlotConfig;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const defaultConfig: BoxPlotConfig = {
|
|
30
|
+
colorUpper: '#2db85bff',
|
|
31
|
+
colorLower: '#b3761bff',
|
|
32
|
+
color: '#5f9ec4',
|
|
33
|
+
showOutliers: true,
|
|
34
|
+
tooltipFormatter: (v) => String(v),
|
|
35
|
+
height: 420,
|
|
36
|
+
responsive: true,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Série locale pour boxPlot */
|
|
40
|
+
type BoxPlotSeries = ReadonlyArray<{
|
|
41
|
+
name: string;
|
|
42
|
+
data: ReadonlyArray<{ x: string | number; y: [number, number, number, number, number] }>;
|
|
43
|
+
}>;
|
|
44
|
+
|
|
45
|
+
const BoxPlotChart: React.FC<Props> = ({ data, config = defaultConfig }) => {
|
|
46
|
+
const cfg: BoxPlotConfig = { ...defaultConfig, ...config };
|
|
47
|
+
|
|
48
|
+
const seriesPoints = Array.isArray(data?.series) ? data.series : [];
|
|
49
|
+
const apexSeries: BoxPlotSeries = [
|
|
50
|
+
{
|
|
51
|
+
name: 'Distribution',
|
|
52
|
+
data: seriesPoints.map((p) => ({ x: p.x, y: p.y })),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
const options: ApexOptions = {
|
|
56
|
+
chart: {
|
|
57
|
+
foreColor: 'var(--color-text)',
|
|
58
|
+
type: 'boxPlot',
|
|
59
|
+
toolbar: { show: false },
|
|
60
|
+
height: cfg.height,
|
|
61
|
+
},
|
|
62
|
+
yaxis: {
|
|
63
|
+
tickAmount: 10,
|
|
64
|
+
labels: {
|
|
65
|
+
formatter: function (val: number) {
|
|
66
|
+
return val.toFixed(0);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
plotOptions: {
|
|
71
|
+
boxPlot: {
|
|
72
|
+
colors: {
|
|
73
|
+
upper: cfg.colorUpper,
|
|
74
|
+
lower: cfg.colorLower,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
stroke: { show: true, width: 1, colors: ['var(--color-secondary)'] },
|
|
79
|
+
markers: { size: 0 },
|
|
80
|
+
tooltip: {
|
|
81
|
+
shared: false,
|
|
82
|
+
y: {
|
|
83
|
+
formatter: (val: number | string | unknown) => {
|
|
84
|
+
if (typeof val === 'number') return cfg.tooltipFormatter!(val);
|
|
85
|
+
return String(val);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
grid: { borderColor: '#e6e6e6' },
|
|
90
|
+
dataLabels: { enabled: false },
|
|
91
|
+
legend: { show: false },
|
|
92
|
+
responsive: cfg.responsive
|
|
93
|
+
? [
|
|
94
|
+
// {
|
|
95
|
+
// breakpoint: 768,
|
|
96
|
+
// options: {
|
|
97
|
+
// chart: { height: Math.max(220, Math.round((cfg.height ?? 380) * 0.6)) },
|
|
98
|
+
// },
|
|
99
|
+
// },
|
|
100
|
+
]
|
|
101
|
+
: undefined,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Chart
|
|
106
|
+
options={options}
|
|
107
|
+
series={apexSeries as unknown as ApexOptions['series']}
|
|
108
|
+
type='boxPlot'
|
|
109
|
+
height={cfg.height}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default BoxPlotChart;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import Chart from 'react-apexcharts';
|
|
3
3
|
import type { ApexOptions } from 'apexcharts';
|
|
4
|
+
import { Move } from 'lucide-react';
|
|
4
5
|
|
|
5
6
|
/* ---------- Types ---------- */
|
|
6
7
|
export interface BandChartData {
|
|
@@ -59,6 +60,9 @@ interface Props {
|
|
|
59
60
|
config?: BandChartConfig;
|
|
60
61
|
height?: number;
|
|
61
62
|
useOnGoing?: boolean;
|
|
63
|
+
draggable?: boolean;
|
|
64
|
+
tooltipEnabled?: boolean;
|
|
65
|
+
// zoomEnabled removed as separate prop — zoom/pan follow tooltipEnabled
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/* ---------- Local series item types (compat Apex) ---------- */
|
|
@@ -140,7 +144,24 @@ const MixedChart: React.FC<Props> = ({
|
|
|
140
144
|
config = defaultConfig,
|
|
141
145
|
height = 350,
|
|
142
146
|
useOnGoing,
|
|
147
|
+
draggable = false,
|
|
148
|
+
tooltipEnabled = true,
|
|
143
149
|
}) => {
|
|
150
|
+
const [renderKey, setRenderKey] = useState(0);
|
|
151
|
+
const [loading, setLoading] = useState(false);
|
|
152
|
+
|
|
153
|
+
// Lorsque draggable passe de true → false, on force remount
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!draggable) {
|
|
156
|
+
setLoading(true);
|
|
157
|
+
const timeout = setTimeout(() => {
|
|
158
|
+
setRenderKey((k) => k + 1); // nouvelle key → remount Chart
|
|
159
|
+
setLoading(false);
|
|
160
|
+
}, 10); // très court délai pour permettre le placeholder
|
|
161
|
+
return () => clearTimeout(timeout);
|
|
162
|
+
}
|
|
163
|
+
}, [draggable]);
|
|
164
|
+
|
|
144
165
|
// merge defaults and provided config
|
|
145
166
|
const merged = { ...defaultConfig, ...config };
|
|
146
167
|
// minimal override: if caller provided useOnGoing boolean, it forces merged.showOnGoing
|
|
@@ -480,9 +501,26 @@ const MixedChart: React.FC<Props> = ({
|
|
|
480
501
|
chart: {
|
|
481
502
|
foreColor: 'var(--color-text)',
|
|
482
503
|
type: 'line',
|
|
483
|
-
toolbar: {
|
|
504
|
+
toolbar: {
|
|
505
|
+
show: false,
|
|
506
|
+
offsetY: -20,
|
|
507
|
+
autoSelected: 'pan',
|
|
508
|
+
tools: {
|
|
509
|
+
download: false,
|
|
510
|
+
selection: true,
|
|
511
|
+
zoom: true,
|
|
512
|
+
zoomin: true,
|
|
513
|
+
zoomout: true,
|
|
514
|
+
pan: true,
|
|
515
|
+
reset: true,
|
|
516
|
+
},
|
|
517
|
+
},
|
|
484
518
|
width: '100%',
|
|
485
|
-
zoom: {
|
|
519
|
+
zoom: {
|
|
520
|
+
enabled: tooltipEnabled,
|
|
521
|
+
type: 'x',
|
|
522
|
+
autoScaleYaxis: true,
|
|
523
|
+
},
|
|
486
524
|
animations: {
|
|
487
525
|
enabled: true,
|
|
488
526
|
animateGradually: { enabled: true, delay: 80 },
|
|
@@ -525,6 +563,7 @@ const MixedChart: React.FC<Props> = ({
|
|
|
525
563
|
// CUSTOM TOOLTIP: show only defined values, keep Real and OnGoing separate,
|
|
526
564
|
// skip outlier points flagged _outside, skip column placeholder zeros
|
|
527
565
|
tooltip: {
|
|
566
|
+
enabled: tooltipEnabled,
|
|
528
567
|
shared: true,
|
|
529
568
|
intersect: false,
|
|
530
569
|
followCursor: true,
|
|
@@ -613,12 +652,29 @@ const MixedChart: React.FC<Props> = ({
|
|
|
613
652
|
};
|
|
614
653
|
|
|
615
654
|
return (
|
|
616
|
-
<
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
655
|
+
<div style={{ position: 'relative', width: '100%', height }}>
|
|
656
|
+
{draggable && !loading ? (
|
|
657
|
+
<div
|
|
658
|
+
style={{
|
|
659
|
+
width: '100%',
|
|
660
|
+
height: '100%',
|
|
661
|
+
display: 'flex',
|
|
662
|
+
alignItems: 'center',
|
|
663
|
+
justifyContent: 'center',
|
|
664
|
+
}}
|
|
665
|
+
>
|
|
666
|
+
<Move size={48} strokeWidth={1.5} style={{ opacity: 0.8 }} />
|
|
667
|
+
</div>
|
|
668
|
+
) : (
|
|
669
|
+
<Chart
|
|
670
|
+
key={renderKey} // force remount si besoin
|
|
671
|
+
options={options}
|
|
672
|
+
series={series as unknown as ApexOptions['series']}
|
|
673
|
+
type='line'
|
|
674
|
+
height={height}
|
|
675
|
+
/>
|
|
676
|
+
)}
|
|
677
|
+
</div>
|
|
622
678
|
);
|
|
623
679
|
};
|
|
624
680
|
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
// MySankeyChart.tsx
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { ResponsiveSankey } from '@nivo/sankey';
|
|
5
|
-
import type { SankeyDataProps } from '@nivo/sankey';
|
|
6
|
-
// Définissez vos données avec le type approprié pour une meilleure intégrité
|
|
7
|
-
const data: SankeyDataProps = {
|
|
8
|
-
nodes: [
|
|
9
|
-
{ id: 'start', color: '#61cdbb' },
|
|
10
|
-
{ id: 'process_a', color: '#97e6a6' },
|
|
11
|
-
{ id: 'process_b', color: '#e8c1a0' },
|
|
12
|
-
{ id: 'end_result', color: '#f1e15b' },
|
|
13
|
-
],
|
|
14
|
-
links: [
|
|
15
|
-
{ source: 'start', target: 'process_a', value: 100 },
|
|
16
|
-
{ source: 'start', target: 'process_b', value: 50 },
|
|
17
|
-
{ source: 'process_a', target: 'end_result', value: 75 },
|
|
18
|
-
{ source: 'process_a', target: 'process_b', value: 25 },
|
|
19
|
-
{ source: 'process_b', target: 'end_result', value: 75 },
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const MySankeyChart: React.FC = () => {
|
|
24
|
-
return (
|
|
25
|
-
<div style={{ height: '500px', width: '100%' }}>
|
|
26
|
-
<ResponsiveSankey
|
|
27
|
-
data={data}
|
|
28
|
-
margin={{ top: 10, right: 10, bottom: 10, left: 10 }}
|
|
29
|
-
align='justify'
|
|
30
|
-
colors={{ scheme: 'category10' }}
|
|
31
|
-
nodeOpacity={1}
|
|
32
|
-
nodeThickness={18}
|
|
33
|
-
nodeInnerPadding={8}
|
|
34
|
-
nodeSpacing={24}
|
|
35
|
-
linkOpacity={0.5}
|
|
36
|
-
nodeBorderWidth={0}
|
|
37
|
-
nodeBorderColor={{
|
|
38
|
-
from: 'color',
|
|
39
|
-
modifiers: [['darker', 0.8]],
|
|
40
|
-
}}
|
|
41
|
-
// Active l'affichage des étiquettes
|
|
42
|
-
enableLabels={true}
|
|
43
|
-
// Positionne les étiquettes à l'extérieur des nœuds
|
|
44
|
-
labelPosition='outside'
|
|
45
|
-
// Oriente les étiquettes horizontalement
|
|
46
|
-
labelOrientation='horizontal'
|
|
47
|
-
// Ajoute un espacement entre les nœuds et les étiquettes
|
|
48
|
-
labelPadding={16}
|
|
49
|
-
// Personnalise la couleur du texte des étiquettes
|
|
50
|
-
labelTextColor={{
|
|
51
|
-
from: 'color',
|
|
52
|
-
modifiers: [['darker', 1.5]],
|
|
53
|
-
}}
|
|
54
|
-
animate={true}
|
|
55
|
-
motionConfig='stiff'
|
|
56
|
-
// Personnalise les styles via le thème
|
|
57
|
-
theme={{
|
|
58
|
-
labels: {
|
|
59
|
-
text: {
|
|
60
|
-
fontSize: 14,
|
|
61
|
-
fontWeight: 'bold',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
}}
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default MySankeyChart;
|
|
1
|
+
// MySankeyChart.tsx
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ResponsiveSankey } from '@nivo/sankey';
|
|
5
|
+
import type { SankeyDataProps } from '@nivo/sankey';
|
|
6
|
+
// Définissez vos données avec le type approprié pour une meilleure intégrité
|
|
7
|
+
const data: SankeyDataProps = {
|
|
8
|
+
nodes: [
|
|
9
|
+
{ id: 'start', color: '#61cdbb' },
|
|
10
|
+
{ id: 'process_a', color: '#97e6a6' },
|
|
11
|
+
{ id: 'process_b', color: '#e8c1a0' },
|
|
12
|
+
{ id: 'end_result', color: '#f1e15b' },
|
|
13
|
+
],
|
|
14
|
+
links: [
|
|
15
|
+
{ source: 'start', target: 'process_a', value: 100 },
|
|
16
|
+
{ source: 'start', target: 'process_b', value: 50 },
|
|
17
|
+
{ source: 'process_a', target: 'end_result', value: 75 },
|
|
18
|
+
{ source: 'process_a', target: 'process_b', value: 25 },
|
|
19
|
+
{ source: 'process_b', target: 'end_result', value: 75 },
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const MySankeyChart: React.FC = () => {
|
|
24
|
+
return (
|
|
25
|
+
<div style={{ height: '500px', width: '100%' }}>
|
|
26
|
+
<ResponsiveSankey
|
|
27
|
+
data={data}
|
|
28
|
+
margin={{ top: 10, right: 10, bottom: 10, left: 10 }}
|
|
29
|
+
align='justify'
|
|
30
|
+
colors={{ scheme: 'category10' }}
|
|
31
|
+
nodeOpacity={1}
|
|
32
|
+
nodeThickness={18}
|
|
33
|
+
nodeInnerPadding={8}
|
|
34
|
+
nodeSpacing={24}
|
|
35
|
+
linkOpacity={0.5}
|
|
36
|
+
nodeBorderWidth={0}
|
|
37
|
+
nodeBorderColor={{
|
|
38
|
+
from: 'color',
|
|
39
|
+
modifiers: [['darker', 0.8]],
|
|
40
|
+
}}
|
|
41
|
+
// Active l'affichage des étiquettes
|
|
42
|
+
enableLabels={true}
|
|
43
|
+
// Positionne les étiquettes à l'extérieur des nœuds
|
|
44
|
+
labelPosition='outside'
|
|
45
|
+
// Oriente les étiquettes horizontalement
|
|
46
|
+
labelOrientation='horizontal'
|
|
47
|
+
// Ajoute un espacement entre les nœuds et les étiquettes
|
|
48
|
+
labelPadding={16}
|
|
49
|
+
// Personnalise la couleur du texte des étiquettes
|
|
50
|
+
labelTextColor={{
|
|
51
|
+
from: 'color',
|
|
52
|
+
modifiers: [['darker', 1.5]],
|
|
53
|
+
}}
|
|
54
|
+
animate={true}
|
|
55
|
+
motionConfig='stiff'
|
|
56
|
+
// Personnalise les styles via le thème
|
|
57
|
+
theme={{
|
|
58
|
+
labels: {
|
|
59
|
+
text: {
|
|
60
|
+
fontSize: 14,
|
|
61
|
+
fontWeight: 'bold',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default MySankeyChart;
|