0.1.9 • Published 8 years ago

@redsift/d3-rs-treemap v0.1.9

Weekly downloads
20
License
MIT
Repository
github
Last release
8 years ago

d3-rs-treemap

d3-rs-treemap A TreeMap visual component made with D3v4

Builds

Circle CI npm MIT

Example

View @redsift/d3-rs-treemap on Codepen

Treemap chart

Sample treemp with text

Usage

Browser

ES6

import { chart } from "@redsift/d3-rs-treemap"; let eml = chart.html(); ...

Require

var chart = require("@redsift/d3-rs-treemap"); var eml = chart.html(); ...

Data layout

Data need to be in a hierarchical form as it is described in d3-hierarchy. The basic criteria is to have the children property. If your data are not in a hierarchical form you can use the stratify method in d3-hierarchy to manipulate them.

{
  name:'root',
  children: [
    {
      l: 'children1',
      v: 10
    },
    {
      l: 'children1',
      v: 10,
      u: 'http://www.google.com/children2'
    }
  ]
}

For this visualization objects inside the children array are expected to have the above layout. The u property is optional, only if you want to display images so you need to provide a link.

Parameters

NameDescriptionTransition
classedSVG custom classN
width, height, size, scale, marginInteger SVG container sizesY
styleString Custom CSS to inject into chartN
fillString, Array, Function Colour palette for the data. Available options from d3-rs-themeY
themeString dark or light(default)
appendTextBoolean Append a text element inside the rect
textValueString, Function for the value of the text element that will be displayed
appendImageBoolean Append an image element inside the rectY
imageFallbackLinkString Helper link of asset to display as a fall back solution when an image fails to load
filterString Filter to be applied on an image as described in d3-rs-theme#filters e.g. 'emboss', 'greyscale', 'shadow'