@@ -51,58 +51,13 @@ import { movingAverageLinePlot } from "./components/movingAverageLinePlot.js";
51
51
` ` `
52
52
53
53
54
- <div class="card">
55
- <h2>TIMEFRAME</h2>
56
-
57
- ` ` ` js
58
- const timeframe = view (Inputs .radio ([" All" , " 365d" , " 180d" , " 90d" , " 30d" , " Custom" ], {value: params .has (' from_date' ) || params .has (' to_date' ) ? " Custom" : " All" }));
59
- ` ` `
60
-
61
- ` ` ` js
62
- const startDate = timeframe === " Custom" ? view (Inputs .date ({
63
- label: " Start" ,
64
- value: from_date,
65
- })) : from_date;
66
-
67
- const endDate = timeframe === " Custom" ? view (Inputs .date ({
68
- label: " End" ,
69
- value: to_date,
70
- })) : to_date;
71
- ` ` `
72
-
73
- ` ` ` js
74
- if (timeframe === " Custom" ) {
75
- updateURLParams (startDate .toISOString ().split (' T' )[0 ], endDate .toISOString ().split (' T' )[0 ]);
76
- } else if (timeframe === " 365d" ) {
77
- const daysAgo = new Date ();
78
- daysAgo .setDate (daysAgo .getDate () - 365 );
79
- updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
80
- } else if (timeframe === " 180d" ) {
81
- const daysAgo = new Date ();
82
- daysAgo .setDate (daysAgo .getDate () - 180 );
83
- updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
84
- } else if (timeframe === " 90d" ) {
85
- const daysAgo = new Date ();
86
- daysAgo .setDate (daysAgo .getDate () - 90 );
87
- updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
88
- } else if (timeframe === " 30d" ) {
89
- const daysAgo = new Date ();
90
- daysAgo .setDate (daysAgo .getDate () - 30 );
91
- updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
92
- } else if (timeframe === " All" ) {
93
- // Clear URL params
94
- window .history .replaceState ({}, ' ' , window .location .pathname );
95
- }
96
- ` ` `
97
-
98
- </div>
99
54
100
55
101
56
` ` ` js
102
57
function getFilteredData (data , timeframe , startDate , endDate ) {
103
58
if (timeframe === " All" ) return data;
104
59
if (timeframe === " Custom" ) return data .filter (d => d .date >= startDate && d .date <= endDate);
105
-
60
+
106
61
const days = parseInt (timeframe .replace (' d' , ' ' ));
107
62
const cutoffDate = new Date ();
108
63
cutoffDate .setDate (cutoffDate .getDate () - days);
@@ -1333,3 +1288,49 @@ Here are some resources for you to explore and learn more about Filecoin data.
1333
1288
1334
1289
1335
1290
_Charts shown here are for informational purposes only. The data pipelines powering this are optimized for analytical purposes and might not be 100% accurate._
1291
+
1292
+ <div id="timeframe-selector">
1293
+ <h3>Timeframe</h3>
1294
+
1295
+ ` ` ` js
1296
+ const timeframe = view (Inputs .radio ([" All" , " 365d" , " 180d" , " 90d" , " 30d" , " Custom" ], {value: params .has (' from_date' ) || params .has (' to_date' ) ? " Custom" : " All" }));
1297
+ ` ` `
1298
+
1299
+ ` ` ` js
1300
+ const startDate = timeframe === " Custom" ? view (Inputs .date ({
1301
+ label: " Start" ,
1302
+ value: from_date,
1303
+ })) : from_date;
1304
+
1305
+ const endDate = timeframe === " Custom" ? view (Inputs .date ({
1306
+ label: " End" ,
1307
+ value: to_date,
1308
+ })) : to_date;
1309
+ ` ` `
1310
+
1311
+ ` ` ` js
1312
+ if (timeframe === " Custom" ) {
1313
+ updateURLParams (startDate .toISOString ().split (' T' )[0 ], endDate .toISOString ().split (' T' )[0 ]);
1314
+ } else if (timeframe === " 365d" ) {
1315
+ const daysAgo = new Date ();
1316
+ daysAgo .setDate (daysAgo .getDate () - 365 );
1317
+ updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
1318
+ } else if (timeframe === " 180d" ) {
1319
+ const daysAgo = new Date ();
1320
+ daysAgo .setDate (daysAgo .getDate () - 180 );
1321
+ updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
1322
+ } else if (timeframe === " 90d" ) {
1323
+ const daysAgo = new Date ();
1324
+ daysAgo .setDate (daysAgo .getDate () - 90 );
1325
+ updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
1326
+ } else if (timeframe === " 30d" ) {
1327
+ const daysAgo = new Date ();
1328
+ daysAgo .setDate (daysAgo .getDate () - 30 );
1329
+ updateURLParams (daysAgo .toISOString ().split (' T' )[0 ], new Date ().toISOString ().split (' T' )[0 ]);
1330
+ } else if (timeframe === " All" ) {
1331
+ // Clear URL params
1332
+ window .history .replaceState ({}, ' ' , window .location .pathname );
1333
+ }
1334
+ ` ` `
1335
+
1336
+ </div>
0 commit comments