Interface to format all values before they are drawn as labels.

Extend ValueFormatter instead

interface IValueFormatter {
    getFormattedValue(
        value: number,
        entry: Entry,
        index: any,
        count: any,
        dataSetIndex: any,
        viewPortHandler: any,
    ): string;
}

Implemented by

Methods

  • Called when a value (from labels inside the chart) is formatted before being drawn. For performance reasons, avoid excessive calculations and memory allocations inside this method.

    Parameters

    • value: number

      the value to be formatted

    • entry: Entry

      the entry the value belongs to - in e.g. BarChart, this is of class BarEntry

    • index: any

      index of the drawn value

    • count: any

      total number of values drawn (useful to draw first or last)

    • dataSetIndex: any

      the index of the DataSet the entry in focus belongs to

    • viewPortHandler: any

      provides information about the current chart state (scale, translation, ...)

    Returns string

    the formatted label ready for being drawn

    Extend ValueFormatter and override an appropriate method