Custom Sort for FlexChart

Posted by: sskss1ss2 on 31 July 2023, 10:59 pm EST

  • Posted 31 July 2023, 10:59 pm EST

    I’ve a flexchart whose X-Axis can be a alpha numeric value. How do i write a custom sort for this?

    Thanks,

  • Posted 1 August 2023, 5:26 pm EST

    Hello,

    You can sort alphanumeric values using the sortComparer method of collectionView with the third-party library ‘alphanum-compare’s’ compare function. This will sort all the values alphanumerically. Please refer to the sample link below demonstrating the same:

    https://stackblitz.com/edit/angular-f248k7?file=src%2Fapp%2Fapp.component.ts

    Regards

    Sonu Kumar Pandey

  • Posted 1 August 2023, 7:46 pm EST - Updated 1 August 2023, 7:54 pm EST

    Hi,

    Thank you for the revert.

    Is it not possible to trigger the sortComparer method from flexChart’s CollectionView Object?

    Because when i try to do it this way

    this.chart.collectionView[ ‘sortComparer’ ] = (val1, val2) => {}

    it gives me the below error

    TypeError: ‘caller’, ‘callee’, and ‘arguments’ properties may not be accessed on strict mode functions or the arguments objects for calls to them

    at Function.r (:1:83)

  • Posted 1 August 2023, 11:15 pm EST

    Hi,

    The sortComparer is not a function but a property of CollectionView which takes a callback function to define the sorting behavior of data.

    To perform the sorting, or call the sortComparer function you need to add the desired binding into the sortDescriptions array(as done in the above-shared sample link for month binding).

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels