Jump to content
  • 0

Display total records in Pie Chart


randybow

Question

I am sure this is something easy I am missing, but I can't figure it out. I would like to display somewhere in the pie chart the total number of records In all categories. I do see that I can convert the individual slice values to percentages, but I can't figure out how to display a total number represented in the chart. Is this possible?

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

Hello @randybow

It is possible to implement such a workflow using additional JS code.
You need to add Header/Footer to your chart and then insert the following snippets of code:

HEADER

<script type="text/javascript">

var myVar = setInterval(myTimer, 1000);

function myTimer() {
 if(Highcharts) {
  const options = Highcharts.charts[0].series[0].yData;
  const result = options.reduce(function(accumulator, currentValue) {return accumulator + currentValue});
  document.getElementById('total').innerHTML = 'Total: ' + result;
  myStopFunction();
 }
 return null;
}

function myStopFunction() {
  clearInterval(myVar);
}

</script>

FOOTER

<h1 id="total"></h1>

Please note that you need to disable the HTML editor both in the header and footer. You can do this in the advanced section.

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...