Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@visx/voronoi

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visx/voronoi

visx voronoi

  • 3.12.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is @visx/voronoi?

@visx/voronoi is a part of the VisX library, which provides a collection of reusable low-level visualization components for React. The @visx/voronoi package specifically deals with creating and rendering Voronoi diagrams, which are a way of dividing a plane into regions based on distance to a specific set of points.

What are @visx/voronoi's main functionalities?

Creating a Voronoi Layout

This feature allows you to create a Voronoi layout using a set of data points. The `d3.voronoi()` function is used to generate the Voronoi diagram, and the `polygons` method is used to get the Voronoi cells.

const voronoi = d3.voronoi().extent([[0, 0], [width, height]]); const polygons = voronoi.polygons(data);

Rendering Voronoi Cells

This feature allows you to render the Voronoi cells as SVG paths. Each cell is represented as a path element, and the `d` attribute is set to the coordinates of the cell.

polygons.map((polygon, i) => <path key={`polygon-${i}`} d={`M${polygon.join('L')}Z`} />);

Handling Voronoi Events

This feature allows you to handle events on the Voronoi cells. For example, you can add `onMouseEnter` and `onMouseLeave` event handlers to each cell to handle mouse events.

<path key={`polygon-${i}`} d={`M${polygon.join('L')}Z`} onMouseEnter={() => handleMouseEnter(polygon)} onMouseLeave={() => handleMouseLeave(polygon)} />

Other packages similar to @visx/voronoi

Keywords

FAQs

Package last updated on 07 Nov 2024

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