|
24 | 24 |
|
25 | 25 | <div id="chart6" class="chart"></div> |
26 | 26 |
|
27 | | -<script> |
28 | | -var sheetUrl = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vSgRb1CWKFvn_Yx-AJucuj9uEk9Xblfepoyr2qRcjG8m-mL7mCeNm78Pv0QuMTlVuf6rGFBaPF0bfdD/pub?gid=0&single=true&output=csv'; |
29 | | - |
30 | | -function getCurrentTheme() { |
31 | | - const html = document.documentElement; |
32 | | - const body = document.body; |
33 | | - |
34 | | - if (html.classList.contains('dark') || |
35 | | - body.classList.contains('dark') || |
36 | | - html.getAttribute('data-theme') === 'dark' || |
37 | | - body.getAttribute('data-theme') === 'dark') { |
38 | | - return 'dark'; |
39 | | - } |
40 | | - return 'light'; |
41 | | -} |
42 | | - |
43 | | -function getThemedLayoutBase() { |
44 | | - const isDark = getCurrentTheme() === 'dark'; |
45 | | - |
46 | | - return { |
47 | | - font: { |
48 | | - family: 'Times New Roman, serif', |
49 | | - size: 14, |
50 | | - color: isDark ? '#e0e0e0' : '#000' |
51 | | - }, |
52 | | - paper_bgcolor: isDark ? 'rgba(0,0,0,0)' : '#fff', |
53 | | - plot_bgcolor: isDark ? '#2d2d2d' : '#fff', |
54 | | - margin: {t: 60, b: 80, l: 70, r: 100}, |
55 | | - xaxis: { |
56 | | - showline: true, |
57 | | - linewidth: 1.5, |
58 | | - linecolor: isDark ? '#666' : '#000', |
59 | | - mirror: true, |
60 | | - ticks: 'outside', |
61 | | - tickwidth: 1, |
62 | | - tickcolor: isDark ? '#666' : '#000', |
63 | | - tickfont: {size: 11, color: isDark ? '#e0e0e0' : '#000'}, |
64 | | - showgrid: false, |
65 | | - tickangle: -30 |
66 | | - }, |
67 | | - yaxis: { |
68 | | - showline: true, |
69 | | - linewidth: 1.5, |
70 | | - linecolor: isDark ? '#666' : '#000', |
71 | | - mirror: true, |
72 | | - ticks: 'outside', |
73 | | - tickwidth: 1, |
74 | | - tickcolor: isDark ? '#666' : '#000', |
75 | | - tickfont: {size: 11, color: isDark ? '#e0e0e0' : '#000'}, |
76 | | - showgrid: true, |
77 | | - gridcolor: isDark ? '#444' : '#e0e0e0', |
78 | | - gridwidth: 0.5, |
79 | | - zeroline: false |
80 | | - }, |
81 | | - legend: { |
82 | | - orientation: 'v', |
83 | | - yanchor: 'middle', |
84 | | - y: 0.5, |
85 | | - xanchor: 'left', |
86 | | - x: 1.02, |
87 | | - font: {size: 10, color: isDark ? '#e0e0e0' : '#000'}, |
88 | | - bordercolor: isDark ? '#666' : '#ccc', |
89 | | - borderwidth: 1, |
90 | | - bgcolor: isDark ? 'rgba(0,0,0,0.5)' : 'rgba(255,255,255,0.9)' |
91 | | - }, |
92 | | - bargap: 0.2, |
93 | | - bargroupgap: 0.1 |
94 | | - }; |
95 | | -} |
96 | | - |
97 | | -function getThemedBarStyle() { |
98 | | - const isDark = getCurrentTheme() === 'dark'; |
99 | | - return { |
100 | | - line: {color: isDark ? '#666' : '#000', width: 0.5} |
101 | | - }; |
102 | | -} |
| 27 | +<script src="{{ '/assets/js/chart_lib.js' | relative_url }}"></script> |
103 | 28 |
|
104 | | - |
105 | | - |
106 | | -function formatTime(secs) { |
107 | | - if (!secs) return 'N/A'; |
108 | | - if (secs >= 3600) { |
109 | | - return `${Math.floor(secs/3600)}h ${Math.floor((secs%3600)/60)}m ${Math.round(secs%60)}s`; |
110 | | - } |
111 | | - if (secs >= 60) { |
112 | | - return `${Math.floor(secs/60)}m ${Math.round(secs%60)}s`; |
113 | | - } |
114 | | - return `${secs}s`; |
115 | | -} |
116 | | - |
117 | | -function parseHMS(val) { |
118 | | - const parts = String(val).split(':').map(Number); |
119 | | - if (parts.length === 3) { |
120 | | - return parts[0] * 3600 + parts[1] * 60 + parts[2]; |
121 | | - } |
122 | | - if (parts.length === 2) { |
123 | | - return parts[0] * 60 + parts[1]; |
124 | | - } |
125 | | - return parseFloat(val) || 0; |
126 | | -} |
| 29 | +<script> |
127 | 30 |
|
128 | 31 | var globalData = null; |
129 | 32 |
|
|
140 | 43 | var uniqueDownsampling = globalData.uniqueDownsampling; |
141 | 44 | var markerShapes = globalData.markerShapes; |
142 | 45 |
|
143 | | - var layout_base = getThemedLayoutBase(); |
144 | | - var barStyle = getThemedBarStyle(); |
| 46 | + var layout_base = charty.getThemedLayoutBase(); |
| 47 | + var barStyle = charty.getThemedBarStyle(); |
145 | 48 | var plotConfig = {displayModeBar: false}; |
146 | 49 |
|
147 | 50 | var traces1 = []; |
|
222 | 125 | marker: Object.assign({color: uniqueMethods.map(m => colorMap[m])}, barStyle), |
223 | 126 | text: uniqueMethods.map(m => gpu[methods.findIndex(x => x === m)]), |
224 | 127 | textposition: 'outside', |
225 | | - textfont: {size: 9, color: getCurrentTheme() === 'dark' ? '#ccc' : '#333'} |
| 128 | + textfont: {size: 9, color: charty.getCurrentTheme() === 'dark' ? '#ccc' : '#333'} |
226 | 129 | }], Object.assign({}, layout_base, { |
227 | 130 | title: {text: '(c) Training Time with Downsampling Factor 8', font: {size: 14}, x: 0.5}, |
228 | 131 | showlegend: false, |
|
266 | 169 | color: colorMap[method], |
267 | 170 | symbol: 'circle', |
268 | 171 | size: 10, |
269 | | - line: {color: getCurrentTheme() === 'dark' ? '#666' : '#000', width: 1} |
| 172 | + line: {color: charty.getCurrentTheme() === 'dark' ? '#666' : '#000', width: 1} |
270 | 173 | } |
271 | 174 | }); |
272 | 175 | }); |
|
283 | 186 | color: '#666', |
284 | 187 | symbol: markerShapes[ds] || 'circle', |
285 | 188 | size: 10, |
286 | | - line: {color: getCurrentTheme() === 'dark' ? '#666' : '#000', width: 1} |
| 189 | + line: {color: charty.getCurrentTheme() === 'dark' ? '#666' : '#000', width: 1} |
287 | 190 | } |
288 | 191 | }); |
289 | 192 | }); |
|
304 | 207 | color: colorMap[method], |
305 | 208 | symbol: markerShapes[ds] || 'circle', |
306 | 209 | size: 10, |
307 | | - line: {color: getCurrentTheme() === 'dark' ? '#666' : '#000', width: 1} |
| 210 | + line: {color: charty.getCurrentTheme() === 'dark' ? '#666' : '#000', width: 1} |
308 | 211 | } |
309 | 212 | }); |
310 | 213 | }); |
|
321 | 224 | } |
322 | 225 |
|
323 | 226 |
|
324 | | -Papa.parse(sheetUrl, { |
| 227 | +Papa.parse(charty.sheetsUrls.Ours, { |
325 | 228 | download: true, |
326 | 229 | header: true, |
327 | 230 |
|
328 | 231 | complete: function(results) { |
329 | 232 | var data = results.data.filter(d => d.method); |
330 | 233 |
|
331 | 234 | var uniqueMethods = [...new Set(data.map(d => d.method))]; |
332 | | - var palette = [ |
333 | | - '#7a9fdc', '#f4a876', '#8fdb8a', '#e38888', '#b18fca', '#a9806a', '#e8a4d6', '#9a9a9a', '#e3d08f', '#a7dbee', |
334 | | - '#4878d0', '#ee854a', '#6acc64', '#d65f5f', '#956cb4', '#8c613c', '#dc7ec0', '#797979', '#d5bb67', '#82c6e2', |
335 | | - '#2e5aa8', '#d66b28', '#4ab345', '#c03a3a', '#7a4e9d', '#6f4623', '#ca5aa9', '#5a5a5a', '#c4a73f', '#5bb0d5', |
336 | | - '#1d4580', '#b5561a', '#359a2e', '#a02525', '#5f3880', '#543316', '#b03d91', '#3e3e3e', '#a88d25', '#3a95bf' |
337 | | - ]; |
| 235 | + var palette = charty.palette; |
338 | 236 | var colorMap = {}; |
339 | 237 | uniqueMethods.forEach((m, i) => colorMap[m] = palette[i % palette.length]); |
340 | 238 |
|
|
353 | 251 |
|
354 | 252 | var methods = data.map(d => d.method); |
355 | 253 | var gpu = data.map(d => d.gpu); |
356 | | - var times = data.map(d => parseHMS(d.times)); |
| 254 | + var times = data.map(d => charty.parseHMS(d.times)); |
357 | 255 |
|
358 | 256 | var uniqueDownsampling = [...new Set(data.map(d => d.downsampling))].sort((a, b) => b - a); |
359 | 257 |
|
|
0 commit comments