Skip to content

Commit

Permalink
closes #2085
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Jun 14, 2024
1 parent 7c8a465 commit bef7e75
Show file tree
Hide file tree
Showing 10 changed files with 1,930 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/marks/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export class Geo extends Mark {
data,
{
geometry: {value: options.geometry, scale: "projection"},
x: {value: options.x, scale: "x", optional: true},
y: {value: options.y, scale: "y", optional: true},
r: {value: vr, scale: "r", filter: positive, optional: true}
},
withDefaultSort(options),
Expand Down
6 changes: 4 additions & 2 deletions src/transforms/centroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export function centroid({geometry = identity, ...options} = {}) {
facets,
channels: {
x: {value: X, scale: projection == null ? "x" : null, source: null},
y: {value: Y, scale: projection == null ? "y" : null, source: null}
y: {value: Y, scale: projection == null ? "y" : null, source: null},
geometry: {value: G}
}
};
});
}

export function geoCentroid({geometry = identity, ...options} = {}) {
export function geoCentroid(options = {}) {
let C;
const {geometry = identity} = options;
return {
...options,
x: {transform: (data) => Float64Array.from((C = valueof(valueof(data, geometry), GeoCentroid)), ([x]) => x)},
Expand Down
7 changes: 7 additions & 0 deletions test/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ CBO
https://www.cbo.gov/topics/budget/accuracy-projections
https://observablehq.com/@tophtucker/examples-of-bitemporal-charts

## london.json
giCentre, City University of London
https://github.com/gicentre/data

## london-car-access.csv
Jo Wood, TK

## metros.csv
The New York Times
https://www.nytimes.com/2019/12/02/upshot/wealth-poverty-divide-american-cities.html
Expand Down
34 changes: 34 additions & 0 deletions test/data/london-car-access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
borough,y2001,y2011,y2021
City of London,0.380,0.306,0.228
Barking and Dagenham,0.621,0.604,0.652
Barnet,0.733,0.713,0.701
Bexley,0.763,0.763,0.776
Brent,0.627,0.570,0.559
Bromley,0.770,0.765,0.771
Camden,0.444,0.389,0.364
Croydon,0.702,0.665,0.664
Ealing,0.683,0.647,0.632
Enfield,0.715,0.675,0.690
Greenwich,0.592,0.580,0.569
Hammersmith and Fulham,0.514,0.448,0.425
Haringey,0.535,0.482,0.473
Harrow,0.773,0.765,0.753
Havering,0.767,0.770,0.785
Hillingdon,0.783,0.773,0.777
Hounslow,0.714,0.684,0.672
Islington,0.424,0.353,0.331
Kensington and Chelsea,0.496,0.440,0.417
Kingston upon Thames,0.762,0.749,0.743
Lambeth,0.491,0.422,0.420
Lewisham,0.572,0.519,0.523
Merton,0.699,0.674,0.670
Newham,0.511,0.479,0.483
Redbridge,0.738,0.721,0.725
Richmond upon Thames,0.763,0.753,0.746
Southwark,0.481,0.416,0.397
Sutton,0.767,0.766,0.772
Tower Hamlets,0.432,0.370,0.336
Waltham Forest,0.610,0.581,0.579
Wandsworth,0.593,0.547,0.521
Westminster,0.436,0.371,0.338
Hackney,0.440,0.354,0.351
Loading

0 comments on commit bef7e75

Please sign in to comment.