* Generate a label format function for a scale. If the scale has a * 'tickFormat' method, it will be used to generate the formatter, with the * count and specifier arguments passed as parameters. If the scale lacks a * 'tickFormat' method, the returned formatter performs simple string coercion.
(locale, scale11, count, specifier, formatType, noSkip)
| 127189 | * time multi-format specifier object. |
| 127190 | * @return {function(*):string} - The generated label formatter. |
| 127191 | */ function tickFormat(locale, scale11, count, specifier, formatType, noSkip) { |
| 127192 | const type = scale11.type; |
| 127193 | let format1 = defaultFormatter; |
| 127194 | if (type === Time || formatType === Time) format1 = locale.timeFormat(specifier); |
| 127195 | else if (type === UTC || formatType === UTC) format1 = locale.utcFormat(specifier); |
| 127196 | else if (isLogarithmic(type)) { |
| 127197 | const varfmt = locale.formatFloat(specifier); |
| 127198 | if (noSkip || scale11.bins) format1 = varfmt; |
| 127199 | else { |
| 127200 | const test = tickLog(scale11, count, false); |
| 127201 | format1 = (_)=>test(_) ? varfmt(_) : ""; |
| 127202 | } |
| 127203 | } else if (scale11.tickFormat) { |
| 127204 | // if d3 scale has tickFormat, it must be continuous |
| 127205 | const d = scale11.domain(); |
| 127206 | format1 = locale.formatSpan(d[0], d[d.length - 1], count, specifier); |
| 127207 | } else if (specifier) format1 = locale.format(specifier); |
| 127208 | return format1; |
| 127209 | } |
| 127210 | function tickLog(scale12, count, values) { |
| 127211 | const ticks = tickValues(scale12, count), base = scale12.base(), logb = Math.log(base), k = Math.max(1, base * count / ticks.length); // apply d3-scale's log format filter criteria |
| 127212 | const test = (d)=>{ |
no test coverage detected