Forum Discussion

zohebakber's avatar
zohebakber
Cloud Apps
01-09-2023
Solved

manual sorting categories in Scatter Chart

Hi Team, I want to manually sort the categories for the x axis in scatter chart. Please help. Thanks
  • zohebakber's avatar
    zohebakber
    01-09-2023

    Hi Sijo,

    Thanks for the reply..
    I tried the below script and it worked..

     

    var categories= ['10+% lower','5-10% lower','2-5% lower','0-2% lower','0%','0-2% Higher','2-5% Higher','5-10% Higher','10+% Higher'];

    widget.on('queryend',function(se,ev){
    ev.rawResult.values.sort(function(a, b){
    var aIndex = categories.indexOf(a[0].data.trim());
    var bIndex = categories.indexOf(b[0].data.trim());

    if (aIndex < bIndex)
    return -1;
    if (aIndex > bIndex)
    return 1;

    return 0;
    })
    })