How to use the d3-collection.nest function in d3-collection

To help you get started, we’ve selected a few d3-collection 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 broadinstitute / gtex-viz / src / modules / Heatmap.js View on Github external
_setXScale(width, newList = undefined) {
        if(newList !== undefined){
            this.xList = newList
        }
        else {
            this.xList = nest()
                .key((d) => d.x)
                .entries(this.data)
                .map((d) => d.key);
        }
        this.xScale = scaleBand()
            .domain(this.xList)
            .range([0, width])
            .padding(.05); // TODO: eliminate hard-coded value
    }
github broadinstitute / gtex-viz / src / modules / HalfMap.js View on Github external
_setXScale(dim={w:600}, xList=undefined){
        if (xList === undefined){
            xList = nest()
            .key((d) => d.x) // group this.data by d.x
            .entries(this.data)
            .map((d) => d.key) // then return the unique list of d.x
            .sort((a, b) => {return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;});
        }

        this.xScale = scaleBand() // reference: https://github.com/d3/d3-scale#scaleBand
            .domain(xList) // perhaps it isn't necessary to store xList, it could be retrieved by xScale.domain
            // .range([dim.left, dim.left+(dim.w/Math.sqrt(2))])
            .range([0, dim.w/Math.sqrt(2)])
            .padding(.05); // temporarily hard-coded value
    }
github PitchInteractiveInc / tilegrams / source / components / HexMetrics.js View on Github external
_getCountsByGeo(tiles, geos) {
    const counts = nest()
      .key((d) => d.id)
      .rollup((values) => values.length)
      .entries(tiles)
    const countHash = hashFromData(counts)
    return geos.map((geo) => {
      return {
        key: geo,
        value: countHash[geo] || 0,
      }
    }).sort((a, b) => a.key - b.key)
  }
github broadinstitute / gtex-viz / src / GeneEqtlVisualizer.js View on Github external
function buildVariantLookupTables(bmap){
    bmap.rsLookUp = {};
    bmap.varLookUp = {};
    nest()
        .key((d)=>d.x)
        .entries(bmap.data)
        .forEach((d)=> {
            let v = d.values[0];
            if(v.hasOwnProperty('snpId') === undefined) throw 'Input Error: RS ID lookup table is not built.';
            if(v.hasOwnProperty('displayX') === undefined) throw 'Input Error: display label lookup table is not built.';

            bmap.rsLookUp[d.key] = d.values[0].snpId;
            bmap.varLookUp[d.key] = d.values[0].displayX;
        });
}
github samccone / bundle-buddy / viz / src / index.js View on Github external
.map(d => {
        d[3] = nest()
          .key(d => d.inBundleCount)
          .rollup(leaves => sum(leaves, l => l.count))
          .entries(Object.values(d[1]))
          .map(d => {
            d.key = parseInt(d.key, 10);
            return d;
          })
          .sort((a, b) => b.key - a.key);

        return d;
      });

d3-collection

Handy data structures for elements keyed by string.

BSD-3-Clause
Latest version published 6 years ago

Package Health Score

55 / 100
Full package analysis