Skip to content

Commit

Permalink
prefilter data
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Nov 1, 2023
1 parent 2a67261 commit 381341b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/plots/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ import * as Plot from "@observablehq/plot";
import * as d3 from "d3";

export async function findArrow() {
const ilc = await d3.csv<any>("data/ilc_lvps08.csv", d3.autoType);
const ages = ["Y16-19", "Y20-24", "Y25-29"];
const sexes = ["M", "F"];
const ilc = await d3.csv<any>("data/ilc_lvps08.csv", (d) =>
d.geo === "EL" && sexes.includes(d.sex) && ages.includes(d.age) ? d3.autoType(d) : null
);
return Plot.plot({
x: {tickFormat: "", label: null, inset: 10},
y: {grid: true, label: "Greek youth living with parents (%, ↑more male, ↓more female)"},
color: {legend: true, domain: ages},
color: {legend: true},
marks: [
Plot.ruleY([0, 100]),
Plot.lineY(ilc, {
filter: (d) => d.geo === "EL" && d.sex === "F",
filter: (d) => d.sex === "F",
x: "TIME_PERIOD",
y: "OBS_VALUE",
stroke: "age",
strokeOpacity: 0.2
}),
Plot.lineY(ilc, {
filter: (d) => d.geo === "EL" && d.sex === "M",
filter: (d) => d.sex === "M",
x: "TIME_PERIOD",
y: "OBS_VALUE",
stroke: "age"
Expand All @@ -31,7 +34,6 @@ export async function findArrow() {
y2: Plot.find((d) => d.sex === "M")
},
{
filter: (d) => d.geo === "EL",
x: "TIME_PERIOD",
y: "OBS_VALUE",
stroke: "age",
Expand Down

0 comments on commit 381341b

Please sign in to comment.