npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3.layout.grid

v0.0.1

Published

Lightweight grid layout designed for categorical data

Downloads

36

Readme

d3.layout.grid

Lightweight grid layout designed for categorical data

Demo: http://felixlaumon.github.io/d3.layout.grid/examples/basic.html

d3.layout.grid is designed to display categorical data, allowing users to sort and group by different categorical variables.

To maintain flexibility and the possibility to animate between layout type (e.g. between grid and force layout), d3.layout.grid does not include animation logic, but set x and y coordinates to the data.

Like other classes in D3, d3.layout.grid is chainable.

Quick Start

var grid = d3.layout.grid()
  .width(500)
  .height(1000)
  .data(data)
  .groupBy('color')

d3.selectAll('circle')
  .enter()
    .append('circle')
    .attr('r', 10)
    .attr('cx', function (d) { return d.x; })
    .attr('cy', function (d) { return d.y; })
    .attr('fill', function (d) { return d.color; })

See examples/basic.html and examples/basic.js for a complete example.

API

grid = d3.layout.grid()

Returns a new grid layout with the following default settings:

  • width = 500
  • height = 1000
  • colWidth = 50
  • rowHeight = 50
  • sectionPadding = 100
  • marginLeft = 50
  • marginTop = 100

grid.data([data])

Data associated with the grid. Relayouting (triggered by groupBy(...) or sort(...)) will set x and y properties to each datum, which can then be used for animation.

grid.groupBy(string | fn)

Group data using underscore's _.groupBy.

Will trigger relayout.

grid.sort(groupComparator, dataComparator)

groupComparator is used to produce the group order, which is invoked with the group names (a string) from grid.groupBy()

dataComparator is used to sort the data within a group, which is inovked with the data from grid.data()

Will trigger relayout.

grid.groups()

Returns information about current grouping. Most notably it returns the y-coordinate of each group, which allows easy placement for the group headers.

grid.width(), grid.height(), grid.colWidth(), grid.rowHeight(), grid.sectionPadding(), grid.marginLeft(), grid.marginTop()

If 1 argument is specified, set that corresponding config; otherwise return that config.

This should be normally done with the initialization of d3.layout.grid(). Note that this doesn't trigger a relayout. To change a config with animation, call grid.relayout()

grid.relayout()

Force manual relayout of the grid

License

ISC. Copyright (c) 2014 Felix Lau.