Skip to content

default geo clip #1132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ Equivalent to [Plot.dot](#plotdotdata-options) except that the **symbol** option
Plot.geo(counties, {fill: d => d.properties.rate})
```

Returns a new geo mark with the given *data* and *options*. If *data* is a GeoJSON feature collection, then the mark’s data is *data*.features; if *data* is a GeoJSON geometry collection, then the mark’s data is *data*.geometries; if *data* is some other GeoJSON object, then the mark’s data is the single-element array [*data*]. If the **geometry** option is not specified, *data* is assumed to be a GeoJSON object or an iterable of GeoJSON objects.
Returns a new geo mark with the given *data* and *options*. If *data* is a GeoJSON feature collection, then the mark’s data is *data*.features; if *data* is a GeoJSON geometry collection, then the mark’s data is *data*.geometries; if *data* is some other GeoJSON object, then the mark’s data is the single-element array [*data*]. If the **geometry** option is not specified, *data* is assumed to be a GeoJSON object or an iterable of GeoJSON objects. The **clip** option defaults to *frame*, clipping the mark to the frame’s dimensions.

In addition to the [standard mark options](#marks), the **r** option controls the size of Point and MultiPoint geometries. It can be specified as either a channel or constant. When **r** is specified as a number, it is interpreted as a constant radius in pixels; otherwise it is interpreted as a channel and the effective radius is controlled by the *r* scale. (As with [dots](#dot), the *r* scale defaults to a *sqrt* scale such that the visual area of a point is proportional to its associated value.) If the **r** option is not specified it defaults to 3 pixels. Geometries with a nonpositive radius are not drawn. If **r** is a channel, geometries will be sorted by descending radius by default.

Expand Down Expand Up @@ -1289,7 +1289,7 @@ Plot.hexgrid()

<!-- jsdoc hexgrid -->

The **binWidth** option specifies the distance between the centers of neighboring hexagons, in pixels (defaults to 20). The **clip** option defaults to true, clipping the mark to the frame’s dimensions.
The **binWidth** option specifies the distance between the centers of neighboring hexagons, in pixels (defaults to 20). The **clip** option defaults to *frame*, clipping the mark to the frame’s dimensions.

<!-- jsdocEnd hexgrid -->

Expand Down
8 changes: 4 additions & 4 deletions src/marks/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const defaults = {
};

export class Geo extends Mark {
constructor(data, options = {}) {
const [vr, cr] = maybeNumberChannel(options.r, 3);
constructor(data, {clip = "frame", r, geometry, ...options} = {}) {
const [vr, cr] = maybeNumberChannel(r, 3);
super(
data,
{
geometry: {value: options.geometry},
geometry: {value: geometry},
r: {value: vr, scale: "r", filter: positive, optional: true}
},
withDefaultSort(options),
withDefaultSort({clip, ...options}),
defaults
);
this.r = cr;
Expand Down
2 changes: 1 addition & 1 deletion src/marks/hexgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function hexgrid(options) {
}

export class Hexgrid extends Mark {
constructor({binWidth = 20, clip = true, ...options} = {}) {
constructor({binWidth = 20, clip = "frame", ...options} = {}) {
super(undefined, undefined, {clip, ...options}, defaults);
this.binWidth = number(binWidth);
}
Expand Down
15 changes: 9 additions & 6 deletions test/output/armadillo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions test/output/bertin1953Facets.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions test/output/graticule.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion test/output/nullProjection.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading