amigopeta
Posts: 6
Joined: Tue Nov 28, 2023 6:08 am

Hide a chart in a dashboard

Hello, I'm currently learning programming and I wonder if it's possible to hide a chart in the dashboard based on whether a variable is set to true, everytime I tried to hide it, it left a blank space which is unwanted behaviour. :)

The chart I'm trying to hide is cell: 'dashboard-col-2' in the demo

I'm glad for any possible improvements, also, is there any OOP solution in the official documentation? I'm kind of stuck in that part
Here's a demo: https://jsfiddle.net/tzy5wpv2/
jedrzej.r
Posts: 725
Joined: Tue Jan 24, 2023 11:21 am

Re: Hide a chart in a dashboard

Hi!

Thanks for reaching out to us with your inqury!

The simplest way would be to check the variable and depending on it's state update cell visibility with CSS selectors.

Demo: https://jsfiddle.net/BlackLabel/tkdLvr7m/

Other way around can be achieved by referencing Board.layouts, where you can access certain cell and call the hide() and show() methods.

Demo: https://jsfiddle.net/BlackLabel/u930f7vk/

API:
https://api.highcharts.com/dashboards/# ... -1#layouts
https://github.com/highcharts/highchart ... #L247-L254

Let me know if that was helpful for you.
Best regards!
Jędrzej Ruta
Highcharts Developer

Return to “Highcharts Dashboards”