In this article, we will guide you on how to add a custom button to dynamically sort values in column chart DataPage. This can also be applied to other chart DataPages.

Steps to add custom sorting button:

  1. Edit your column chart DataPage.
  2. Add a Header and Footer in the Configure Chart Options screen of the DataPage wizard.
  3. Disable the HTML Editor in the Header section.
  4. Copy and paste the following code in the Header section:
    <button id="button" class="cbSubmitButton" type="button">Reverse Sort Order</button>
  5. Disable the HTML Editor in the Footer section.
  6. Copy and paste the following code in the Footer section:
    <script type="text/javascript">
    function toggle() {
    var x = document.getElementById("button");
    if (x.innerHTML === "Reverse Sort Order") {
    x.innerHTML = "Back to Default Sort Order"
    } else {
    x.innerHTML = "Reverse Sort Order";
    function setChart(result){
    Highcharts.charts[0].update({ xAxis:{ reversed: result }});
  7. Save the DataPage.

Note: This article uses external HTML, JavaScript, or third-party solutions to add functionality outside of Caspio standard feature set. These solutions are provided “as is” without warranty, support or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.