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

docs(examples): Add example showing how to set the zorder via a conditional order encoding #9136

Merged
merged 7 commits into from
Oct 28, 2023

Conversation

joelostblom
Copy link
Contributor

This adds an example of how to make a point appear on top when it is hovered over, instead of it being covered by other points based on the initial plotting order. This was discussed in #4864 and #1684, but I couldn't find an example that demonstrates this behavior. I would presume that setting the zorder like this is more performant than having a second layer that responds to a filter transform linked to to the selection, which is what I have used myself in the past.

image
Open the Chart in the Vega Editor

@joelostblom joelostblom changed the title Add example showing how to set the zorder via a conditional order encoding docs: Add example showing how to set the zorder via a conditional order encoding Oct 12, 2023
},
"order": {
"value": 0,
"condition": {"param": "param_122", "value": 1, "empty": false}
Copy link
Member

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 above value.

@@ -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)).
Copy link
Member

Choose a reason for hiding this comment

The 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 examples.json.

I think you can add this example to the end of the following block in examples.json. :)

"Interactive": {
    "Interactive Charts": [

@kanitw
Copy link
Member

kanitw commented Oct 12, 2023

Thanks for adding the example! :)

@joelostblom
Copy link
Contributor Author

Thanks for the quick review @kanitw ! I believe I have addressed your comment in my last couple of commits, so please have another look.

@kanitw kanitw changed the title docs: Add example showing how to set the zorder via a conditional order encoding docs(examples): Add example showing how to set the zorder via a conditional order encoding Oct 28, 2023
@kanitw kanitw merged commit 1263d66 into main Oct 28, 2023
12 checks passed
@kanitw kanitw deleted the hover-zorder branch October 28, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants