@@ -65,7 +65,7 @@ const latencyByRouteCanvas = document.createElement("canvas");
65
65
66
66
``` js
67
67
const latencyHistogram = FileAttachment (" data/latency-histogram.parquet" ).parquet ();
68
- const histogramCanvas = document .createElement (" canvas" );
68
+ const histogramCanvas_new = document .createElement (" canvas" );
69
69
```
70
70
71
71
``` js
@@ -74,30 +74,33 @@ const routeColor = Object.assign(Plot.scale({color: {domain: topRoutesPixel.map(
74
74
const routeSwatch = (route ) => html ` <span style =" white-space : nowrap ;" ><svg width =10 height =10 fill =${routeColor.apply(route)} ><rect width =10 height =10 ></rect ></svg > <span class =" small" >${ route} </span ></span >` ;
75
75
```
76
76
77
- <div class =" grid grid-cols-2 " style =" grid-auto-rows : 504px ;" >
77
+ ``` js
78
+ const incomeData = FileAttachment (" data/income-histogram.parquet" ).parquet ();
79
+ const histogramCanvas = document .createElement (" canvas" );
80
+ ```
81
+
78
82
83
+ ``` js
84
+ // Assuming modification for categorization based on age
85
+ const ageColorMapping = d3 .sort (d3 .rollups (incomeData .getChild (" age" ), (D ) => D .length , (d ) => d).filter (([d ]) => d), ([, d ]) => - d).map (([age , count ]) => ({age, count}));
86
+ const ageColor = Object .assign (Plot .scale ({color: {domain: ageColorMapping .map ((d ) => d .age .toString ())}}), {label: " age" });
87
+ const ageSwatch = (age ) => html ` <span style =" white-space : nowrap ;" ><svg width =10 height =10 fill =${ageColor.apply(age.toString())} ><rect width =10 height =10 ></rect ></svg > <span class =" small" >${ age} </span ></span >` ;
88
+ ```
89
+
90
+
91
+ <div class =" grid grid-cols-2 " style =" grid-auto-rows : 504px ;" >
92
+ <div class =" card " >
93
+ <h2>Income Distribution by Age</h2>
94
+ ${resize((width) => ApiHistogram(incomeData.getChild("income"), incomeData.getChild("count"), incomeData.getChild("age"), {canvas: histogramCanvas, color: ageColor, width, label: "Income ($)", y1: 0.5, y2: 100_000}))}
95
+ </div >
79
96
<div class =" card " >
80
97
<h2>Response latency histogram</h2>
81
- ${resize((width) => ApiHistogram(latencyHistogram.getChild("duration"), latencyHistogram.getChild("count"), latencyHistogram.getChild("route"), {canvas: histogramCanvas , color: routeColor, width, label: "Duration (ms)", y1: 0.5, y2: 10_000}))}
98
+ ${resize((width) => ApiHistogram(latencyHistogram.getChild("duration"), latencyHistogram.getChild("count"), latencyHistogram.getChild("route"), {canvas: histogramCanvas_new , color: routeColor, width, label: "Duration (ms)", y1: 0.5, y2: 10_000}))}
82
99
</div >
83
- <div class =" card " >${
84
- resize((width) => Plot.plot({
85
- title: "How big are penguins, anyway? 🐧",
86
- width,
87
- grid: true,
88
- x: {label: "Body mass (g)"},
89
- y: {label: "Flipper length (mm)"},
90
- color: {legend: true},
91
- marks: [
92
- Plot.linearRegressionY(penguins, {x: "body_mass_g", y: "flipper_length_mm", stroke: "species"}),
93
- Plot.dot(penguins, {x: "body_mass_g", y: "flipper_length_mm", stroke: "species", tip: true})
94
- ]
95
- }))
96
- }</div >
97
100
</div >
98
101
99
102
---
100
-
103
+ <!--
101
104
## Next steps
102
105
103
106
Here are some ideas of things you could try…
@@ -124,4 +127,4 @@ Here are some ideas of things you could try…
124
127
<div class="card">
125
128
Visit <a href="https://github.com/observablehq/framework">Framework on GitHub</a> and give us a star. Or file an issue if you’ve found a bug!
126
129
</div>
127
- </div >
130
+ </div> -->
0 commit comments