Skip to content

How to programatically show/hide chart data #4987

Answered by hustcc
matteematt asked this question in Q&A
Discussion options

You must be logged in to vote

In G2Plot v2 or G2 v4, you can configure the legend.selected to update the default selection. Document here, search selected.

legend: {
  selected: {
   'Eaxm 3': false, // 👈🏻 do not show as default.
  },
},

In G2 v5, you can use API:

chart.emit('legend:selected', { data: { /* ... */ } });
chart.emit('legend:unselected', { data: { /* ... */ } });
``

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

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

This discussion was converted from issue #4621 on May 10, 2023 05:31.