Disabling a chart / table along with all of the related queries

How can I disable a chart or a table along with all of the queries that are related to it?
I want to add a button to disable/enable the table/chart. I tried to control all of the queries that supply the chart with data but the chart itself keeps generating errors because there's no data.. like this one:

Hi @msaleh Thanks for reaching out!

Can you use Javascript to make the data in the chart conditional based on whether the query has been triggered?

In the below example, I have a manually triggered query populating the chart. The query is triggered only by button click.

Then, in the chart data source, I have a conditional that checks to see if I have data for the chart query. If I do, I'll populate the chart with data. If I don't, I'll populate the chart with an empty dataset.

This is what it looks like after triggering the query:

It doesn't look like we have a specific "disabled" property for the chart, but you could optionally make the chart hidden whenever there is no data