SliceSorter<T>: ((sliceA: T, sliceB: T) => number)

Type Parameters

Type declaration

    • (sliceA: T, sliceB: T): number
    • Type of function which is used to sort Slices of a Chart with Slices. It is a comparator function used with JavaScript API: Array.sort.

      See SliceSorters collection for quick access to some example implementations.

      Use with setSliceSorter

      Example usage:

      // Use a default implementation
      SlicedCharts.setSliceSorter(SliceSorters.SortByValueDescending)
      // Use a custom implementation
      SlicedCharts.setSliceSorter((a, b) => a.getValue() - b.getValue())

      Returns

      Number which implies the sorted order between Slices A and B. For more details, refer to Array documentation.

      Parameters

      • sliceA: T

        Slice A

      • sliceB: T

        Slice B

      Returns number