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

conditional formatting mark_text based on variable? #1976

Closed
parodayco opened this issue Feb 17, 2020 · 5 comments · Fixed by #3226
Closed

conditional formatting mark_text based on variable? #1976

parodayco opened this issue Feb 17, 2020 · 5 comments · Fixed by #3226
Labels
enhancement vega: vega-lite Requires upstream action in `vega-lite`

Comments

@parodayco
Copy link

parodayco commented Feb 17, 2020

I've read the docs on conditions based on interactions but I didn't find a way to format chart text based on conditions. Here's a particularly egregious example where I would like mark_text(align="left", dx=20) for seller_status up to 50%, over 50% mark_text(align="right", dx=-20). I'd appreciate any ideas you have.

visualization(1)

@parodayco parodayco changed the title conditional formatting based on variable? conditional formatting mark_text based on variable? Feb 17, 2020
@jakevdp
Copy link
Collaborator

jakevdp commented Feb 17, 2020

No, unfortunately the only thing that can depend on conditions are encodings, not mark properties. I know the Vega-Lite team has been thinking about ways to relax this restriction, so you might inquire there.

@parodayco
Copy link
Author

Ok, thanks Jake. I'll bring it up with them. They have an example of conditionally altering text in the first example on https://vega.github.io/vega-lite/docs/text.html and am hoping that's the path to my solution. Have a look and please let me know if that can currently be reproduced with Altair. If not, perhaps I can fork and try to help add the capability.

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 18, 2020

Yes, you can conditionally encode the color, because the color is an encoding channel. You cannot conditionally encode offset, because offset is not (yet) an encoding channel.

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 18, 2020

The relevant issue to add your +1 is here: vega/vega-lite#4703

@parodayco
Copy link
Author

Thanks again, Jake! I saw your recommendation and cross-post to the vega issue board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement vega: vega-lite Requires upstream action in `vega-lite`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants