Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getWidthBasedResolutionText(
zoomLevel, maxWidth, binsPerDimension, maxZoom
) {
const resolution = maxWidth / ((2 ** zoomLevel) * binsPerDimension);
// we can't display a NaN resolution
if (!Number.isNaN(resolution)) {
// what is the maximum possible resolution?
// this will determine how we format the lower resolutions
const maxResolutionSize = maxWidth / ((2 ** maxZoom) * binsPerDimension);
const pp = precisionPrefix(maxResolutionSize, resolution);
const f = formatPrefix(`.${pp}`, resolution);
const formattedResolution = f(resolution);
return formattedResolution;
}
console.warn('NaN resolution, screen is probably too small.');
return '';
}
for (let i = 0; i <= track.maxZoom; i++) {
const { maxWidth, binsPerDimension, maxZoom } = track;
let maxResolutionSize = 1;
let resolution = 1;
if (track.resolutions) {
const sortedResolutions = track.resolutions.map(x => +x).sort((a, b) => b - a);
([maxResolutionSize] = sortedResolutions);
resolution = sortedResolutions[i];
} else {
resolution = track.maxWidth / ((2 ** i) * track.binsPerDimension);
maxResolutionSize = maxWidth / ((2 ** maxZoom) * binsPerDimension);
}
const pp = precisionPrefix(maxResolutionSize, resolution);
const f = formatPrefix(`.${pp}`, resolution);
const formattedResolution = f(resolution);
inlineOptions.push({
name: formattedResolution,
value: i.toString(),
});
//
}
return inlineOptions;
} return [];
},
},
export default function(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;
}
}
function formatResolutionText(resolution, maxResolutionSize) {
const pp = precisionPrefix(maxResolutionSize, resolution);
const f = formatPrefix(`.${pp}`, resolution);
const formattedResolution = f(resolution);
return formattedResolution;
}
function linearNumberFormat(domain, count, f) {
var range = linearRange(domain, count);
if (f == null) f = ',f';
switch (f = d3_numberF.formatSpecifier(f), f.type) {
case 's': {
var value = Math.max(Math.abs(range[0]), Math.abs(range[1]));
if (f.precision == null) f.precision = d3_numberF.precisionPrefix(range[2], value);
return numberF.formatPrefix(f, value);
}
case '':
case 'e':
case 'g':
case 'p':
case 'r': {
if (f.precision == null) f.precision = d3_numberF.precisionRound(range[2], Math.max(Math.abs(range[0]), Math.abs(range[1]))) - (f.type === 'e');
break;
}
case 'f':
case '%': {
if (f.precision == null) f.precision = d3_numberF.precisionFixed(range[2]) - 2 * (f.type === '%');
break;
}
}