How to programatically show/hide chart data #4987
-
I can show/hide fields by clicking the relevent items in the legend to get this: Is there a way I can do that programatically via the API rather than getting the user to click? I have tried to look through the documentation but I can't find a way to do it Checklist
Description of change |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
What version of G2 are you using? V4 or V5? |
Beta Was this translation helpful? Give feedback.
-
Hi @pearmini thanks for the reply. I am using I can see in the legend section of the docs there is a
|
Beta Was this translation helpful? Give feedback.
-
If you are using G2Plot, you can see this example for more details. |
Beta Was this translation helpful? Give feedback.
-
I didn't really have any luck with This does work but not an ideal solution |
Beta Was this translation helpful? Give feedback.
-
In G2Plot v2 or G2 v4, you can configure the legend.selected to update the default selection. Document here, search 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: { /* ... */ } });
`` |
Beta Was this translation helpful? Give feedback.
In G2Plot v2 or G2 v4, you can configure the legend.selected to update the default selection. Document here, search
selected
.In G2 v5, you can use API: