Socket
Socket
Sign inDemoInstall

d3-hexbin

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-hexbin

Group two-dimensional points into hexagonal bins.


Version published
Weekly downloads
237K
decreased by-1.38%
Maintainers
2
Weekly downloads
 
Created

What is d3-hexbin?

The d3-hexbin npm package is a plugin for D3.js that provides tools for creating hexagonal binning visualizations. Hexagonal binning is a technique used to visualize the density of points in a scatter plot by grouping points into hexagonal bins. This can be particularly useful for large datasets where individual points may overlap and obscure patterns.

What are d3-hexbin's main functionalities?

Hexbin Generation

This code demonstrates how to generate hexagonal bins from a set of random data points. The `hexbin` function is configured with a radius and extent, and then used to bin the data points.

const d3 = require('d3');
const d3Hexbin = require('d3-hexbin');

const width = 960;
const height = 500;
const data = d3.range(2000).map(() => [Math.random() * width, Math.random() * height]);

const hexbin = d3Hexbin.hexbin()
  .radius(20)
  .extent([[0, 0], [width, height]]);

const bins = hexbin(data);
console.log(bins);

Hexbin Visualization

This code demonstrates how to visualize hexagonal bins using SVG elements. The hexbin data is used to create SVG paths that represent each hexagon, which are then appended to the SVG element.

const d3 = require('d3');
const d3Hexbin = require('d3-hexbin');

const svg = d3.select('body').append('svg')
  .attr('width', 960)
  .attr('height', 500);

const width = +svg.attr('width');
const height = +svg.attr('height');
const data = d3.range(2000).map(() => [Math.random() * width, Math.random() * height]);

const hexbin = d3Hexbin.hexbin()
  .radius(20)
  .extent([[0, 0], [width, height]]);

const bins = hexbin(data);

svg.append('g')
  .selectAll('path')
  .data(bins)
  .enter().append('path')
  .attr('d', hexbin.hexagon())
  .attr('transform', d => `translate(${d.x},${d.y})`)
  .style('fill', 'steelblue')
  .style('stroke', 'white');

Other packages similar to d3-hexbin

Keywords

FAQs

Package last updated on 28 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc