Skip to content

XYChart Legend #1143

Answered by williaster
JamesIrish asked this question in Q&A
Apr 7, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hey @JamesIrish 👋 thanks for checking out visx. Here's a demo incorporating a legend into XYChart. The key is the DataContext which is described under AdvancedUsage in the @visx/xychart docs.

Legends were initially on the MVP features for @visx/xychart but didn't make the cut. Thankfully it's pretty straight forward to integrate. I left additional comments in the sandbox. Note this is an HTML legend (which is what @visx/legend is based on), so you can't render it as a child of XYChart since the chart is SVG based. Hope that helps!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JamesIrish
Comment options

Answer selected by JamesIrish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants