diff --git a/examples/compiled/bar_x_offset_without_x.png b/examples/compiled/bar_x_offset_without_x.png index 122bd1ac9e..dddf972e29 100644 Binary files a/examples/compiled/bar_x_offset_without_x.png and b/examples/compiled/bar_x_offset_without_x.png differ diff --git a/examples/compiled/bar_x_offset_without_x.svg b/examples/compiled/bar_x_offset_without_x.svg index 3d7578d3ff..339c464fe7 100644 --- a/examples/compiled/bar_x_offset_without_x.svg +++ b/examples/compiled/bar_x_offset_without_x.svg @@ -1 +1 @@ -01234valuexyzgroup \ No newline at end of file +0.00.51.01.52.0valuexyzgroup \ No newline at end of file diff --git a/examples/compiled/bar_x_offset_without_x.vg.json b/examples/compiled/bar_x_offset_without_x.vg.json index 99fefe0cf2..c3fb601dde 100644 --- a/examples/compiled/bar_x_offset_without_x.vg.json +++ b/examples/compiled/bar_x_offset_without_x.vg.json @@ -27,9 +27,9 @@ "transform": [ { "type": "stack", - "groupby": [], + "groupby": ["group"], "field": "value", - "sort": {"field": ["group"], "order": ["descending"]}, + "sort": {"field": [], "order": []}, "as": ["value_start", "value_end"], "offset": "zero" }, @@ -53,8 +53,12 @@ "description": { "signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; group: \" + (isValid(datum[\"group\"]) ? datum[\"group\"] : \"\"+datum[\"group\"])" }, - "xc": {"signal": "width", "mult": 0.5, "offset": {"field": "group"}}, - "width": {"signal": "0.9 * width"}, + "x": { + "signal": "width", + "mult": 0.5, + "offset": {"scale": "xOffset", "field": "group"} + }, + "width": {"signal": "max(0.25, bandwidth('xOffset'))"}, "y": {"scale": "y", "field": "value_end"}, "y2": {"scale": "y", "field": "value_start"} } @@ -70,6 +74,12 @@ "nice": true, "zero": true }, + { + "name": "xOffset", + "type": "band", + "domain": {"data": "data_0", "field": "group", "sort": true}, + "range": [{"signal": "-width/2"}, {"signal": "width/2"}] + }, { "name": "color", "type": "ordinal",