Skip to content

Commit 79d4538

Browse files
committed
pRetTIEr
1 parent bf05165 commit 79d4538

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/marks/geometry.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,22 @@ export class Geometry extends Mark {
4949

5050
export function geometry(data, options) {
5151
switch (data?.type) {
52-
case "FeatureCollection": data = data.features; break;
53-
case "GeometryCollection": data = data.geometries; break;
52+
case "FeatureCollection":
53+
data = data.features;
54+
break;
55+
case "GeometryCollection":
56+
data = data.geometries;
57+
break;
5458
case "Feature":
5559
case "LineString":
5660
case "MultiLineString":
5761
case "MultiPoint":
5862
case "MultiPolygon":
5963
case "Point":
6064
case "Polygon":
61-
case "Sphere": data = [data]; break;
65+
case "Sphere":
66+
data = [data];
67+
break;
6268
}
6369
return new Geometry(data, options);
6470
}

src/projection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export function maybeProjection(projection, dimensions) {
99
if (typeof projection === "function") return projection;
1010
const {width, height} = dimensions;
1111
switch (`${projection}`.toLowerCase()) {
12-
case "albers-usa": return geoAlbersUsa().scale(Math.min(1.34 * width, 2.14 * height)).translate([width / 2, height / 2]);
12+
case "albers-usa":
13+
return geoAlbersUsa()
14+
.scale(Math.min(1.34 * width, 2.14 * height))
15+
.translate([width / 2, height / 2]);
1316
}
1417
throw new Error(`invalid projection: ${projection}`);
1518
}

test/plots/us-county-choropleth.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import {feature, mesh} from "topojson-client";
44

55
export default async function () {
66
const [[counties, statemesh], unemployment] = await Promise.all([
7-
d3.json("data/us-counties-10m.json").then((us) => ([feature(us, us.objects.counties), mesh(us, us.objects.states, (a, b) => a !== b)])),
7+
d3
8+
.json("data/us-counties-10m.json")
9+
.then((us) => [feature(us, us.objects.counties), mesh(us, us.objects.states, (a, b) => a !== b)]),
810
d3.csv("data/us-county-unemployment.csv").then((data) => new Map(data.map(({id, rate}) => [id, +rate])))
911
]);
1012
return Plot.plot({
@@ -21,7 +23,7 @@ export default async function () {
2123
label: "Unemployment (%)"
2224
},
2325
marks: [
24-
Plot.geometry(counties, {fill: d => unemployment.get(d.id), title: d => d.properties.name}), // TODO string accessors for properties, id
26+
Plot.geometry(counties, {fill: (d) => unemployment.get(d.id), title: (d) => d.properties.name}), // TODO string accessors for properties, id
2527
Plot.geometry(statemesh, {stroke: "white"})
2628
]
2729
});

0 commit comments

Comments
 (0)