Skip to content
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

Adding the Natural Earth projection #304

Merged
merged 2 commits into from
Jun 9, 2018
Merged
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
27 changes: 26 additions & 1 deletion packages/vx-geo/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,29 @@ Same properties as Mercator.

| Name | Default | Type | Description |
|:--------------- |:------------------- |:-------- |:----------------------------------------------------------------------------------------------------------- |
| className | `vx-albers` | string | The class name for the `path` element. |
| className | `vx-albers` | string | The class name for the `path` element. |

## `<NaturalEarth />`

The Natural Earth projection.

### Example

```js
<NaturalEarth
data={myData}
scale={myScale}
translate={[width / 2, height / 2]}
fill={(feature) => '#aaaaaa'}
onClick={data => event => {
alert(`Clicked!`);
}}
/>
```

### Properties
Same properties as Mercator.

| Name | Default | Type | Description |
|:--------------- |:----------------------------- |:-------- |:----------------------------------------------------------------------------------------------------------- |
| className | `vx-geo-naturalEarth` | string | The class name for the `path` element.
1 change: 1 addition & 0 deletions packages/vx-geo/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as Albers } from './projections/Albers';
export { default as Mercator } from './projections/Mercator';
export { default as Orthographic } from './projections/Orthographic';
export { default as NaturalEarth } from './projections/NaturalEarth';
6 changes: 6 additions & 0 deletions packages/vx-geo/src/projections/NaturalEarth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import Projection from './Projection';

export default function NaturalEarth(props) {
return <Projection projection="naturalEarth" {...props} />;
}
5 changes: 3 additions & 2 deletions packages/vx-geo/src/projections/Projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import cx from 'classnames';
import { Group } from '@vx/group';
import additionalProps from '../util/additionalProps';
import Graticule from '../graticule/Graticule';
import { geoOrthographic, geoAlbers, geoMercator, geoPath } from 'd3-geo';
import { geoOrthographic, geoAlbers, geoMercator, geoNaturalEarth1, geoPath } from 'd3-geo';

// TODO: Implement all projections of d3-geo
const projectionMapping = {
orthographic: () => geoOrthographic(),
albers: () => geoAlbers(),
mercator: () => geoMercator()
mercator: () => geoMercator(),
naturalEarth: () => geoNaturalEarth1()
};

/**
Expand Down