Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make tick support relative band size (so it works better with binned fields) #9176

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27803,6 +27803,11 @@
],
"description": "For text marks, the vertical text baseline. One of `\"alphabetic\"` (default), `\"top\"`, `\"middle\"`, `\"bottom\"`, `\"line-top\"`, `\"line-bottom\"`, or an expression reference that provides one of the valid values. The `\"line-top\"` and `\"line-bottom\"` values operate similarly to `\"top\"` and `\"bottom\"`, but are calculated relative to the `lineHeight` rather than `fontSize` alone.\n\nFor range marks, the vertical alignment of the marks. One of `\"top\"`, `\"middle\"`, `\"bottom\"`.\n\n__Note:__ Expression reference is *not* supported for range marks."
},
"binSpacing": {
"description": "Offset between bars for binned field. The ideal value for this is either 0 (preferred by statisticians) or 1 (Vega-Lite default, D3 example style).\n\n__Default value:__ `1`",
"minimum": 0,
"type": "number"
},
"blend": {
"anyOf": [
{
Expand All @@ -27828,6 +27833,11 @@
],
"description": "Default color.\n\n__Default value:__ <span style=\"color: #4682b4;\">&#9632;</span> `\"#4682b4\"`\n\n__Note:__\n- This property cannot be used in a [style config](https://vega.github.io/vega-lite/docs/mark.html#style-config).\n- The `fill` and `stroke` properties have higher precedence than `color` and will override `color`."
},
"continuousBandSize": {
"description": "The default size of the bars on continuous scales.\n\n__Default value:__ `5`",
"minimum": 0,
"type": "number"
},
"cornerRadius": {
"anyOf": [
{
Expand Down Expand Up @@ -27916,6 +27926,18 @@
}
]
},
"discreteBandSize": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/RelativeBandSize"
}
],
"description": "The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars.",
"minimum": 0
},
"dx": {
"anyOf": [
{
Expand Down Expand Up @@ -28128,6 +28150,17 @@
}
]
},
"minBandSize": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "The minimum band size for bar and rectangle marks. __Default value:__ `0.25`"
},
"opacity": {
"anyOf": [
{
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/bar_bullet_expr_bind.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@
"description": {
"signal": "\"markers[0]: \" + (format(datum[\"markers.0\"], \"\"))"
},
"width": {"value": 2},
"xc": {"scale": "x", "field": "markers\\.0"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"signal": "height"},
"width": {"value": 2}
"height": {"signal": "height"}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/compiled/bar_tooltip_aggregate.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"description": {
"signal": "\"Mean of data: \" + (format(datum[\"mean_data\"], \"\"))"
},
"height": {"value": 1},
"xc": {"signal": "width", "mult": 0.5},
"yc": {"scale": "y", "field": "mean_data"},
"width": {"value": 15},
"height": {"value": 1}
"width": {"mult": 0.75, "field": {"group": "width"}},
"yc": {"scale": "y", "field": "mean_data"}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/compiled/bar_tooltip_groupby.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"description": {
"signal": "\"Mean of data: \" + (format(datum[\"mean_data\"], \"\")) + \"; data: \" + (isValid(datum[\"data\"]) ? datum[\"data\"] : \"\"+datum[\"data\"])"
},
"height": {"value": 1},
"xc": {"signal": "width", "mult": 0.5},
"yc": {"scale": "y", "field": "mean_data"},
"width": {"value": 15},
"height": {"value": 1}
"width": {"mult": 0.75, "field": {"group": "width"}},
"yc": {"scale": "y", "field": "mean_data"}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_1D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@
"tooltip": {
"signal": "{\"Upper Whisker of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Lower Whisker of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\")}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "lower_whisker_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 15},
"width": {"value": 1}
"height": {"mult": 0.75, "field": {"group": "height"}}
}
}
},
Expand All @@ -231,10 +231,10 @@
"tooltip": {
"signal": "{\"Upper Whisker of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Lower Whisker of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\")}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "upper_whisker_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 15},
"width": {"value": 1}
"height": {"mult": 0.75, "field": {"group": "height"}}
}
}
},
Expand Down Expand Up @@ -273,10 +273,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_1D_horizontal_explicit.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_1D_invalid.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@
"tooltip": {
"signal": "{\"Max of b\": format(datum[\"max_b\"], \"\"), \"Q3 of b\": format(datum[\"upper_box_b\"], \"\"), \"Median of b\": format(datum[\"mid_box_b\"], \"\"), \"Q1 of b\": format(datum[\"lower_box_b\"], \"\"), \"Min of b\": format(datum[\"min_b\"], \"\"), \"a\": format(datum[\"a\"], \"\")}"
},
"height": {"value": 1},
"xc": {"scale": "x", "field": "a"},
"yc": {"scale": "y", "field": "mid_box_b"},
"width": {"value": 14},
"height": {"value": 1}
"yc": {"scale": "y", "field": "mid_box_b"}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_1D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}"
},
"height": {"value": 1},
"xc": {"signal": "width", "mult": 0.5},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"width": {"value": 14},
"height": {"value": 1}
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_2D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_2D_horizontal_color_size.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 10},
"width": {"value": 1}
"height": {"value": 10}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_2D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"height": {"value": 1},
"xc": {"scale": "x", "field": "Species", "band": 0.5},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"width": {"value": 14},
"height": {"value": 1}
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_groupped.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@
"tooltip": {
"signal": "{\"Max of Acceleration\": format(datum[\"max_Acceleration\"], \"\"), \"Q3 of Acceleration\": format(datum[\"upper_box_Acceleration\"], \"\"), \"Median of Acceleration\": format(datum[\"mid_box_Acceleration\"], \"\"), \"Q1 of Acceleration\": format(datum[\"lower_box_Acceleration\"], \"\"), \"Min of Acceleration\": format(datum[\"min_Acceleration\"], \"\"), \"Cylinders\": isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"], \"Origin\": isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"]}"
},
"height": {"value": 1},
"xc": {
"scale": "x",
"field": "Cylinders",
"offset": {"scale": "xOffset", "field": "Origin", "band": 0.5}
},
"yc": {"scale": "y", "field": "mid_box_Acceleration"},
"width": {"value": 14},
"height": {"value": 1}
"yc": {"scale": "y", "field": "mid_box_Acceleration"}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_minmax_2D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_minmax_2D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"height": {"value": 1},
"xc": {"scale": "x", "field": "Species", "band": 0.5},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"width": {"value": 14},
"height": {"value": 1}
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_preaggregated.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@
"description": {
"signal": "\"median: \" + (format(datum[\"median\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"])"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "median"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_tooltip_aggregate.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@
"opacity": {"value": 0.7},
"fill": {"value": "white"},
"tooltip": {"signal": "format(datum[\"mean_Body Mass (g)\"], \"\")"},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_tooltip_not_aggregate.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@
"tooltip": {
"signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}"
},
"width": {"value": 1},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"width": {"value": 1}
"height": {"value": 14}
}
}
}
Expand Down
Binary file modified examples/compiled/errorbar_2d_vertical_ticks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.