apexsankey 1.7.0 → 1.8.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.
@@ -3,98 +3,110 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Document</title>
7
- <link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap" rel="stylesheet" />
6
+ <title>Per-Node Colors - Website Traffic</title>
7
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
8
10
  <script src="../apexsankey.min.js"></script>
11
+ <style>
12
+ body {
13
+ max-width: 1000px;
14
+ margin: 0 auto;
15
+ font-family: 'Inter', sans-serif;
16
+ background: #fff;
17
+ padding: 20px 0;
18
+ }
19
+ h2 {
20
+ font-size: 22px;
21
+ font-weight: 700;
22
+ color: #1a1a2e;
23
+ margin: 0 0 4px 0;
24
+ line-height: 1.3;
25
+ }
26
+ .subtitle {
27
+ font-size: 13px;
28
+ color: #6e6e6e;
29
+ margin-bottom: 16px;
30
+ }
31
+ </style>
9
32
  </head>
10
33
  <body>
11
- <div id="svg-sankey" style="margin: 0 auto"></div>
34
+ <h2>Website Traffic Flow</h2>
35
+ <p class="subtitle">
36
+ Per-node color overrides to visually group traffic sources, pages, and outcomes using the
37
+ <code>color</code> property on each node
38
+ </p>
39
+ <div id="svg-sankey"></div>
12
40
  <script>
13
41
  const data = {
14
42
  nodes: [
15
- {
16
- id: 'John',
17
- title: 'John',
18
- },
19
- {
20
- id: 'Raoul',
21
- title: 'Raoul',
22
- },
23
- {
24
- id: 'Jane',
25
- title: 'Jane',
26
- },
27
- {
28
- id: 'Marcel',
29
- title: 'Marcel',
30
- },
31
- {
32
- id: 'Ibrahim',
33
- title: 'Ibrahim',
34
- },
35
- {
36
- id: 'Junko',
37
- title: 'Junko',
38
- },
43
+ // Sources — blue tones
44
+ {id: 'Google Search', title: 'Google Search', color: '#4285F4'},
45
+ {id: 'Social Media', title: 'Social Media', color: '#E1306C'},
46
+ {id: 'Direct', title: 'Direct', color: '#6366F1'},
47
+ {id: 'Email', title: 'Email Campaigns', color: '#0EA5E9'},
48
+ {id: 'Referral', title: 'Referral Sites', color: '#8B5CF6'},
49
+ // Pages — warm tones
50
+ {id: 'Homepage', title: 'Homepage', color: '#F97316'},
51
+ {id: 'Blog', title: 'Blog', color: '#F59E0B'},
52
+ {id: 'Product', title: 'Product Pages', color: '#EF4444'},
53
+ {id: 'Pricing', title: 'Pricing', color: '#EC4899'},
54
+ {id: 'Docs', title: 'Documentation', color: '#D946EF'},
55
+ // Outcomes — green/neutral tones
56
+ {id: 'Sign Up', title: 'Sign Up', color: '#10B981'},
57
+ {id: 'Purchase', title: 'Purchase', color: '#059669'},
58
+ {id: 'Bounce', title: 'Bounce', color: '#94A3B8'},
59
+ {id: 'Support', title: 'Contact Support', color: '#14B8A6'},
39
60
  ],
40
61
  edges: [
41
- {
42
- source: 'Marcel',
43
- target: 'Ibrahim',
44
- value: 72,
45
- },
46
- {
47
- source: 'Marcel',
48
- target: 'Raoul',
49
- value: 155,
50
- },
51
- {
52
- source: 'Raoul',
53
- target: 'John',
54
- value: 109,
55
- },
56
- {
57
- source: 'Raoul',
58
- target: 'Ibrahim',
59
- value: 100,
60
- },
61
- {
62
- source: 'Ibrahim',
63
- target: 'Jane',
64
- value: 100,
65
- },
66
- {
67
- source: 'Ibrahim',
68
- target: 'Junko',
69
- value: 127,
70
- },
71
- {
72
- source: 'Ibrahim',
73
- target: 'John',
74
- value: 67,
75
- },
76
- {
77
- source: 'Junko',
78
- target: 'Jane',
79
- value: 140,
80
- },
81
- {
82
- source: 'Junko',
83
- target: 'John',
84
- value: 93,
85
- },
62
+ {source: 'Google Search', target: 'Homepage', value: 4200},
63
+ {source: 'Google Search', target: 'Blog', value: 3800},
64
+ {source: 'Google Search', target: 'Product', value: 2100},
65
+ {source: 'Google Search', target: 'Docs', value: 1400},
66
+ {source: 'Social Media', target: 'Homepage', value: 2800},
67
+ {source: 'Social Media', target: 'Blog', value: 1900},
68
+ {source: 'Social Media', target: 'Product', value: 800},
69
+ {source: 'Direct', target: 'Homepage', value: 3100},
70
+ {source: 'Direct', target: 'Pricing', value: 1600},
71
+ {source: 'Direct', target: 'Product', value: 1200},
72
+ {source: 'Email', target: 'Product', value: 1800},
73
+ {source: 'Email', target: 'Pricing', value: 900},
74
+ {source: 'Email', target: 'Blog', value: 600},
75
+ {source: 'Referral', target: 'Blog', value: 1100},
76
+ {source: 'Referral', target: 'Homepage', value: 700},
77
+ {source: 'Referral', target: 'Docs', value: 500},
78
+ {source: 'Homepage', target: 'Sign Up', value: 3200},
79
+ {source: 'Homepage', target: 'Bounce', value: 5400},
80
+ {source: 'Homepage', target: 'Support', value: 2200},
81
+ {source: 'Blog', target: 'Sign Up', value: 2100},
82
+ {source: 'Blog', target: 'Bounce', value: 4500},
83
+ {source: 'Blog', target: 'Support', value: 800},
84
+ {source: 'Product', target: 'Purchase', value: 2400},
85
+ {source: 'Product', target: 'Sign Up', value: 1800},
86
+ {source: 'Product', target: 'Bounce', value: 1700},
87
+ {source: 'Pricing', target: 'Purchase', value: 1500},
88
+ {source: 'Pricing', target: 'Bounce', value: 1000},
89
+ {source: 'Docs', target: 'Support', value: 900},
90
+ {source: 'Docs', target: 'Sign Up', value: 600},
91
+ {source: 'Docs', target: 'Bounce', value: 400},
86
92
  ],
87
93
  };
88
- const graphOptions = {
89
- width: 800,
90
- fontFamily: 'Quicksand, sans-serif',
91
- fontWeight: '600',
92
- nodeWidth: 5,
93
- nodeBorderWidth: 2,
94
- nodeBorderColor: '#111',
95
- edgeGradientFill: false,
94
+
95
+ const options = {
96
+ nodeWidth: 16,
97
+ fontFamily: 'Inter, sans-serif',
98
+ fontWeight: '500',
99
+ fontSize: '12px',
100
+ fontColor: '#334155',
101
+ width: '100%',
102
+ height: 560,
103
+ edgeGradientFill: true,
104
+ edgeOpacity: 0.3,
105
+ enableToolbar: true,
106
+ canvasStyle: 'border: 1px solid #e2e8f0; border-radius: 8px; background: #fafafa; box-sizing: border-box;',
96
107
  };
97
- const s = new ApexSankey(document.getElementById('svg-sankey'), graphOptions);
108
+
109
+ const s = new ApexSankey(document.getElementById('svg-sankey'), options);
98
110
  s.render(data);
99
111
  </script>
100
112
  </body>
@@ -3,169 +3,101 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Document</title>
7
- <link href="https://fonts.googleapis.com/css2?family=Satisfy&display=swap" rel="stylesheet" />
6
+ <title>Custom Fonts - Job Application Journey</title>
7
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
+ <link
10
+ href="https://fonts.googleapis.com/css2?family=Satisfy&family=Inter:wght@400;500;600&display=swap"
11
+ rel="stylesheet"
12
+ />
8
13
  <script src="../apexsankey.min.js"></script>
14
+ <style>
15
+ body {
16
+ max-width: 1000px;
17
+ margin: 0 auto;
18
+ font-family: 'Inter', sans-serif;
19
+ background: #fff;
20
+ padding: 20px 0;
21
+ }
22
+ h2 {
23
+ font-size: 22px;
24
+ font-weight: 700;
25
+ color: #1a1a2e;
26
+ margin: 0 0 4px 0;
27
+ line-height: 1.3;
28
+ }
29
+ .subtitle {
30
+ font-size: 13px;
31
+ color: #6e6e6e;
32
+ margin-bottom: 16px;
33
+ }
34
+ </style>
9
35
  </head>
10
-
11
36
  <body>
12
- <div id="svg-sankey" style="margin: 0 auto"></div>
37
+ <h2>Job Application Journey</h2>
38
+ <p class="subtitle">
39
+ Custom Google Font with warm accent color (<code>fontFamily: 'Satisfy'</code>, <code>fontColor: '#B45309'</code>,
40
+ <code>fontSize: '18px'</code>) and column ordering via
41
+ <code>data.options.order</code>
42
+ </p>
43
+ <div id="svg-sankey"></div>
13
44
  <script>
14
45
  const data = {
15
46
  nodes: [
16
- {id: 'Berlin', title: 'Berlin'},
17
- {id: 'Job Applications', title: 'Job Applications'},
18
- {id: 'Barcelona', title: 'Barcelona'},
19
- {id: 'Madrid', title: 'Madrid'},
20
- {id: 'Amsterdam', title: 'Amsterdam'},
21
- {id: 'Paris', title: 'Paris'},
22
- {id: 'London', title: 'London'},
23
- {id: 'Munich', title: 'Munich'},
24
- {id: 'Brussels', title: 'Brussels'},
25
- {id: 'Dubai', title: 'Dubai'},
26
- {id: 'Dublin', title: 'Dublin'},
27
- {id: 'Other Cities', title: 'Other Cities'},
28
- {id: 'No Response', title: 'No Response'},
29
- {id: 'Responded', title: 'Responded'},
30
- {id: 'Rejected', title: 'Rejected'},
31
- {id: 'Interviewed', title: 'Interviewed'},
32
- {id: 'No Offer', title: 'No Offer'},
33
- {id: 'Declined Offer', title: 'Declined Offer'},
34
- {id: 'Accepted Offer', title: 'Accepted Offer'},
47
+ {id: 'LinkedIn', title: 'LinkedIn', color: '#0A66C2'},
48
+ {id: 'Indeed', title: 'Indeed', color: '#2164F3'},
49
+ {id: 'Referral', title: 'Referral', color: '#7C3AED'},
50
+ {id: 'Company Site', title: 'Company Site', color: '#0891B2'},
51
+ {id: 'Recruiter', title: 'Recruiter', color: '#059669'},
52
+ {id: 'Applied', title: 'Applied', color: '#D97706'},
53
+ {id: 'No Response', title: 'No Response', color: '#D4D4D8'},
54
+ {id: 'Responded', title: 'Responded', color: '#F59E0B'},
55
+ {id: 'Rejected', title: 'Rejected', color: '#A3A3A3'},
56
+ {id: 'Interviewed', title: 'Interviewed', color: '#F97316'},
57
+ {id: 'No Offer', title: 'No Offer', color: '#CBD5E1'},
58
+ {id: 'Declined', title: 'Declined', color: '#94A3B8'},
59
+ {id: 'Accepted', title: 'Accepted!', color: '#16A34A'},
35
60
  ],
36
61
  edges: [
37
- {
38
- source: 'Berlin',
39
- target: 'Job Applications',
40
- value: 102,
41
- color: '#dddddd',
42
- },
43
- {
44
- source: 'Barcelona',
45
- target: 'Job Applications',
46
- value: 39,
47
- color: '#dddddd',
48
- },
49
- {
50
- source: 'Madrid',
51
- target: 'Job Applications',
52
- value: 35,
53
- color: '#dddddd',
54
- },
55
- {
56
- source: 'Amsterdam',
57
- target: 'Job Applications',
58
- value: 15,
59
- color: '#dddddd',
60
- },
61
- {
62
- source: 'Paris',
63
- target: 'Job Applications',
64
- value: 14,
65
- color: '#dddddd',
66
- },
67
- {
68
- source: 'London',
69
- target: 'Job Applications',
70
- value: 6,
71
- color: '#dddddd',
72
- },
73
- {
74
- source: 'Munich',
75
- target: 'Job Applications',
76
- value: 5,
77
- color: '#dddddd',
78
- },
79
- {
80
- source: 'Brussels',
81
- target: 'Job Applications',
82
- value: 4,
83
- color: '#dddddd',
84
- },
85
- {
86
- source: 'Dubai',
87
- target: 'Job Applications',
88
- value: 3,
89
- color: '#dddddd',
90
- },
91
- {
92
- source: 'Dublin',
93
- target: 'Job Applications',
94
- value: 3,
95
- color: '#dddddd',
96
- },
97
- {
98
- source: 'Other Cities',
99
- target: 'Job Applications',
100
- value: 12,
101
- color: '#dddddd',
102
- },
103
- {
104
- source: 'Job Applications',
105
- target: 'No Response',
106
- value: 189,
107
- color: '#dddddd',
108
- },
109
- {
110
- source: 'Job Applications',
111
- target: 'Responded',
112
- value: 49,
113
- color: 'orange',
114
- },
115
- {
116
- source: 'Responded',
117
- target: 'Rejected',
118
- value: 38,
119
- color: '#dddddd',
120
- },
121
- {
122
- source: 'Responded',
123
- target: 'Interviewed',
124
- value: 11,
125
- color: 'orange',
126
- },
127
- {
128
- source: 'Interviewed',
129
- target: 'No Offer',
130
- value: 8,
131
- color: '#dddddd',
132
- },
133
- {
134
- source: 'Interviewed',
135
- target: 'Declined Offer',
136
- value: 2,
137
- color: '#dddddd',
138
- },
139
- {
140
- source: 'Interviewed',
141
- target: 'Accepted Offer',
142
- value: 1,
143
- color: 'orange',
144
- },
62
+ {source: 'LinkedIn', target: 'Applied', value: 85},
63
+ {source: 'Indeed', target: 'Applied', value: 62},
64
+ {source: 'Referral', target: 'Applied', value: 28},
65
+ {source: 'Company Site', target: 'Applied', value: 40},
66
+ {source: 'Recruiter', target: 'Applied', value: 23},
67
+ {source: 'Applied', target: 'No Response', value: 168},
68
+ {source: 'Applied', target: 'Responded', value: 70},
69
+ {source: 'Responded', target: 'Rejected', value: 48},
70
+ {source: 'Responded', target: 'Interviewed', value: 22},
71
+ {source: 'Interviewed', target: 'No Offer', value: 14},
72
+ {source: 'Interviewed', target: 'Declined', value: 4},
73
+ {source: 'Interviewed', target: 'Accepted', value: 4},
145
74
  ],
146
75
  options: {
147
76
  order: [
148
- [
149
- ['Berlin', 'Barcelona', 'Madrid', 'Amsterdam', 'Paris', 'London'],
150
- ['Munich', 'Brussels', 'Dubai', 'Dublin', 'Other Cities'],
151
- ],
152
- [['Job Applications']],
77
+ [['LinkedIn', 'Indeed', 'Referral', 'Company Site', 'Recruiter']],
78
+ [['Applied']],
153
79
  [['Responded'], ['No Response']],
154
80
  [['Interviewed'], ['Rejected']],
155
- [['Accepted Offer', 'Declined Offer', 'No Offer'], []],
81
+ [['Accepted', 'Declined', 'No Offer']],
156
82
  ],
157
83
  },
158
84
  };
159
- const graphOptions = {
160
- nodeWidth: 10,
161
- fontSize: '20px',
162
- fontFamily: 'Satisfy, "cursive"',
163
- fontWeight: '600',
164
- fontColor: '#E37816',
165
- width: 800,
166
- height: 700,
85
+
86
+ const options = {
87
+ nodeWidth: 12,
88
+ fontSize: '18px',
89
+ fontFamily: 'Satisfy, cursive',
90
+ fontWeight: '400',
91
+ fontColor: '#B45309',
92
+ width: '100%',
93
+ height: 600,
94
+ edgeGradientFill: true,
95
+ edgeOpacity: 0.3,
96
+ enableToolbar: false,
97
+ canvasStyle: 'border: 1px solid #e7e5e4; border-radius: 8px; background: #fffbf5; box-sizing: border-box;',
167
98
  };
168
- const s = new ApexSankey(document.getElementById('svg-sankey'), graphOptions);
99
+
100
+ const s = new ApexSankey(document.getElementById('svg-sankey'), options);
169
101
  s.render(data);
170
102
  </script>
171
103
  </body>