MCPcopy
hub / github.com/apache/echarts / round

Function round

src/util/number.ts:222–237  ·  view source on GitHub ↗
(x: number | string, precision: number, returnStr?: boolean)

Source from the content-addressed store, hash-verified

220export function round(x: number | string, precision: number, returnStr: false): number;
221export function round(x: number | string, precision: number, returnStr: true): string;
222export function round(x: number | string, precision: number, returnStr?: boolean): string | number {
223 if (__DEV__) {
224 // NOTICE: We should not provided a default precision, since there is no universally adaptable
225 // precision. The caller need to input a precision according to the scenarios.
226 zrUtil.assert(precision != null);
227 }
228 if (isNaN(precision)) {
229 // precision utils (such as getAcceptableTickPrecision) may return NaN.
230 return returnStr ? '' + x : +x;
231 }
232 // Avoid range error
233 precision = mathMin(mathMax(0, precision), TO_FIXED_SUPPORTED_PRECISION_MAX);
234 // PENDING: 1.005.toFixed(2) is '1.00' rather than '1.01'
235 x = (+x).toFixed(precision);
236 return (returnStr ? x : +x);
237}
238
239export function roundLegacy(x: number | string, precision?: number): number;
240export function roundLegacy(x: number | string, precision: number, returnStr: false): number;

Callers 15

createPolarClipPathFunction · 0.90
_updateCommonStlMethod · 0.90
_renderTicksMethod · 0.90
getMinorTicksFunction · 0.90
intervalScaleNiceTicksFunction · 0.90
increaseIntervalFunction · 0.90
setConfigMethod · 0.90
getTicksMethod · 0.90
getLabelMethod · 0.90
setBatchMethod · 0.90
formatLabelFunction · 0.90
calculateDataWindowMethod · 0.90

Calls 1

toFixedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…