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

feat: support relative point size #9356

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 74 additions & 4 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -3533,6 +3536,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -15213,6 +15219,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -16353,6 +16362,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -17256,6 +17268,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -18767,6 +18782,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -21052,6 +21070,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down Expand Up @@ -21428,6 +21449,26 @@
],
"type": "object"
},
"RelativePointSize": {
"additionalProperties": false,
"properties": {
"relative": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "Relative point/circle/square mark size, as a multiple of the geometric mean of width and height (sqrt(width * height)).\n\nWe use geometric mean because it offers an intuitive sense of the rectangle's size that is less skewed by extreme aspect ratios (i.e., very long and narrow or very short and wide rectangles). It provides a kind of \"central\" value for understanding the scale of the rectangle."
}
},
"required": [
"relative"
],
"type": "object"
},
"RepeatMapping": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -21915,6 +21956,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Sets the maximum value in the scale range, overriding the `range` property or the default range. This property is only intended for use with scales having continuous ranges."
Expand All @@ -21929,6 +21973,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Sets the minimum value in the scale range, overriding the `range` property or the default range. This property is only intended for use with scales having continuous ranges."
Expand Down Expand Up @@ -22133,9 +22180,19 @@
"type": "number"
},
"maxSize": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default max value for point size scale.",
"minimum": 0,
"type": "number"
"minimum": 0
},
"maxStrokeWidth": {
"description": "Default max strokeWidth for the scale of strokeWidth for rule and line marks and of size for trail marks.\n\n__Default value:__ `4`",
Expand All @@ -22159,9 +22216,19 @@
"type": "number"
},
"minSize": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default minimum value for point size scale.\n\n__Default value:__ `9`",
"minimum": 0,
"type": "number"
"minimum": 0
},
"minStrokeWidth": {
"description": "Default minimum strokeWidth for the scale of strokeWidth for rule and line marks and of size for trail marks.\n\n__Default value:__ `1`",
Expand Down Expand Up @@ -28744,6 +28811,9 @@
},
{
"$ref": "#/definitions/ExprRef"
},
{
"$ref": "#/definitions/RelativePointSize"
}
],
"description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.",
Expand Down
Binary file added examples/compiled/point_bubble_relative.png
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/point_bubble_relative.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 134 additions & 0 deletions examples/compiled/point_bubble_relative.vg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A bubbleplot showing horsepower on x, miles per gallons on y, and binned acceleration on size.",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",
"url": "data/cars.json",
"format": {"type": "json"},
"transform": [
{
"type": "filter",
"expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"]) && isValid(datum[\"Acceleration\"]) && isFinite(+datum[\"Acceleration\"])"
}
]
}
],
"marks": [
{
"name": "marks",
"type": "symbol",
"style": ["point"],
"from": {"data": "source_0"},
"encode": {
"update": {
"opacity": {"value": 0.7},
"fill": {"value": "transparent"},
"stroke": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "point"},
"description": {
"signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Miles_per_Gallon: \" + (format(datum[\"Miles_per_Gallon\"], \"\")) + \"; Acceleration: \" + (format(datum[\"Acceleration\"], \"\"))"
},
"x": {"scale": "x", "field": "Horsepower"},
"y": {"scale": "y", "field": "Miles_per_Gallon"},
"size": {"scale": "size", "field": "Acceleration"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "linear",
"domain": {"data": "source_0", "field": "Horsepower"},
"range": [0, {"signal": "width"}],
"nice": true,
"zero": true
},
{
"name": "y",
"type": "linear",
"domain": {"data": "source_0", "field": "Miles_per_Gallon"},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
},
{
"name": "size",
"type": "linear",
"domain": {"data": "source_0", "field": "Acceleration"},
"range": [4, {"signal": "PI * pow(0.2 * sqrt(width * height)/2, 2)"}],
"zero": true
}
],
"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": "y",
"orient": "left",
"gridScale": "x",
"grid": true,
"tickCount": {"signal": "ceil(height/40)"},
"domain": false,
"labels": false,
"aria": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "Horsepower",
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "Miles_per_Gallon",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
}
],
"legends": [
{
"size": "size",
"symbolType": "circle",
"title": "Acceleration",
"encode": {
"symbols": {
"update": {
"fill": {"value": "transparent"},
"stroke": {"value": "#4c78a8"},
"opacity": {"value": 0.7}
}
}
}
}
]
}
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/point_relative_size_discrete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading