-
Notifications
You must be signed in to change notification settings - Fork 607
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
docs(examples): Add example showing how to set the zorder via a conditional order encoding #9136
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1a6fe60
Add example showing how to set the zorder via order sorting
joelostblom 96183d8
chore: update examples [CI]
3164acb
Change "mouseover" to "pointerover"
joelostblom 9ddb952
chore: update examples [CI]
d4a7941
Add schema to spec
joelostblom a3ea7ce
Change condition order
joelostblom 4fe13b5
Add example to index file
joelostblom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega/v5.json", | ||
"background": "white", | ||
"padding": 5, | ||
"width": 200, | ||
"height": 200, | ||
"style": "cell", | ||
"data": [ | ||
{ | ||
"name": "param_122_store", | ||
"transform": [{"type": "collect", "sort": {"field": "_vgsid_"}}] | ||
}, | ||
{ | ||
"name": "source_0", | ||
"url": "https://cdn.jsdelivr.net/npm/[email protected]/data/cars.json", | ||
"format": {"type": "json"}, | ||
"transform": [ | ||
{"type": "identifier", "as": "_vgsid_"}, | ||
{ | ||
"type": "filter", | ||
"expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"])" | ||
} | ||
] | ||
} | ||
], | ||
"signals": [ | ||
{ | ||
"name": "unit", | ||
"value": {}, | ||
"on": [ | ||
{"events": "pointermove", "update": "isTuple(group()) ? group() : unit"} | ||
] | ||
}, | ||
{ | ||
"name": "param_122", | ||
"update": "vlSelectionResolve(\"param_122_store\", \"union\", true, true)" | ||
}, | ||
{ | ||
"name": "param_122_tuple", | ||
"on": [ | ||
{ | ||
"events": [{"source": "scope", "type": "pointerover"}], | ||
"update": "datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0 ? {unit: \"\", _vgsid_: (item().isVoronoi ? datum.datum : datum)[\"_vgsid_\"]} : null", | ||
"force": true | ||
}, | ||
{"events": [{"source": "view", "type": "dblclick"}], "update": "null"} | ||
] | ||
}, | ||
{ | ||
"name": "param_122_toggle", | ||
"value": false, | ||
"on": [ | ||
{ | ||
"events": [{"source": "scope", "type": "pointerover"}], | ||
"update": "event.shiftKey" | ||
}, | ||
{"events": [{"source": "view", "type": "dblclick"}], "update": "false"} | ||
] | ||
}, | ||
{ | ||
"name": "param_122_modify", | ||
"on": [ | ||
{ | ||
"events": {"signal": "param_122_tuple"}, | ||
"update": "modify(\"param_122_store\", param_122_toggle ? null : param_122_tuple, param_122_toggle ? null : true, param_122_toggle ? param_122_tuple : null)" | ||
} | ||
] | ||
} | ||
], | ||
"marks": [ | ||
{ | ||
"name": "marks", | ||
"type": "symbol", | ||
"style": ["circle"], | ||
"interactive": true, | ||
"from": {"data": "source_0"}, | ||
"encode": { | ||
"update": { | ||
"opacity": {"value": 1}, | ||
"fill": [ | ||
{ | ||
"test": "length(data(\"param_122_store\")) && vlSelectionIdTest(\"param_122_store\", datum)", | ||
"value": "coral" | ||
}, | ||
{"value": "grey"} | ||
], | ||
"zindex": [ | ||
{ | ||
"test": "length(data(\"param_122_store\")) && vlSelectionIdTest(\"param_122_store\", datum)", | ||
"value": 1 | ||
}, | ||
{"value": 0} | ||
], | ||
"ariaRoleDescription": {"value": "circle"}, | ||
"description": { | ||
"signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Miles_per_Gallon: \" + (format(datum[\"Miles_per_Gallon\"], \"\"))" | ||
}, | ||
"x": {"scale": "x", "field": "Horsepower"}, | ||
"y": {"scale": "y", "field": "Miles_per_Gallon"}, | ||
"size": [ | ||
{ | ||
"test": "length(data(\"param_122_store\")) && vlSelectionIdTest(\"param_122_store\", datum)", | ||
"value": 400 | ||
}, | ||
{"value": 100} | ||
], | ||
"shape": {"value": "circle"} | ||
} | ||
} | ||
} | ||
], | ||
"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 | ||
} | ||
], | ||
"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 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | ||
"data": { | ||
"url": "https://cdn.jsdelivr.net/npm/[email protected]/data/cars.json" | ||
}, | ||
"mark": {"type": "circle", "opacity": 1}, | ||
"encoding": { | ||
"color": { | ||
"condition": {"param": "param_122", "value": "coral", "empty": false}, | ||
"value": "grey" | ||
}, | ||
"order": { | ||
"value": 0, | ||
"condition": {"param": "param_122", "value": 1, "empty": false} | ||
}, | ||
"size": { | ||
"condition": {"param": "param_122", "value": 400, "empty": false}, | ||
"value": 100 | ||
}, | ||
"x": {"field": "Horsepower", "type": "quantitative"}, | ||
"y": {"field": "Miles_per_Gallon", "type": "quantitative"} | ||
}, | ||
"params": [ | ||
{"name": "param_122", "select": {"type": "point", "on": "pointerover"}} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,7 +413,7 @@ The key channel can enable object constancy for transitions over dynamic data. W | |
|
||
## Order Channel | ||
|
||
`order` channel can define a data field (or a ordered list of data fields) that are used to sorts stacking order for stacked charts (see [an example in the `stack` page](stack.html#order)) and the order of data points in line marks for connected scatterplots (see [an example in the `line` page](line.html#connected-scatter-plot)). | ||
`order` channel can define a data field (or a ordered list of data fields) that are used to sorts stacking order for stacked charts (see [an example in the `stack` page](stack.html#order)), the order of data points in line marks for connected scatterplots (see [an example in the `line` page](line.html#connected-scatter-plot)), and which data points are plotted on top in a chart (the "zorder", see [an example in the gallery]({{ site.baseurl }}/examples/selection_type_point_zorder.html)). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (the "zorder", see [an example in the gallery]({{ site.baseurl }}/examples/selection_type_point_zorder.html)) --> I think this URL probably doesn't work unless you add it to I think you can add this example to the end of the following block in
|
||
|
||
{% include table.html props="order" source="Encoding" %} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consisistency with size and to make it reads like if-then-else, better put
condition
abovevalue
.