Skip to content

Commit

Permalink
fix: make tick size responsive to plot height (#9395)
Browse files Browse the repository at this point in the history
## PR Description

Before:

Tick size doesn't respond to plot size change


<img width="249" alt="image"
src="https://github.com/user-attachments/assets/15d14ba2-946e-415b-9cc1-529504e5a796">

after: 

Now it does:

<img width="243" alt="image"
src="https://github.com/user-attachments/assets/405650f1-a98b-4880-b6f7-02e78f0cc729">

---------

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
kanitw and GitHub Actions Bot authored Jul 30, 2024
1 parent da84469 commit 3f5dce6
Show file tree
Hide file tree
Showing 36 changed files with 650 additions and 62 deletions.
13 changes: 13 additions & 0 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22237,6 +22237,19 @@
],
"description": "If true, rounds numeric output values to integers. This can be helpful for snapping to the pixel grid. (Only available for `x`, `y`, and `size` scales.)"
},
"tickBandPaddingInner": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "Default inner padding for `x` and `y` band-ordinal scales of `\"tick\"` marks.\n\n__Default value:__ `0.25`",
"maximum": 1,
"minimum": 0
},
"useUnaggregatedDomain": {
"description": "Use the source data range before aggregation as scale domain instead of aggregated data for aggregate axis.\n\nThis is equivalent to setting `domain` to `\"unaggregate\"` for aggregated _quantitative_ fields by default.\n\nThis property only works with aggregate functions that produce values within the raw data domain (`\"mean\"`, `\"average\"`, `\"median\"`, `\"q1\"`, `\"q3\"`, `\"min\"`, `\"max\"`). For other aggregations that produce values outside of the raw data domain (e.g. `\"count\"`, `\"sum\"`), this property is ignored.\n\n__Default value:__ `false`",
"type": "boolean"
Expand Down
Loading
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/boxplot_preaggregated_with_height.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
228 changes: 228 additions & 0 deletions examples/compiled/boxplot_preaggregated_with_height.vg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"title": {"text": "Body Mass of Penguin Species (g)", "frame": "group"},
"style": "cell",
"data": [
{
"name": "source_0",
"values": [
{
"Species": "Adelie",
"lower": 2850,
"q1": 3350,
"median": 3700,
"q3": 4000,
"upper": 4775,
"outliers": []
},
{
"Species": "Chinstrap",
"lower": 2700,
"q1": 3487.5,
"median": 3700,
"q3": 3950,
"upper": 4800,
"outliers": [2700, 4800]
},
{
"Species": "Gentoo",
"lower": 3950,
"q1": 4700,
"median": 5000,
"q3": 5500,
"upper": 6300,
"outliers": []
}
]
},
{
"name": "data_1",
"source": "source_0",
"transform": [
{
"type": "filter",
"expr": "isValid(datum[\"lower\"]) && isFinite(+datum[\"lower\"])"
}
]
},
{
"name": "data_2",
"source": "source_0",
"transform": [
{
"type": "filter",
"expr": "isValid(datum[\"q1\"]) && isFinite(+datum[\"q1\"])"
}
]
},
{
"name": "data_3",
"source": "source_0",
"transform": [
{
"type": "filter",
"expr": "isValid(datum[\"median\"]) && isFinite(+datum[\"median\"])"
}
]
},
{
"name": "data_4",
"source": "source_0",
"transform": [
{"type": "flatten", "fields": ["outliers"], "as": ["outliers"]},
{
"type": "filter",
"expr": "isValid(datum[\"outliers\"]) && isFinite(+datum[\"outliers\"])"
}
]
}
],
"marks": [
{
"name": "layer_0_marks",
"type": "rule",
"style": ["rule"],
"from": {"data": "data_1"},
"encode": {
"update": {
"stroke": {"value": "black"},
"description": {
"signal": "\"lower: \" + (format(datum[\"lower\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper: \" + (format(datum[\"upper\"], \"\"))"
},
"x": {"scale": "x", "field": "lower"},
"x2": {"scale": "x", "field": "upper"},
"y": {"scale": "y", "field": "Species", "band": 0.5}
}
}
},
{
"name": "layer_1_marks",
"type": "rect",
"style": ["bar"],
"from": {"data": "data_2"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "Species"},
"ariaRoleDescription": {"value": "bar"},
"description": {
"signal": "\"q1: \" + (format(datum[\"q1\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; q3: \" + (format(datum[\"q3\"], \"\"))"
},
"x": {"scale": "x", "field": "q1"},
"x2": {"scale": "x", "field": "q3"},
"y": {"scale": "y", "field": "Species"},
"height": {"signal": "max(0.25, bandwidth('y'))"}
}
}
},
{
"name": "layer_2_marks",
"type": "rect",
"style": ["tick"],
"from": {"data": "data_3"},
"encode": {
"update": {
"opacity": {"value": 0.7},
"fill": {"value": "white"},
"ariaRoleDescription": {"value": "tick"},
"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": {"scale": "y", "band": 1},
"width": {"value": 1}
}
}
},
{
"name": "layer_3_marks",
"type": "symbol",
"style": ["point", "boxplot-outliers"],
"from": {"data": "data_4"},
"encode": {
"update": {
"opacity": {"value": 0.7},
"fill": {"value": "transparent"},
"stroke": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "point"},
"description": {
"signal": "\"outliers: \" + (format(datum[\"outliers\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"])"
},
"x": {"scale": "x", "field": "outliers"},
"y": {"scale": "y", "field": "Species", "band": 0.5}
}
}
}
],
"scales": [
{
"name": "x",
"type": "linear",
"domain": {
"fields": [
{"data": "data_1", "field": "lower"},
{"data": "data_1", "field": "upper"},
{"data": "data_2", "field": "q1"},
{"data": "data_2", "field": "q3"},
{"data": "data_3", "field": "median"},
{"data": "data_4", "field": "outliers"}
]
},
"range": [0, {"signal": "width"}],
"zero": false,
"nice": true
},
{
"name": "y",
"type": "band",
"domain": {
"fields": [
{"data": "data_1", "field": "Species"},
{"data": "data_2", "field": "Species"},
{"data": "data_3", "field": "Species"},
{"data": "data_4", "field": "Species"}
],
"sort": true
},
"range": [0, {"signal": "height"}],
"paddingInner": 0.25,
"paddingOuter": 0.125
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "data_2", "field": "Species", "sort": true},
"range": "category"
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"gridScale": "y",
"grid": true,
"tickCount": {"signal": "ceil(width/40)"},
"domain": false,
"labels": false,
"aria": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "x",
"orient": "bottom",
"grid": false,
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"zindex": 0
},
{"scale": "y", "orient": "left", "grid": false, "zindex": 0}
]
}
Binary file modified examples/compiled/joinaggregate_mean_difference_by_year.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 3f5dce6

Please sign in to comment.