Git Product home page Git Product logo

react-chord-diagram's Introduction

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.

height

  • type: number

Height of the diagram.

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.

innerRadius

  • type: number

Inner radius of the diagram.

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

react-chord-diagram's People

Contributors

flagollet avatar langfordg avatar thedanielforum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.