Skip to content

Commit

Permalink
fix: support x/yOffset without x/y (#9135)
Browse files Browse the repository at this point in the history
* fix: remove 'replaceOffsetWithMainChannel'

* chore: update examples [CI]

* fix: support x/yOffset without x/y

* chore: update examples [CI]

---------

Co-authored-by: Fan Du <fan.du@databricks.com>
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 12, 2023
1 parent 270bfef commit 58294a7
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 96 deletions.
Binary file added examples/compiled/bar_x_offset_without_x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/compiled/bar_x_offset_without_x.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "xOffset without x will be replaced as x",
"description": "xOffset without x",
"background": "white",
"padding": 5,
"width": 20,
"height": 200,
"style": "cell",
"data": [
Expand Down Expand Up @@ -39,13 +40,6 @@
]
}
],
"signals": [
{"name": "x_step", "value": 20},
{
"name": "width",
"update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
}
],
"marks": [
{
"name": "marks",
Expand All @@ -59,23 +53,19 @@
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; group: \" + (isValid(datum[\"group\"]) ? datum[\"group\"] : \"\"+datum[\"group\"])"
},
"x": {"scale": "x", "field": "group"},
"width": {"signal": "max(0.25, bandwidth('x'))"},
"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"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {"data": "data_0", "field": "group", "sort": true},
"range": {"step": {"signal": "x_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
},
{
"name": "y",
"type": "linear",
Expand All @@ -84,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",
Expand All @@ -95,7 +91,6 @@
{
"scale": "y",
"orient": "left",
"gridScale": "x",
"grid": true,
"tickCount": {"signal": "ceil(height/40)"},
"domain": false,
Expand All @@ -106,16 +101,6 @@
"ticks": false,
"zindex": 0
},
{
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "group",
"labelAlign": "right",
"labelAngle": 270,
"labelBaseline": "middle",
"zindex": 0
},
{
"scale": "y",
"orient": "left",
Expand Down
Binary file removed examples/compiled/bar_x_offset_without_x_broken.png
Binary file not shown.
1 change: 0 additions & 1 deletion examples/compiled/bar_x_offset_without_x_broken.svg

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "xOffset without x will be replaced as x",
"description": "xOffset without x",
"data": {
"values": [
{"category":"A", "group": "x", "value":0.1},
Expand Down

0 comments on commit 58294a7

Please sign in to comment.