UNPKG

@thewtex/vtk.js-esm

Version:

Visualization Toolkit for the Web

36 lines (33 loc) 1.46 kB
import { f as formatSpecifier } from '../../d3-format/src/formatSpecifier.js'; import { p as precisionFixed } from '../../d3-format/src/precisionFixed.js'; import { p as precisionRound } from '../../d3-format/src/precisionRound.js'; import { p as precisionPrefix } from '../../d3-format/src/precisionPrefix.js'; import { f as formatPrefix, a as format } from '../../d3-format/src/defaultLocale.js'; import { b as tickStep } from '../../d3-array/src/ticks.js'; function tickFormat(start, stop, count, specifier) { var step = tickStep(start, stop, count), precision; specifier = formatSpecifier(specifier == null ? ",f" : specifier); switch (specifier.type) { case "s": { var value = Math.max(Math.abs(start), Math.abs(stop)); if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision; return formatPrefix(specifier, value); } case "": case "e": case "g": case "p": case "r": { if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); break; } case "f": case "%": { if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2; break; } } return format(specifier); } export { tickFormat as t };