Skip to product menu

Zoho Analytics has been recognized in the 2024 Gartner® Magic Quadrant™ for ABI PlatformsRead more

Skip to main content

Sorting View

You can use this API to sort the chart metrics by Axis, and by Legend. You can sort the chart in ascending or descending order. 

Function Call

Objname.sortView("AxisType", "SortType", "SortIndex (optional)")

Parameters 

Parameter NameDescription
AxisType

String

Enter the axis type over which the sort action needs to be performed.

  • XAXIS
  • YAXIS
  • LEGEND
SortType

String

Enter the type of sort action that needs to be performed.

  • asc - to sort the view in ascending order.
  • desc - to sort the view in descending order.
SortIndex (optional)

Number

Applicable only if the view has multiple Y-axis
The number represents the Y-axis over which the sort action needs to be performed.

Sample Response

ZAnalytics JS API
 

Sample Request:

Copied<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>ZAnalytics JS API</title>
    <link rel="icon" type="image/x-icon" href="https://analytics.zoho.com/favicon.ico">
<script src="https://downloads.zohocdn.com/zanalyticslib/jsapi/v1/zanalytics.min.js"></script>
</head>
<style>
    button {
        background: #fff;
        border-radius: 3px;
        border: 1px solid #b8b8b8;
        height: 30px;
        margin: 5px;
        cursor: pointer;
    }
</style>
<body>
    <div class="viewcontainer">
        <div class="row" style="float: right;">
             <button onclick="vizObj.sortView('XAXIS','asc')">X-Axis - Ascending</button> 
<button onclick="vizObj.sortView('XAXIS','desc')">X-Axis - Descending</button> 
<button onclick="vizObj.sortView('YAXIS','asc')">Y-Axis - Ascending</button> 
<button onclick="vizObj.sortView('YAXIS','desc')">Y-Axis - Descending</button>
        </div>
        <div id="analysisView"></div>
        <script>
            const containerDiv = document.getElementById("analysisView");
            const url = "https://analytics.zoho.com/open-view/2588560000000010083";
            const options = {
                width: '100%',
                height: 600
            };
            const vizObj = new ZAnalyticsLib(containerDiv, url, options);
            vizObj.createViz();
        </script>
    </div>
</body>
</html>
Thanks for your interest. We shall get back to you shortly.