Skip to content

Commit a7c7ab6

Browse files
committed
clean up todos
1 parent 43d945b commit a7c7ab6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docs/summary-table.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,22 @@ async function summary(div, filters, refresh) {
148148
// categorical
149149
if (type === "Utf8") {
150150
const stackOptions = {order: "sum", reverse: true};
151-
const counts = new Map();
151+
let counts = new Map();
152152
let nulls = 0;
153153
for (const v of values) {
154154
if (v == null) {nulls++; continue;}
155155
if (counts.has(v)) counts.set(v, 1 + counts.get(v)); else counts.set(v, 1);
156156
}
157-
const topX = d3.sort(counts, ([, c]) => -c).slice(0, 10);
158-
const visible = new Map(topX.filter(([, c]) => c / count > 0.3));
157+
counts = d3.sort(counts, ([, c]) => -c);
158+
const topX = counts.slice(0, 10);
159+
let visible = new Map(topX.filter(([, c]) => c / count > 0.07));
160+
if (counts.length === visible.size + 1) visible = new Map(counts); // if the “others” group has a single value, use it
159161
const others = d3.sum(counts, ([key, c]) => visible.has(key) ? 0 : c);
160162

161-
// TODO:
162-
// - if the “others” group has a single value, use it
163-
// - if a category is already named "Others", use "…" instead
164-
165163
const bars = [...visible];
166-
const Other = {toString() {return "Other"}};
167-
const Null = {toString() {return "null"}};
164+
165+
const Other = {toString() {return ""}}
166+
const Null = {toString() {return "ø"}};
168167
if (others) bars.push([Other, others]);
169168
if (nulls) bars.push([Null, nulls]);
170169

0 commit comments

Comments
 (0)