@@ -6,8 +6,8 @@ const BASE_URL = "https://raw.githubusercontent.com/dandi/access-summaries/main"
6
6
const BASE_TSV_URL = `${ BASE_URL } /content/summaries` ;
7
7
8
8
const ARCHIVE_TOTALS_URL = `${ BASE_URL } /content/archive_totals.json` ;
9
- const ALL_DANDISET_TOTALS_URL = `${ BASE_URL } /content/all_dandiset_totals .json` ;
10
- const REGION_CODES_TO_LATITUDE_LONGITUDE_URL = `${ BASE_URL } /content/region_codes_to_coordinates.json ` ;
9
+ const ALL_DANDISET_TOTALS_URL = `${ BASE_URL } /content/totals .json` ;
10
+ const REGION_CODES_TO_LATITUDE_LONGITUDE_URL = `${ BASE_URL } /content/region_codes_to_coordinates.yaml ` ;
11
11
12
12
let REGION_CODES_TO_LATITUDE_LONGITUDE = { } ;
13
13
let ALL_DANDISET_TOTALS = { } ;
@@ -28,11 +28,11 @@ window.addEventListener("load", () => {
28
28
if ( logScaleCheckbox ) {
29
29
logScaleCheckbox . addEventListener ( "change" , function ( ) {
30
30
USE_LOG_SCALE = this . checked ;
31
-
31
+
32
32
// Get the current dandiset ID
33
33
const dandiset_selector = document . getElementById ( "dandiset_selector" ) ;
34
34
const selected_dandiset = dandiset_selector . value ;
35
-
35
+
36
36
// Reload plots with the current dandiset ID
37
37
load_over_time_plot ( selected_dandiset ) ;
38
38
load_per_asset_histogram ( selected_dandiset ) ;
@@ -112,15 +112,15 @@ function resizePlots() {
112
112
fetch ( REGION_CODES_TO_LATITUDE_LONGITUDE_URL )
113
113
. then ( ( response ) => {
114
114
if ( ! response . ok ) {
115
- throw new Error ( `Failed to fetch JSON file: ${ response . statusText } ` ) ;
115
+ throw new Error ( `Failed to fetch YAML file: ${ response . statusText } ` ) ;
116
116
}
117
- return response . json ( ) ;
117
+ return response . text ( ) ;
118
118
} )
119
119
. then ( ( data ) => {
120
- REGION_CODES_TO_LATITUDE_LONGITUDE = data ;
120
+ REGION_CODES_TO_LATITUDE_LONGITUDE = jsyaml . load ( data ) ;
121
121
} )
122
122
. catch ( ( error ) => {
123
- console . error ( "Error loading JSON file:" , error ) ;
123
+ console . error ( "Error loading YAML file:" , error ) ;
124
124
} ) ;
125
125
126
126
fetch ( ARCHIVE_TOTALS_URL )
@@ -153,7 +153,20 @@ fetch(ALL_DANDISET_TOTALS_URL)
153
153
} )
154
154
. then ( ( all_dandiset_totals_text ) => {
155
155
Object . assign ( ALL_DANDISET_TOTALS , JSON . parse ( all_dandiset_totals_text ) ) ;
156
- const dandiset_ids = Object . keys ( ALL_DANDISET_TOTALS ) ;
156
+ let dandiset_ids = Object . keys ( ALL_DANDISET_TOTALS ) ;
157
+ dandiset_ids . sort ( ( a , b ) => {
158
+ if ( a === "archive" ) return - 1 ;
159
+ if ( b === "archive" ) return 1 ;
160
+ // Compare as numbers if both are numeric
161
+ const aNum = Number ( a ) ;
162
+ const bNum = Number ( b ) ;
163
+ if ( ! isNaN ( aNum ) && ! isNaN ( bNum ) ) {
164
+ return aNum - bNum ;
165
+ }
166
+ // Fallback to string comparison
167
+ return a . localeCompare ( b ) ;
168
+ } ) ;
169
+
157
170
const selector = document . getElementById ( "dandiset_selector" ) ;
158
171
159
172
if ( ! selector ) {
@@ -208,7 +221,7 @@ function update_totals(dandiset_id) {
208
221
const footnote = document . createElement ( "div" ) ;
209
222
footnote . style . fontSize = "0.5em" ;
210
223
footnote . style . marginTop = "7px" ;
211
- footnote . innerHTML = "<sup>*</sup> These values are only estimates for publically released datasets and are subject to change as additional information becomes available." ;
224
+ footnote . innerHTML = "<sup>*</sup> These values are only estimates for publicly released datasets and are subject to change as additional information becomes available." ;
212
225
totals_element . appendChild ( footnote ) ;
213
226
} catch ( error ) {
214
227
console . error ( "Error:" , error ) ;
@@ -221,13 +234,7 @@ function update_totals(dandiset_id) {
221
234
// Function to fetch and render the over time for a given Dandiset ID
222
235
function load_over_time_plot ( dandiset_id ) {
223
236
const plot_element_id = "over_time_plot" ;
224
- let by_day_summary_tsv_url ;
225
-
226
- if ( dandiset_id === "archive" ) {
227
- by_day_summary_tsv_url = `${ BASE_TSV_URL } /archive_summary_by_day.tsv` ;
228
- } else {
229
- by_day_summary_tsv_url = `${ BASE_TSV_URL } /${ dandiset_id } /dandiset_summary_by_day.tsv` ;
230
- }
237
+ let by_day_summary_tsv_url = `${ BASE_TSV_URL } /${ dandiset_id } /by_day.tsv` ;
231
238
232
239
fetch ( by_day_summary_tsv_url )
233
240
. then ( ( response ) => {
@@ -261,8 +268,9 @@ function load_over_time_plot(dandiset_id) {
261
268
262
269
const plot_info = [
263
270
{
264
- type : "scatter" ,
265
- mode : "lines+markers" ,
271
+ //type: "scatter",
272
+ //mode: "lines+markers",
273
+ type : "bar" ,
266
274
x : dates , // Use raw dates for proper alignment
267
275
y : plot_data ,
268
276
text : dates . map ( ( date , index ) => `${ date } <br>${ human_readable_bytes_sent [ index ] } ` ) ,
@@ -310,7 +318,7 @@ function load_over_time_plot(dandiset_id) {
310
318
// Function to fetch and render histogram over asset IDs
311
319
function load_per_asset_histogram ( dandiset_id ) {
312
320
const plot_element_id = "per_asset_histogram" ;
313
- let by_day_summary_tsv_url = "" ;
321
+ let by_asset_summary_tsv_url = "" ;
314
322
315
323
// Suppress div element content if 'archive' is selected
316
324
if ( dandiset_id === "archive" ) {
@@ -320,10 +328,10 @@ function load_per_asset_histogram(dandiset_id) {
320
328
}
321
329
return "" ;
322
330
} else {
323
- by_day_summary_tsv_url = `${ BASE_TSV_URL } /${ dandiset_id } /dandiset_summary_by_asset .tsv` ;
331
+ by_asset_summary_tsv_url = `${ BASE_TSV_URL } /${ dandiset_id } /by_asset .tsv` ;
324
332
}
325
333
326
- fetch ( by_day_summary_tsv_url )
334
+ fetch ( by_asset_summary_tsv_url )
327
335
. then ( ( response ) => {
328
336
if ( ! response . ok ) {
329
337
throw new Error ( `Failed to fetch TSV file: ${ response . statusText } ` ) ;
@@ -346,23 +354,25 @@ function load_per_asset_histogram(dandiset_id) {
346
354
throw new Error ( "Currently only supports NWB files." ) ;
347
355
}
348
356
349
- // TODO: this was a heuristic idea for shortening the asset names
350
- // const subject_and_session = filename.split("_");
351
- // const subject = subject_and_session.at(0).split("-").slice(1).join("-");
352
- // const session = subject_and_sessions.slice(1).split("-").slice(1).join("-");
353
- // return `${subject} ${session}`;
354
-
355
357
return filename ;
356
358
} ) ;
357
359
const bytes_sent = data . map ( ( row ) => parseInt ( row [ 1 ] , 10 ) ) ;
358
- const human_readable_bytes_sent = bytes_sent . map ( ( bytes ) => format_bytes ( bytes ) ) ;
359
360
361
+ // Sort asset_names and bytes_sent in descending order by bytes_sent
362
+ const combined = asset_names . map ( ( name , idx ) => ( { name, bytes : bytes_sent [ idx ] } ) ) ;
363
+ combined . sort ( ( a , b ) => b . bytes - a . bytes ) ;
364
+
365
+ const sorted_asset_names = combined . map ( item => item . name ) ;
366
+ const sorted_bytes_sent = combined . map ( item => item . bytes ) ;
367
+ const human_readable_bytes_sent = sorted_bytes_sent . map ( ( bytes ) => format_bytes ( bytes ) ) ;
368
+
369
+ // Use sorted arrays in the plot
360
370
const plot_data = [
361
371
{
362
372
type : "bar" ,
363
- x : asset_names ,
364
- y : bytes_sent ,
365
- text : asset_names . map ( ( name , index ) => `${ name } <br>${ human_readable_bytes_sent [ index ] } ` ) ,
373
+ x : sorted_asset_names ,
374
+ y : sorted_bytes_sent ,
375
+ text : sorted_asset_names . map ( ( name , index ) => `${ name } <br>${ human_readable_bytes_sent [ index ] } ` ) ,
366
376
textposition : "none" ,
367
377
hoverinfo : "text" ,
368
378
}
@@ -375,14 +385,10 @@ function load_per_asset_histogram(dandiset_id) {
375
385
} ,
376
386
xaxis : {
377
387
title : {
378
- text : "Asset Name " ,
388
+ text : "(hover over an entry for asset names) " ,
379
389
font : { size : 16 }
380
390
} ,
381
391
showticklabels : false ,
382
- // TODO: ticks are currently too long to fit since heuristic is not working well
383
- // tickangle: -45,
384
- // tickfont: { size: 10 },
385
- // automargin: true,
386
392
} ,
387
393
yaxis : {
388
394
title : {
@@ -403,21 +409,17 @@ function load_per_asset_histogram(dandiset_id) {
403
409
console . error ( "Error:" , error ) ;
404
410
const plot_element = document . getElementById ( plot_element_id ) ;
405
411
if ( plot_element ) {
406
- plot_element . innerText = "Failed to load data for per asset (current supports NWB datasets only)." ;
412
+ while ( plot_element . firstChild ) {
413
+ plot_element . removeChild ( plot_element . firstChild ) ;
414
+ }
407
415
}
408
416
} ) ;
409
417
}
410
418
411
419
// Function to fetch and render heatmap over geography
412
420
function load_geographic_heatmap ( dandiset_id ) {
413
421
const plot_element_id = "geography_heatmap" ;
414
- let by_region_summary_tsv_url ;
415
-
416
- if ( dandiset_id === "archive" ) {
417
- by_region_summary_tsv_url = `${ BASE_TSV_URL } /archive_summary_by_region.tsv` ;
418
- } else {
419
- by_region_summary_tsv_url = `${ BASE_TSV_URL } /${ dandiset_id } /dandiset_summary_by_region.tsv` ;
420
- }
422
+ let by_region_summary_tsv_url = `${ BASE_TSV_URL } /${ dandiset_id } /by_region.tsv` ;
421
423
422
424
if ( ! REGION_CODES_TO_LATITUDE_LONGITUDE ) {
423
425
console . error ( "Error:" , error ) ;
0 commit comments