How to use the vega-scale.isLogarithmic function in vega-scale

To help you get started, we’ve selected a few vega-scale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vega / vega / packages / vega-encode / src / Scale.js View on Github external
function domainCheck(type, domain, df) {
  if (isLogarithmic(type)) {
    // sum signs of domain values
    // if all pos or all neg, abs(sum) === domain.length
    var s = Math.abs(domain.reduce(function(s, v) {
      return s + (v < 0 ? -1 : v > 0 ? 1 : 0);
    }, 0));

    if (s !== domain.length) {
      df.warn('Log scale domain includes zero: ' + stringValue(domain));
    }
  }
  return domain;
}
github vega / vega / packages / vega-encode / src / ticks.js View on Github external
export function tickFormat(scale, count, specifier, formatType) {
  var format = scale.tickFormat ? scale.tickFormat(count, specifier)
    : specifier && formatType === Time ? timeFormat(specifier)
    : specifier ? numberFormat(specifier)
    : String;

  if (isLogarithmic(scale.type)) {
    var logfmt = variablePrecision(specifier);
    format = scale.bins ? logfmt : filter(format, logfmt);
  }

  return format;
}