How to use the d3-scale.scaleQuantile function in d3-scale

To help you get started, we’ve selected a few d3-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 DefinitelyTyped / DefinitelyTyped / types / d3-scale / d3-scale-tests.ts View on Github external
outputNumber = quantizeScaleNumber(0.51);

// copy(...) -----------------------------------------------------------------

const copiedQuantizeScale: d3Scale.ScaleQuantize = quantizeScaleNumber.copy();

// -------------------------------------------------------------------------------
// Quantile Scale Factory
// -------------------------------------------------------------------------------

// scaleQuantile() -----------------------------------------------------------------

let quantileScaleNumber: d3Scale.ScaleQuantile;
let quantileScaleString: d3Scale.ScaleQuantile;

quantileScaleNumber = d3Scale.scaleQuantile();
quantileScaleString = d3Scale.scaleQuantile();

// ScaleQuantile Interface ========================================================

// domain(...) -----------------------------------------------------------------

quantileScaleNumber = quantileScaleNumber.domain(domainNumbers);

domainNumbers = quantileScaleNumber.domain();

quantileScaleString = quantileScaleString.domain(domainNumeric);

// range(...) -----------------------------------------------------------------

quantileScaleNumber = quantileScaleNumber.range([1, 2, 3, 4]);
rangeNumbers = quantileScaleNumber.range();
github DefinitelyTyped / DefinitelyTyped / d3-scale / d3-scale-tests.ts View on Github external
// copy(...) -----------------------------------------------------------------

let copiedQuantizeScale: d3Scale.ScaleQuantize = quantizeScaleNumber.copy();


// -------------------------------------------------------------------------------
// Quantile Scale Factory
// -------------------------------------------------------------------------------


// scaleQuantile() -----------------------------------------------------------------

let quantileScaleNumber: d3Scale.ScaleQuantile;
let quantileScaleString: d3Scale.ScaleQuantile;

quantileScaleNumber = d3Scale.scaleQuantile();
quantileScaleString = d3Scale.scaleQuantile();


// ScaleQuantile Interface ========================================================

// domain(...) -----------------------------------------------------------------

quantileScaleNumber = quantileScaleNumber.domain(domainNumbers);

domainNumbers = quantileScaleNumber.domain();

quantileScaleString = quantileScaleString.domain(domainNumeric);

// range(...) -----------------------------------------------------------------

quantileScaleNumber = quantileScaleNumber.range([1, 2, 3, 4]);
github uber / deck.gl / examples / website / arc / app.js View on Github external
}
    if (!selectedCounty) {
      selectedCounty = data.find(f => f.properties.name === 'Los Angeles, CA');
    }
    const {flows, centroid} = selectedCounty.properties;

    const arcs = Object.keys(flows).map(toId => {
      const f = data[toId];
      return {
        source: centroid,
        target: f.properties.centroid,
        value: flows[toId]
      };
    });

    const scale = scaleQuantile()
      .domain(arcs.map(a => Math.abs(a.value)))
      .range(inFlowColors.map((c, i) => i));

    arcs.forEach(a => {
      a.gain = Math.sign(a.value);
      a.quantile = scale(Math.abs(a.value));
    });

    if (this.props.onSelectCounty) {
      this.props.onSelectCounty(selectedCounty);
    }

    this.setState({arcs, selectedCounty});
  }
github swimlane / ngx-charts / src / common / color.helper.ts View on Github external
generateColorScheme(scheme, type, domain) {
    if (typeof(scheme) === 'string') {
      scheme = colorSets.find(cs => {
        return cs.name === scheme;
      });
    }
    let colorScale;
    if (type === 'quantile') {
      colorScale = scaleQuantile()
        .range(scheme.domain)
        .domain(domain);

    } else if (type === 'ordinal') {
      colorScale = scaleOrdinal()
        .range(scheme.domain)
        .domain(domain);

    } else if (type === 'linear') {
      colorScale = scaleLinear()
        .domain(range(0, 1, 1.0 / (scheme.domain.length - 1)))
        .range(scheme.domain);
    }

    return colorScale;
  }
github react-d3 / react-d3-core / src / utils / scale.jsx View on Github external
var func;

  if(scale === 'linear')
    func = D3Scale.scaleLinear();
  else if(scale === 'identity')
    func = D3Scale.scaleIdentity();
  else if(scale === 'sqrt')
    func = D3Scale.scaleSqrt();
  else if(scale === 'pow')
    func = D3Scale.scalePow();
  else if(scale === 'log')
    func = D3Scale.scaleLog();
  else if(scale === 'quantize')
    func = D3Scale.scaleQuantize();
  else if(scale === 'quantile')
    func = D3Scale.scaleQuantile();
  else if(scale === 'ordinal')
    func = D3Scale.scaleOrdinal()
  else if(scale === 'band')
    func = D3Scale.scaleBand();
  else if(scale === 'time')
    func = D3Scale.scaleTime();
  else
    new Error(`Please check your axis scale setting. "${scale}" scale is invalid. `)

  func = _mkScaleSettings(props, func);

  return func;
}
github uber / deck.gl / examples / website / arc / deckgl-overlay.js View on Github external
if (!data || !selectedFeature) {
      return null;
    }

    const {flows, centroid} = selectedFeature.properties;

    const arcs = Object.keys(flows).map(toId => {
      const f = data[toId];
      return {
        source: centroid,
        target: f.properties.centroid,
        value: flows[toId]
      };
    });

    const scale = scaleQuantile()
      .domain(arcs.map(a => Math.abs(a.value)))
      .range(inFlowColors.map((c, i) => i));

    arcs.forEach(a => {
      a.gain = Math.sign(a.value);
      a.quantile = scale(Math.abs(a.value));
    });

    return arcs;
  }
github uber / react-map-gl / examples / geojson / src / utils.js View on Github external
export function updatePercentiles(featureCollection, accessor) {
  const {features} = featureCollection;
  const scale = scaleQuantile()
    .domain(features.map(accessor))
    .range(range(9));
  features.forEach(f => {
    const value = accessor(f);
    f.properties.value = value;
    f.properties.percentile = scale(value);
  });
}