Skip to content

Commit

Permalink
feat!: change default projection to equalEarth
Browse files Browse the repository at this point in the history
fixes #5367
  • Loading branch information
domoritz committed Nov 18, 2020
1 parent 3467506 commit 4653fda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20364,7 +20364,7 @@
},
"type": {
"$ref": "#/definitions/ProjectionType",
"description": "The cartographic projection to use. This value is case-insensitive, for example `\"albers\"` and `\"Albers\"` indicate the same projection type. You can find all valid projection types [in the documentation](https://vega.github.io/vega-lite/docs/projection.html#projection-types).\n\n__Default value:__ `mercator`"
"description": "The cartographic projection to use. This value is case-insensitive, for example `\"albers\"` and `\"Albers\"` indicate the same projection type. You can find all valid projection types [in the documentation](https://vega.github.io/vega-lite/docs/projection.html#projection-types).\n\n__Default value:__ `equalEarth`"
}
},
"type": "object"
Expand Down
8 changes: 7 additions & 1 deletion src/compile/projection/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function parseUnitProjection(model: UnitModel): ProjectionComponent {
const size = fit ? [model.getSizeSignalRef('width'), model.getSizeSignalRef('height')] : undefined;
const data = fit ? gatherFitData(model) : undefined;

return new ProjectionComponent(
const projComp = new ProjectionComponent(
model.projectionName(true),
{
...(model.config.projection ?? {}),
Expand All @@ -30,6 +30,12 @@ function parseUnitProjection(model: UnitModel): ProjectionComponent {
size,
data
);

if (!projComp.get('type')) {
projComp.set('type', 'equalEarth', false);
}

return projComp;
}

return undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface Projection extends BaseProjection {
/**
* The cartographic projection to use. This value is case-insensitive, for example `"albers"` and `"Albers"` indicate the same projection type. You can find all valid projection types [in the documentation](https://vega.github.io/vega-lite/docs/projection.html#projection-types).
*
* __Default value:__ `mercator`
* __Default value:__ `equalEarth`
*/
type?: ProjectionType | SignalRef; // Re-declare to override docs

Expand Down
1 change: 1 addition & 0 deletions test/compile/projection/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('src/compile/projection/parse', () => {
});
model.parse();
expect(model.component.projection.explicit).toEqual({});
expect(model.component.projection.implicit).toEqual({name: 'projection', type: 'equalEarth'});
});

it('should create projection from config', () => {
Expand Down

0 comments on commit 4653fda

Please sign in to comment.