Brett Cooper
04/07/2023, 10:38 PMMark McClure
05/08/2023, 10:49 AMBrett Cooper
05/08/2023, 1:09 PM{
let year = []
for (const [nameYear, year_value] of so.entries()) {
let body = []
for (const [nameBody, body_value] of year_value.entries()) {
let motor = []
for (const [nameMotor, motor_value] of body_value.entries()) {
motor.push({ name:nameMotor, value: motor_value.length})
}
body.push({ name:nameBody, children: motor})
}
year.push({name:nameYear,children:body});
}
return year
}
So I asked chatGPT if it could be optimized into a recursive functions.
And it say, yes and here is how it would look.
function rollupData(map) {
let result = [];
for (const [key, value] of map.entries()) {
if (value instanceof Map) {
result.push({ name: key, children: rollupData(value) });
} else {
result.push({ name: key, value: value.length });
}
}
return result;
}
I only was working with three levels in my tree but this code means that 'so' can have as many levels as I desire or in any order.
so = d3.group(tsco,
d=> d.Year_of_Registration_date,
d=> d.Body_type,
d=> d.Motor_tech,
d=> d.CO2_band
)
// Year_of_Registration_date
// Month_of_Registration_date
// Body_type
// Import_status
// Motor_tech
// Purchase_region
// Vehicle_class
// CO2_band
// Country
// Engine_vol
// GVM
// Purchase_cust_type
// Veh_Mfr
// CO2_WLTP
The data it rolls works with this. https://observablehq.com/@d3/zoomable-treemappat wo
05/29/2023, 9:50 AMpat wo
06/05/2023, 9:35 AMpat wo
06/14/2023, 3:57 PMNeocarto
06/22/2023, 11:51 AMpat wo
06/30/2023, 9:44 AMBrett Cooper
07/21/2023, 6:39 AMDustin Draaijer
11/17/2023, 7:18 PMMichael Cooper
12/04/2023, 3:35 PM217121-f91854ad
. I hope to see you there!Michael Cooper
12/06/2023, 5:04 PMMatt Dzugan
12/10/2023, 6:27 PMDavid Rio
12/28/2023, 12:25 PMDavid Rio
01/09/2024, 10:00 PMAllison (Observable Team)
01/23/2024, 1:34 PMMax Bo
01/24/2024, 3:53 AMRobert
02/15/2024, 5:30 PMJaan Li
02/18/2024, 9:24 PMpat wo
03/13/2024, 12:33 PMErik Laurijssen
03/22/2024, 3:13 PMStephan Renatus
03/30/2024, 9:42 AMfavicon.ico
when you don’t use any:
<link rel = \"icon\" href = \"data:,\" />
(found here) I guess the same can be done with observable framework.Nathan Cook
03/31/2024, 11:30 PMOndra Švajnoch
04/02/2024, 4:35 PMJaan Li
04/07/2024, 10:55 AMJaan Li
04/08/2024, 2:57 PMAllison (Observable Team)
04/10/2024, 7:26 PMAllison (Observable Team)
04/12/2024, 6:03 PMJaan Li
04/14/2024, 12:54 PMBrent Sullivan
04/22/2024, 6:01 AM