1.3.3 • Published 1 month ago

d3plus-react v1.3.3

Weekly downloads
80
License
MIT
Repository
github
Last release
1 month ago

d3plus-react

NPM Release Build Status Dependency Status Gitter

React components for d3plus visualizations.

Installing

Use npm install d3plus-react -S to install the package as a dependency.

Configuration

A valid d3plus config Object needs to be provided to the config prop of every visualization.

import {Treemap} from "d3plus-react";

const methods = {
  groupBy: "id",
  data: [
    {id: "alpha", value: 29},
    {id: "beta",  value: 10}
  ],
  size: d => d.value
};

<Treemap config={methods} />

Additionally, a global set of styles can be provided using the "d3plus" React context key. This allows you to set base styles on all of your visualizations in one place, often in an external file. A component's config set by props will override global defaults key-by-key using a deep cloning function.

import React, {Component} from "react";

export default class MyApp extends Component {

  getChildContext() {

    return {
      d3plus: {
        shapeConfig: {
          fontFamily: "Comic Sans MS"
        }
      }
    };

  }

  render() {

    return (
      <main>
        {/* child components containing visualizations */}
      </main>
    );

  }

}

MyApp.childContextTypes = {
  d3plus: PropTypes.object
};

Update Cycle

In order to detect whether a component should udpate in React, each component does a rudimentary check between the current config object and the incoming new config object. This is done via a simple equality check on the stringified versions of each object. This can also be overridded using the forceUpdate prop:

const shouldUpdate = this.props.forceUpdate ? false : JSON.stringify(oldConfig) === JSON.stringify(newConfig);

This works in most cases, but may not update your visualizations if using an accessor function that references an external variable. For example, if your x accessor is:

const config = {
  ...,
  x: d => d[xVar]
};

...and xVar changes, the visualization will not update. The quick "hack" for this is add xVar to the config object so that it triggers the update via stringify:

const config = {
  ...,
  x: d => d[xVar],
  xVar
};

API Reference


d3plus.AreaPlot() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.BarChart() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.BoxWhisker() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.BumpChart() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.D3plusContext() <>

A React context instance used to provide global config options via a provider (D3plusContext.Provider).

This is a global function.


d3plus.Donut() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Geomap() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.LinePlot() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Matrix() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Network() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Pack() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Pie() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Plot() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Priestley() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Radar() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.RadialMatrix() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Rings() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Sankey() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.StackedArea() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Tree() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Treemap() <>

This is a global function, and extends all of the methods and functionality of Viz.


d3plus.Viz() <>

Creates SVG paths and coordinate points based on an array of data. See this example for help getting started using the geomap generator.

This is a global function.

# .module.exports <>

This is a static property of Viz.

ParamTypeDefaultDescription
configObject{}An object containing method/value pairs to be passed to the visualization's .config( ) method.
dataFormatfunctiond3plus.dataFoldA custom formatting function to be used when formatting data from an AJAX request. The function will be passed the raw data returned from the request, and is expected to return an array of values used for the data method.
linksFormatfunctiond3plus.links(path, formatter)A custom formatting function to be used when formatting links from an AJAX request. The function will be passed the raw data returned from the request, and is expected to return an array of values used for the links method.
nodesFormatfunctiond3plus.nodes(path, formatter)A custom formatting function to be used when formatting nodes from an AJAX request. The function will be passed the raw data returned from the request, and is expected to return an array of values used for the nodes method.
topojsonFormatfunctiond3plus.topojson(path, formatter)A custom formatting function to be used when formatting topojson from an AJAX request. The function will be passed the raw data returned from the request, and is expected to return an array of values used for the topojson method.

Documentation generated on Tue, 26 Mar 2024 18:14:38 GMT
1.2.8

1 month ago

1.3.3

12 months ago

1.3.2

1 year ago

1.3.1

1 year ago

1.1.3

1 year ago

1.3.0

1 year ago

1.2.0

2 years ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.6.1

3 years ago

0.6.0

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.29

6 years ago

0.2.28

6 years ago

0.2.27

6 years ago

0.2.26

6 years ago

0.2.25

6 years ago

0.2.24

6 years ago

0.2.23

6 years ago

0.2.22

6 years ago

0.2.21

6 years ago

0.2.20

6 years ago

0.2.19

6 years ago

0.2.18

6 years ago

0.2.17

7 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago