Skip to content

Commit

Permalink
fix!: change default projection to equalEarth (#7052)
Browse files Browse the repository at this point in the history
fixes #5367
  • Loading branch information
domoritz committed Nov 18, 2020
1 parent 0e79ef0 commit 2c81034
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/vega-lite-schema.json
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
4 changes: 2 additions & 2 deletions examples/compiled/geo_layer_line_london.vg.json
Expand Up @@ -5,6 +5,7 @@
"width": 700,
"height": 500,
"style": "cell",
"encode": {"update": {"stroke": {"value": "transparent"}}},
"data": [
{
"name": "source_0",
Expand Down Expand Up @@ -149,6 +150,5 @@
"symbolType": "circle",
"encode": {"symbols": {"update": {"fill": {"value": "transparent"}}}}
}
],
"config": {"style": {"cell": {"stroke": "transparent"}}}
]
}
6 changes: 2 additions & 4 deletions examples/specs/geo_layer_line_london.vl.json
Expand Up @@ -2,10 +2,8 @@
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": 700,
"height": 500,
"config": {
"view": {
"stroke": "transparent"
}
"view": {
"stroke": "transparent"
},
"layer": [
{
Expand Down
8 changes: 7 additions & 1 deletion src/compile/projection/parse.ts
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
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
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 2c81034

Please sign in to comment.