Skip to content

Commit

Permalink
fix(#7724,#9414): Make ticks respect bin/timeUnit bands and custom ba…
Browse files Browse the repository at this point in the history
…nd (#9415)

## PR Description

Make ticks respect bin/timeUnit bands and custom band (by calling
`rectPosition()`, just like rect and bar marks)

See the examples added as a proof for fixing.

---------

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
kanitw and GitHub Actions Bot authored Aug 28, 2024
1 parent c0c7b6b commit 088094e
Show file tree
Hide file tree
Showing 61 changed files with 591 additions and 144 deletions.
33 changes: 33 additions & 0 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28308,6 +28308,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 @@ -28333,6 +28338,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 @@ -28421,6 +28431,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 @@ -28633,6 +28655,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
2 changes: 1 addition & 1 deletion examples/compiled/bar_bullet_expr_bind.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@
"description": {
"signal": "\"markers[0]: \" + (format(datum[\"markers.0\"], \"\"))"
},
"xc": {"scale": "x", "field": "markers\\.0"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"signal": "height"},
"xc": {"scale": "x", "field": "markers\\.0"},
"width": {"value": 2}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/bar_tooltip_aggregate.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"signal": "\"Mean of data: \" + (format(datum[\"mean_data\"], \"\"))"
},
"xc": {"signal": "width", "mult": 0.5},
"width": {"signal": "0.75 * width"},
"yc": {"scale": "y", "field": "mean_data"},
"width": {"signal": "(1 - 0.25) * width"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/bar_tooltip_groupby.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"signal": "\"Mean of data: \" + (format(datum[\"mean_data\"], \"\")) + \"; data: \" + (isValid(datum[\"data\"]) ? datum[\"data\"] : \"\"+datum[\"data\"])"
},
"xc": {"signal": "width", "mult": 0.5},
"width": {"signal": "0.75 * width"},
"yc": {"scale": "y", "field": "mean_data"},
"width": {"signal": "(1 - 0.25) * width"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_1D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@
"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)\"], \"\")}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@
"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)\"], \"\")}"
},
"xc": {"scale": "x", "field": "lower_whisker_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"signal": "(1 - 0.25) * height"},
"height": {"signal": "0.75 * height"},
"xc": {"scale": "x", "field": "lower_whisker_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand All @@ -231,9 +231,9 @@
"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)\"], \"\")}"
},
"xc": {"scale": "x", "field": "upper_whisker_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"signal": "(1 - 0.25) * height"},
"height": {"signal": "0.75 * height"},
"xc": {"scale": "x", "field": "upper_whisker_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down Expand Up @@ -279,9 +279,9 @@
"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)\"], \"\")}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_1D_horizontal_explicit.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@
"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)\"], \"\")}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"signal": "height", "mult": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_1D_invalid.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@
"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\"], \"\")}"
},
"xc": {"scale": "x", "field": "a"},
"yc": {"scale": "y", "field": "mid_box_b"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_b"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_1D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
"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)\"], \"\")}"
},
"xc": {"signal": "width", "mult": 0.5},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_2D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_2D_horizontal_color_size.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 10},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_2D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "Species", "band": 0.5},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"height": {"value": 1}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@
"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\": isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]}"
},
"xc": {"scale": "x", "field": "a", "band": 0.5},
"yc": {"scale": "y", "field": "mid_box_b"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_b"},
"height": {"value": 1}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@
"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\": isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]}"
},
"xc": {"scale": "x", "field": "a", "band": 0.5},
"yc": {"scale": "y", "field": "mid_box_b"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_b"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_groupped.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@
"field": "Cylinders",
"offset": {"scale": "xOffset", "field": "Origin", "band": 0.5}
},
"yc": {"scale": "y", "field": "mid_box_Acceleration"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_Acceleration"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_minmax_2D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_minmax_2D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "Species", "band": 0.5},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"width": {"value": 14},
"yc": {"scale": "y", "field": "mid_box_Body Mass (g)"},
"height": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_preaggregated.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
"description": {
"signal": "\"median: \" + (format(datum[\"median\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"])"
},
"xc": {"scale": "x", "field": "median"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "median"},
"width": {"value": 1}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/boxplot_preaggregated_with_height.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@
"description": {
"signal": "\"median: \" + (format(datum[\"median\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"])"
},
"y": {"scale": "y", "field": "Species"},
"height": {"signal": "max(0.25, bandwidth('y'))"},
"xc": {"scale": "x", "field": "median"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"scale": "y", "band": 1},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_tooltip_aggregate.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@
{"value": "white"}
],
"tooltip": {"signal": "format(datum[\"mean_Body Mass (g)\"], \"\")"},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/boxplot_tooltip_not_aggregate.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@
"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\"]}"
},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"yc": {"scale": "y", "field": "Species", "band": 0.5},
"height": {"value": 14},
"xc": {"scale": "x", "field": "mid_box_Body Mass (g)"},
"width": {"value": 1}
}
}
Expand Down
Binary file modified examples/compiled/errorbar_2d_vertical_ticks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 088094e

Please sign in to comment.