mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-02-01 17:47:09 +00:00
Expose formatNumber as a helper (#8683)
This commit is contained in:
parent
81342d6c65
commit
375d856a87
@ -1,6 +1,6 @@
|
||||
import DatasetController from '../core/core.datasetController';
|
||||
import {formatNumber} from '../core/core.intl';
|
||||
import {isArray, toPercentage, toDimension, valueOrDefault} from '../helpers/helpers.core';
|
||||
import {formatNumber} from '../helpers/helpers.intl';
|
||||
import {toRadians, PI, TAU, HALF_PI, _angleBetween} from '../helpers/helpers.math';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {isArray} from '../helpers/helpers.core';
|
||||
import {formatNumber} from '../helpers/helpers.intl';
|
||||
import {log10} from '../helpers/helpers.math';
|
||||
import {formatNumber} from './core.intl';
|
||||
|
||||
/**
|
||||
* Namespace to hold formatters for different types of ticks
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
const intlCache = new Map();
|
||||
|
||||
export function getNumberFormat(locale, options) {
|
||||
function getNumberFormat(locale, options) {
|
||||
options = options || {};
|
||||
const cacheKey = locale + JSON.stringify(options);
|
||||
let formatter = intlCache.get(cacheKey);
|
||||
@ -6,6 +6,7 @@ export * from './helpers.curve';
|
||||
export * from './helpers.dom';
|
||||
export {default as easingEffects} from './helpers.easing';
|
||||
export * from './helpers.interpolation';
|
||||
export * from './helpers.intl';
|
||||
export * from './helpers.options';
|
||||
export * from './helpers.math';
|
||||
export * from './helpers.rtl';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {isNullOrUndef} from '../helpers/helpers.core';
|
||||
import {almostEquals, almostWhole, niceNum, _decimalPlaces, _setMinAndMaxByKey, sign} from '../helpers/helpers.math';
|
||||
import Scale from '../core/core.scale';
|
||||
import {formatNumber} from '../core/core.intl';
|
||||
import {formatNumber} from '../helpers/helpers.intl';
|
||||
import {_addGrace} from '../helpers/helpers.options';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {finiteOrDefault, isFinite} from '../helpers/helpers.core';
|
||||
import {formatNumber} from '../helpers/helpers.intl';
|
||||
import {_setMinAndMaxByKey, log10} from '../helpers/helpers.math';
|
||||
import Scale from '../core/core.scale';
|
||||
import LinearScaleBase from './scale.linearbase';
|
||||
import Ticks from '../core/core.ticks';
|
||||
import {formatNumber} from '../core/core.intl';
|
||||
|
||||
function isMajor(tickVal) {
|
||||
const remain = tickVal / (Math.pow(10, Math.floor(log10(tickVal))));
|
||||
|
||||
7
types/helpers/helpers.intl.d.ts
vendored
Normal file
7
types/helpers/helpers.intl.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Format a number using a localized number formatter.
|
||||
* @param num The number to format
|
||||
* @param locale The locale to pass to the Intl.NumberFormat constructor
|
||||
* @param options Number format options
|
||||
*/
|
||||
export function formatNumber(num: number, locale: string, options: Intl.NumberFormatOptions): string;
|
||||
1
types/helpers/index.d.ts
vendored
1
types/helpers/index.d.ts
vendored
@ -7,6 +7,7 @@ export * from './helpers.dom';
|
||||
export * from './helpers.easing';
|
||||
export * from './helpers.extras';
|
||||
export * from './helpers.interpolation';
|
||||
export * from './helpers.intl';
|
||||
export * from './helpers.math';
|
||||
export * from './helpers.options';
|
||||
export * from './helpers.canvas';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user