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

react-chord-diagram

v2.0.0

Published

A React component for building D3 Chord Diagrams

Downloads

537

Readme

React Chord Diagram

A React component for building D3 Chord Diagrams

Travis npm package Coveralls

Table of Contents

Installation

$ npm install react-chord-diagram

Usage

import ChordDiagram from 'react-chord-diagram'
    
const matrix = [
  [11975, 5871, 8916, 2868],
  [1951, 10048, 2060, 6171],
  [8010, 16145, 8090, 8045],
  [1013, 990, 940, 6907]
]; 

<ChordDiagram
  matrix={matrix}
  componentId={1}
  groupLabels={['Black', 'Yellow', 'Brown', 'Orange']}
  groupColors={["#000000", "#FFDD89", "#957244", "#F26223"]}
/>

screenshot

Required Props

matrix

  • type: array of arrays

The matrix to be visualized. See D3 Chord.

example:

[
  [11975,  5871, 8916, 2868],
  [ 1951, 10048, 2060, 6171],
  [ 8010, 16145, 8090, 8045],
  [ 1013,   990,  940, 6907],
]

componentId

  • type: number

A unique id for the component.

Optional Props

width

  • type: number

Width of the diagram in pixels.

height

  • type: number

Height of the diagram in pixels.

style

  • type: object

Custom styles applied to the diagram's root div.

example:

    {
        font: '10px sans-serif'
    }

className

  • type: string

Custom class name applied to the root svg.

outerRadius

  • type: number

Outer radius of the diagram in pixels.

innerRadius

  • type: number

Inner radius of the diagram in pixels.

groupColors

  • type: array

List of colors, one for each group.

example:

["#000000", "#FFDD89", "#957244", "#F26223"]

padAngle

  • type: number

Specifies the percent of padding between arcs or groups.

default: .05

sortGroups

  • type: function

A function that specifies how the groups should be sorted. See chord.sortGroups.

default: null

sortSubGroups

  • type: function

A function that specifies how subgroups should be sorted. See chord.sortSubGroups.

default: d3.descending

sortChords

  • type: function

A function that specifies how chords should be sorted. See chord.sortChords.

default: d3.descending

labelColors

  • type: array

The color of each label in the diagram.

default: #000000

disableHover

  • type: boolean

Whether to hide other ribbons while mousing over a particular group or ribbon. This overrides the individual group / ribbon hover settings.

default: false

disableGroupHover

  • type: boolean

Whether to hide other ribbons while mousing over a particular group.

default: false

disableRibbonHover

  • type: boolean

Whether to hide other ribbons while mousing over a particular ribbon.

default: false

blurOnHover

  • type: boolean

Whether to blur other ribbons instead of hiding them on hover.

default: false

persistHoverOnClick

  • type: boolean

If true, ribbons highlighted on hover will remain highlighted if you click on the element causing the hover. Click anywhere on the SVG to clear this state.

default: false

ribbonOpacity

  • type: string

Default opacity value for ribbons.

default: '0.67'

ribbonBlurOpacity

  • type: string

If blurOnHover is true, then set 'hidden' ribbons to this opacity instead of hiding them.

default: '0.2'

strokeWidth

  • type: number

Will change the stroke width of the ribbons.

default: 1

resizeWithWindow

  • type: boolean

Resize the svg when the window is resized.

default: false

groupOnClick

  • type: function

A function that will happen when a group is clicked. Group index is passed to the function.

default: null

ribbonOnClick

  • type: function

A function that will happen when a ribbon is clicked. Ribbon index is passed to the function.

default: null

svgOnClick

  • type: function

A function that will happen when the background SVG is clicked. The event is passed to the function.

default: null