UNPKG

@nteract/data-explorer

Version:
26 lines (25 loc) 879 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createLabelItems = exports.numeralFormatting = void 0; const numeral_1 = __importDefault(require("numeral")); function numeralFormatting(tickValue) { let format = "0.[00]a"; if (tickValue === 0) { return "0"; } else if (tickValue > 100000000000000 || tickValue < 0.00001) { format = "0.[000]e+0"; } else if (tickValue < 1) { format = "0.[0000]a"; } return numeral_1.default(tickValue).format(format); } exports.numeralFormatting = numeralFormatting; function createLabelItems(uniqueValues) { return uniqueValues.map((value) => ({ label: value })); } exports.createLabelItems = createLabelItems;