diff --git a/examples/compiled/geo_facet.png b/examples/compiled/geo_facet.png
new file mode 100644
index 0000000000..aae816b8ab
Binary files /dev/null and b/examples/compiled/geo_facet.png differ
diff --git a/examples/compiled/geo_facet.svg b/examples/compiled/geo_facet.svg
new file mode 100644
index 0000000000..9810913084
--- /dev/null
+++ b/examples/compiled/geo_facet.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/examples/compiled/geo_facet.vg.json b/examples/compiled/geo_facet.vg.json
new file mode 100644
index 0000000000..105b72b0e4
--- /dev/null
+++ b/examples/compiled/geo_facet.vg.json
@@ -0,0 +1,143 @@
+{
+ "$schema": "https://vega.github.io/schema/vega/v5.json",
+ "description": "Faceting folded column data (this could also be done using `repeat` without the transform fold.",
+ "background": "white",
+ "padding": 5,
+ "data": [
+ {
+ "name": "source_1",
+ "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/population_engineers_hurricanes.csv",
+ "format": {"type": "csv"}
+ },
+ {
+ "name": "source_0",
+ "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
+ "format": {"feature": "states", "type": "topojson"},
+ "transform": [
+ {
+ "type": "lookup",
+ "from": "source_1",
+ "key": "id",
+ "fields": ["id"],
+ "values": ["population", "engineers", "hurricanes"]
+ },
+ {
+ "type": "fold",
+ "fields": ["population", "engineers", "hurricanes"],
+ "as": ["key", "value"]
+ },
+ {
+ "type": "filter",
+ "expr": "isValid(datum[\"value\"]) && isFinite(+datum[\"value\"])"
+ }
+ ]
+ },
+ {
+ "name": "row_domain",
+ "source": "source_0",
+ "transform": [{"type": "aggregate", "groupby": ["key"]}]
+ }
+ ],
+ "projections": [
+ {
+ "name": "projection",
+ "size": {"signal": "[child_width, child_height]"},
+ "fit": {"signal": "data('source_0')"},
+ "type": "albersUsa"
+ }
+ ],
+ "signals": [
+ {"name": "child_width", "value": 200},
+ {"name": "child_height", "value": 100}
+ ],
+ "layout": {
+ "padding": 20,
+ "offset": {"rowTitle": 10},
+ "columns": 1,
+ "bounds": "full",
+ "align": "all"
+ },
+ "marks": [
+ {
+ "name": "row-title",
+ "type": "group",
+ "role": "row-title",
+ "title": {
+ "text": "key",
+ "orient": "left",
+ "style": "guide-title",
+ "offset": 10
+ }
+ },
+ {
+ "name": "row_header",
+ "type": "group",
+ "role": "row-header",
+ "from": {"data": "row_domain"},
+ "sort": {"field": "datum[\"key\"]", "order": "ascending"},
+ "title": {
+ "text": {
+ "signal": "isValid(parent[\"key\"]) ? parent[\"key\"] : \"\"+parent[\"key\"]"
+ },
+ "orient": "left",
+ "style": "guide-label",
+ "frame": "group",
+ "offset": 10
+ },
+ "encode": {"update": {"height": {"signal": "child_height"}}}
+ },
+ {
+ "name": "cell",
+ "type": "group",
+ "style": "view",
+ "from": {
+ "facet": {"name": "facet", "data": "source_0", "groupby": ["key"]}
+ },
+ "sort": {"field": ["datum[\"key\"]"], "order": ["ascending"]},
+ "encode": {
+ "update": {
+ "width": {"signal": "child_width"},
+ "height": {"signal": "child_height"}
+ }
+ },
+ "marks": [
+ {
+ "name": "child_marks",
+ "type": "shape",
+ "style": ["geoshape"],
+ "from": {"data": "facet"},
+ "encode": {
+ "update": {
+ "tooltip": {
+ "signal": "{\"value\": format(datum[\"value\"], \"\")}"
+ },
+ "fill": {"scale": "child_color", "field": "value"},
+ "ariaRoleDescription": {"value": "geoshape"},
+ "description": {
+ "signal": "\"value: \" + (format(datum[\"value\"], \"\"))"
+ }
+ }
+ },
+ "transform": [{"type": "geoshape", "projection": "projection"}]
+ }
+ ],
+ "scales": [
+ {
+ "name": "child_color",
+ "type": "linear",
+ "domain": {"data": "facet", "field": "value"},
+ "range": "heatmap",
+ "interpolate": "hcl",
+ "zero": false
+ }
+ ],
+ "legends": [
+ {
+ "fill": "child_color",
+ "gradientLength": {"signal": "clamp(child_height, 64, 200)"},
+ "title": "value"
+ }
+ ]
+ }
+ ]
+}
diff --git a/examples/compiled/geo_layer_line_london.png b/examples/compiled/geo_layer_line_london.png
index 2cfff77c85..af61dc67ad 100644
Binary files a/examples/compiled/geo_layer_line_london.png and b/examples/compiled/geo_layer_line_london.png differ
diff --git a/examples/compiled/geo_layer_line_london.svg b/examples/compiled/geo_layer_line_london.svg
index 0980fd6d40..0196975bfb 100644
--- a/examples/compiled/geo_layer_line_london.svg
+++ b/examples/compiled/geo_layer_line_london.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/geo_layer_line_london.vg.json b/examples/compiled/geo_layer_line_london.vg.json
index c2bf00c0f3..5de7f6978f 100644
--- a/examples/compiled/geo_layer_line_london.vg.json
+++ b/examples/compiled/geo_layer_line_london.vg.json
@@ -45,9 +45,7 @@
{
"name": "projection",
"size": {"signal": "[width, height]"},
- "fit": {
- "signal": "[data('source_0'), layer_1_geojson_0, data('source_2')]"
- }
+ "fit": {"signal": "[data('source_0'), layer_1_geojson_0]"}
}
],
"marks": [
diff --git a/examples/compiled/interactive_geo_earthquakes.vg.json b/examples/compiled/interactive_geo_earthquakes.vg.json
index 8468689405..58caf1393c 100644
--- a/examples/compiled/interactive_geo_earthquakes.vg.json
+++ b/examples/compiled/interactive_geo_earthquakes.vg.json
@@ -54,7 +54,7 @@
{
"name": "projection",
"size": {"signal": "[width, height]"},
- "fit": {"signal": "[data('source_0'), data('world'), layer_2_geojson_0]"},
+ "fit": {"signal": "[data('source_0'), layer_2_geojson_0]"},
"type": "orthographic",
"rotate": {"signal": "[rotate0, rotate1, 0]"}
}
diff --git a/examples/specs/geo_facet.vl.json b/examples/specs/geo_facet.vl.json
new file mode 100644
index 0000000000..75afa76ed8
--- /dev/null
+++ b/examples/specs/geo_facet.vl.json
@@ -0,0 +1,29 @@
+{
+ "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
+ "description": "Faceting folded column data (this could also be done using `repeat` without the transform fold.",
+ "data": {
+ "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
+ "format": {"feature": "states", "type": "topojson"}
+ },
+ "facet": {"row": {"field": "key", "type": "nominal"}},
+ "spec": {
+ "mark": {"type": "geoshape", "tooltip": true},
+ "encoding": {"color": {"field": "value", "type": "quantitative"}},
+ "height": 100,
+ "projection": {"type": "albersUsa"},
+ "transform": [
+ {
+ "lookup": "id",
+ "from": {
+ "data": {
+ "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/population_engineers_hurricanes.csv"
+ },
+ "key": "id",
+ "fields": ["population", "engineers", "hurricanes"]
+ }
+ },
+ {"fold": ["population", "engineers", "hurricanes"]}
+ ]
+ },
+ "resolve": {"scale": {"color": "independent"}}
+}
diff --git a/site/_data/examples.json b/site/_data/examples.json
index a04bc1af32..72fb505537 100644
--- a/site/_data/examples.json
+++ b/site/_data/examples.json
@@ -761,7 +761,12 @@
{
"name": "geo_repeat",
"png": true,
- "title": "Three Choropleths Representing Disjoint Data from the Same Table"
+ "title": "Three Repeated Choropleths"
+ },
+ {
+ "name": "geo_facet",
+ "png": true,
+ "title": "Three Faceted Choropleths"
},
{
"name": "geo_text",
diff --git a/src/compile/projection/assemble.ts b/src/compile/projection/assemble.ts
index 909eccb2a2..215d8f7a62 100644
--- a/src/compile/projection/assemble.ts
+++ b/src/compile/projection/assemble.ts
@@ -44,7 +44,9 @@ export function assembleProjectionForModel(model: Model): VgProjection[] {
};
const fits: string[] = component.data.reduce((sources, data) => {
- const source: string = isSignalRef(data) ? data.signal : `data('${model.lookupDataSource(data)}')`;
+ const source: string = isSignalRef(data)
+ ? data.signal
+ : `data('${model.lookupDataSource(model.component.data.sources[0].dataName)}')`;
if (!contains(sources, source)) {
// build a unique list of sources
sources.push(source);