Jump to content
  • 0

Hide Charts when no data is present


TMeyer

Question

I have a chart that displays data based on a submission form to filter my data. When a person selects a combination that returns no data, is there a way to hide the charts and instead display text saying "There are no records for this search criteria" instead of just displaying blank charts? 

Thanks

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @TMeyer,

You can hide the chart when there are no records found, using JavaScript. You need to add a Header& Footer and you can use the following code:

For the Header:

<div class="chart-container">

For the Footer:

</div>

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

    if (document.getElementsByClassName("highcharts-no-data").length > 0) {
        document.getElementsByClassName("chart-container")[0].style.display = "none";
    }

});
</script>

 

-JolliBeng

Link to comment
Share on other sites

  • 0

Hi, 

Just to add to JolliBeng's code, I have a use case where im actually using a Combined Chart and Report DataPage and on the footer,  I used the following script:

 

</div>

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
var selection = document.querySelector(".cbResultSetRecordMessage").innerHTML;
  if (selection == 'No records found.') {

        document.querySelector("div[id*='cbChartContainer']").style.display = "none";

    }

});
</script>

Just change the "No records found" to whatever message you have set when there are no records found.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...