#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# NumericImpl Class

Defined in: `charts/js/NumericImpl.js:8`
Module: axis-numeric-base
Parent Module: charts

NumericImpl contains logic for numeric data. NumericImpl is used by the following classes:

- NumericAxisBase
- NumericAxis

## Constructor

### `NumericImpl`

()

Defined in `charts/js/NumericImpl.js:8`

- Index
- Methods
- Properties
- Attributes

## Item Index

### Methods

- _getMinimumUnit
- _getNiceNumber
- _roundDownToNearest
- _roundMinAndMax
- _roundToNearest
- _roundToPrecision
- _roundUpToNearest
- _updateMinAndMax
- getTotalByKey
- initializer

### Properties

- _type

### Attributes

- alwaysShowZero
- labelFormat
- labelFunction
- roundingMethod

## Methods

### `_getMinimumUnit`

(

- `max`
- `min`
- `units`

)
private

Defined in `charts/js/NumericImpl.js:147`

Helper method for getting a `roundingUnit` when calculating the minimum and maximum values.

#### Parameters:

- `max` Number

  Maximum number

- `min` Number

  Minimum number

- `units` Number

  Number of units on the axis

#### Returns:

Number

### `_getNiceNumber`

(

- `roundingUnit`

)
private

Defined in `charts/js/NumericImpl.js:162`

Calculates a nice rounding unit based on the range.

#### Parameters:

- `roundingUnit` Number

  The calculated rounding unit.

#### Returns:

Number

### `_roundDownToNearest`

(

- `number`
- `nearest`

)
private

Defined in `charts/js/NumericImpl.js:592`

Rounds a Number down to the nearest multiple of an input. For example, by rounding 16 down to the nearest 10, you will receive 10. Similar to the built-in function Math.floor().

#### Parameters:

- `number` Number

  Number to round

- `nearest` Number

  Multiple to round towards.

#### Returns:

Number

### `_roundMinAndMax`

(

- `min`
- `max`

)
private

Defined in `charts/js/NumericImpl.js:258`

Rounds the mimimum and maximum values based on the `roundingUnit` attribute.

#### Parameters:

- `min` Number

  Minimum value

- `max` Number

  Maximum value

### `_roundToNearest`

(

- `number`
- `nearest`

)
private

Defined in `charts/js/NumericImpl.js:559`

Rounds a Number to the nearest multiple of an input. For example, by rounding 16 to the nearest 10, you will receive 20. Similar to the built-in function Math.round().

#### Parameters:

- `number` Number

  Number to round

- `nearest` Number

  Multiple to round towards.

#### Returns:

Number

### `_roundToPrecision`

(

- `number`
- `precision`

)
private

Defined in `charts/js/NumericImpl.js:608`

Rounds a number to a certain level of precision. Useful for limiting the number of decimal places on a fractional number.

#### Parameters:

- `number` Number

  Number to round

- `precision` Number

  Multiple to round towards.

#### Returns:

Number

### `_roundUpToNearest`

(

- `number`
- `nearest`

)
private

Defined in `charts/js/NumericImpl.js:576`

Rounds a Number up to the nearest multiple of an input. For example, by rounding 16 up to the nearest 10, you will receive 20. Similar to the built-in function Math.ceil().

#### Parameters:

- `number` Number

  Number to round

- `nearest` Number

  Multiple to round towards.

#### Returns:

Number

### ``

(

- `value`
- `format`

)

Defined in `charts/js/NumericImpl.js:96`

Formats a label based on the axis type and optionally specified format.

#### Parameters:

- `value` Object
- `format` Object

  Pattern used to format the value.

#### Returns:

String

### `_updateMinAndMax`

() private

Defined in `charts/js/NumericImpl.js:194`

Calculates the maximum and minimum values for the `Data`.

### `getTotalByKey`

(

- `key`

)

Defined in `charts/js/NumericImpl.js:113`

Returns the sum of all values per key.

#### Parameters:

- `key` String

  The identifier for the array whose values will be calculated.

#### Returns:

Number

### `initializer`

() private

Defined in `charts/js/NumericImpl.js:87`

## Properties

### `_type`

Unknown private

Defined in `charts/js/NumericImpl.js:138`

Type of data used in `Data`.

## Attributes

### `alwaysShowZero`

Boolean

Defined in `charts/js/NumericImpl.js:26`

Indicates whether 0 should always be displayed.

#### Fires event `alwaysShowZeroChange`

Fires when the value for the configuration attribute `alwaysShowZero` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `labelFormat`

Object

Defined in `charts/js/NumericImpl.js:51`

Object containing properties used by the `labelFunction` to format a label.

#### Fires event `labelFormatChange`

Fires when the value for the configuration attribute `labelFormat` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `labelFunction`

Function

Defined in `charts/js/NumericImpl.js:36`

Method used for formatting a label. This attribute allows for the default label formatting method to overridden. The method use would need to implement the arguments below and return a `String` or an `HTMLElement`. The default implementation of the method returns a `String`. The output of this method will be rendered to the DOM using `appendChild`. If you override the `labelFunction` method and return an html string, you will also need to override the Data' `appendLabelFunction` to accept html as a `String`.

val
  Label to be formatted. (`String`)
format
  Object containing properties used to format the label. (optional)

#### Fires event `labelFunctionChange`

Fires when the value for the configuration attribute `labelFunction` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `roundingMethod`

String

Defined in `charts/js/NumericImpl.js:68`

Indicates how to round unit values.

niceNumber
  Units will be smoothed based on the number of ticks and data range.
auto
  If the range is greater than 1, the units will be rounded.
numeric value
  Units will be equal to the numeric value.
null
  No rounding will occur.

Default: niceNumber

#### Fires event `roundingMethodChange`

Fires when the value for the configuration attribute `roundingMethod` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.