SliceLabelFormatter<T>: ((slice: T, relativeValue: number) => string)

Type Parameters

Type declaration

    • (slice: T, relativeValue: number): string
    • Type of function which is used to format text of Slice Labels. It is a function which generates a string based on a Slice along with some additional information.

      See SliceLabelFormatters-collection for quick access to some example implementations.

      Use with setLabelFormatter

      Example usage:

      // Use a default implementation
      SlicedCharts.setLabelFormatter(SliceLabelFormatters.NamePlusRelativeValue)
      // Use a custom implementation
      SlicedCharts.setLabelFormatter((slice, relativeValue) => slice.getValue() + ' €')

      Returns

      String text for Label

      Parameters

      • slice: T

        Slice

      • relativeValue: number

        Value of the Slice as a % of all Slice values

      Returns string