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

d3kit-gridmap

v1.1.0

Published

A grid map component based on d3kit

Downloads

12

Readme

Introduction | Demo | API Reference

d3Kit-gridmap NPM version Dependency Status

A tile grid map component built on top of d3Kit

Note: If you are upgrading from v0.x.x to v1.x.x, this library now return the constructor d3KitGridmap instead of d3Kit. Please see the change logs for more detail.

Install

npm install d3kit-gridmap --save

or

bower install d3kit-gridmap --save

Example Usage

For example, to draw a grid map of the US, create a grid map component and pass gridmap-layout-usa as the layout. View source of this demo for example.

var chart = new d3KitGridmap('#usa', {
  col: function(d){return d.x;},
  row: function(d){return d.y;},
  fill: function(d){return color(d.name.length);}
})
  .data(gridmapLayoutUsa)
  .resizeToFitMap();

For more detailed usage please refer to the API Reference.

Layout

d3Kit-gridmap does not come with layout, which is an Array of tiles and their positions, which make it can be reused for a map of any region or country.

The layout has to be passed to the chart by calling chart.data(layout) for this component to show something on the screen.

In the simplest way, you can just pass a custom Array as your own layout.

chart.data([
  {key: 'region1', col: 1, row 2},
  {key: 'region2', col: 1, row 3},
  ...
]);

Or use these available layouts:

Import into your project

Choice 1. Global

Adding this library via <script> tag is the simplest way. By doing this, d3KitGridmap is available in the global scope.

<script src="bower_components/d3/d3.min.js"></script>
<script src="bower_components/d3kit/dist/d3kit.min.js"></script>
<script src="bower_components/d3kit-gridmap/dist/d3kit-gridmap.min.js"></script>
Choice 2: AMD

If you use requirejs, this library support AMD out of the box.

require.config({
  paths: {
    d3:    'path/to/d3',
    d3kit: 'path/to/d3kit',
    'd3kit-gridmap': 'path/to/d3kit-gridmap'
  }
});
require(['d3kit-gridmap'], function(d3KitGridmap) {
  // do something with d3KitGridmap
});

This module will be available as d3Kit.Gridmap.

Choice 3: node.js / browserify

This library also supports usage in commonjs style.

var d3KitGridmap = require('d3kit-gridmap');
// do something with d3KitGridmap

Author

Krist Wongsuphasawat / @kristw

Copyright 2016 Krist Wongsuphasawat. Licensed under the Apache License Version 2.0