Skip to content

Commit cde96d1

Browse files
committed
add circular flow
1 parent 7dac8de commit cde96d1

File tree

4 files changed

+502
-5
lines changed

4 files changed

+502
-5
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,24 @@
6161
"@types/node": "^12.20.55",
6262
"@visx/geo": "^3.5.0",
6363
"@visx/gradient": "^3.3.0",
64-
"@visx/group": "^3.3.0",
64+
"@visx/group": "^3.12.0",
6565
"@visx/hierarchy": "^3.3.0",
6666
"@visx/responsive": "^3.3.0",
67-
"@visx/shape": "^3.5.0",
67+
"@visx/shape": "^3.12.0",
68+
"@visx/text": "^3.12.0",
6869
"d3": "^7.9.0",
6970
"d3-geo": "^3.1.1",
7071
"gsap": "^3.12.7",
72+
"lodash.clamp": "^4.0.3",
7173
"mapbox-gl": "^3.10.0",
7274
"postcss": "^8.4.38",
7375
"postcss-safe-parser": "^7.0.1",
7476
"react-jss": "^10.5.0",
7577
"react-map-gl": "^8.0.1",
7678
"react-scripts": "^5.0.1",
7779
"react-spring": "^9.7.4",
80+
"react-use-gesture": "^9.1.3",
81+
"react-use-measure": "^2.1.7",
7882
"resize-observer-polyfill": "^1.5.1",
7983
"topojson-client": "^3.1.0",
8084
"typescript": "^4"
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import React from 'react';
2+
import { CycleFlow } from './CycleFlow';
3+
4+
export default {
5+
title: 'Visualization/CycleFlow',
6+
component: CycleFlow
7+
};
8+
9+
export const DatingCycle = () => (
10+
<div style={{ width: '600px', height: '600px' }}>
11+
<CycleFlow
12+
width={600}
13+
height={600}
14+
edges={[
15+
{
16+
source: 'More engaged user',
17+
target: 'Successful date',
18+
label: 'leads to',
19+
color: '#4CAF50'
20+
},
21+
{
22+
source: 'Successful date',
23+
target: 'Match with someone',
24+
label: 'encourages',
25+
color: '#4CAF50'
26+
},
27+
{
28+
source: 'Match with someone',
29+
target: 'More engaged user',
30+
label: '❌ becomes',
31+
// color: 'red',
32+
animated: false
33+
}
34+
]}
35+
nodes={[
36+
{ id: 'More engaged user', color: '#4CAF50' },
37+
{ id: 'Successful date', color: '#2196F3' },
38+
{ id: 'Match with someone', color: '#FF5722' }
39+
]}
40+
/>
41+
</div>
42+
);
43+
44+
export const EconomicCycle = () => (
45+
<div style={{ width: '700px', height: '700px', background: '#f9f9f9' }}>
46+
<CycleFlow
47+
width={700}
48+
height={700}
49+
edges={[
50+
{
51+
source: 'Households',
52+
target: 'Firms',
53+
label: 'Consumption spending\n(300 billion pesos)',
54+
color: '#90A4AE'
55+
},
56+
{
57+
source: 'Firms',
58+
target: 'Households',
59+
label: 'Wage income\n(300 billion pesos)',
60+
color: '#90A4AE'
61+
}
62+
]}
63+
nodes={[
64+
{ id: 'Households', color: '#2E7D32' }, // Dark green
65+
{ id: 'Firms', color: '#C62828' } // Dark red
66+
]}
67+
/>
68+
</div>
69+
);
70+
71+
export const SimpleExample = () => (
72+
<div style={{ width: '400px', height: '400px' }}>
73+
<CycleFlow
74+
edges={[
75+
{ source: 'A', target: 'B', label: 'Step 1' },
76+
{ source: 'B', target: 'C', label: 'Step 2' },
77+
{ source: 'C', target: 'A', label: 'Step 3' }
78+
]}
79+
// No node colors specified - will use defaults
80+
/>
81+
</div>
82+
);
83+
84+
export const CustomAnimations = () => (
85+
<div style={{ width: '600px', height: '600px', background: '#f5f5f5' }}>
86+
<CycleFlow
87+
width={600}
88+
height={600}
89+
edges={[
90+
{
91+
source: 'Process A',
92+
target: 'Process B',
93+
label: 'Normal flow',
94+
animated: true
95+
},
96+
{
97+
source: 'Process B',
98+
target: 'Process C',
99+
label: 'Static connection',
100+
animated: false,
101+
color: '#E91E63'
102+
},
103+
{
104+
source: 'Process C',
105+
target: 'Process D',
106+
label: 'Colored flow',
107+
color: '#9C27B0'
108+
},
109+
{
110+
source: 'Process D',
111+
target: 'Process A',
112+
label: 'Default flow'
113+
}
114+
]}
115+
nodes={[
116+
{ id: 'Process A', color: '#3F51B5' },
117+
{ id: 'Process B', color: '#009688' },
118+
{ id: 'Process C', color: '#FFC107' },
119+
{ id: 'Process D', color: '#607D8B' }
120+
]}
121+
/>
122+
</div>
123+
);

0 commit comments

Comments
 (0)