kristw / react-d3kit

Adapter for converting d3Kit class into React class

Home Page:https://react-d3kit.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction | Demo

react-d3kit NPM version Build Status Dependency Status

Easily convert d3Kit chart into React component

Install

npm install react-d3kit --save

Example Usage

Basic

// When PlainBubbleChart is a reusable chart written in d3Kit.
const BubbleChart = ReactD3Kit.createComponent(PlainBubbleChart);

ReactDOM.render(
  <BubbleChart data={data} options={options} />,
  document.getElementById('app')
);

With auto-resize

You can pass props fitOptions and watch, which is equivalent to calling d3Kit's chart.fit(fitOptions, watch). See documentation here.

// When PlainBubbleChart is a reusable chart written in d3Kit.
const BubbleChart = ReactD3Kit.createComponent(PlainBubbleChart);

const fitOptions = { width: '100%', height: 400 };

ReactDOM.render(
  <BubbleChart
    data={data}
    options={options}
    fitOptions={fitOptions}
    watch={true}
  />,
  document.getElementById('app')
);

See demo source

Import into your project

Choice 1. Global

Adding this library via <script> tag is the simplest way. By doing this, ReactD3Kit is available in the global scope.

<script src="node_modules/react-d3kit/dist/react-d3kit.min.js"></script>
Choice 2: AMD

If you use requirejs, this library support AMD out of the box.

require.config({
  paths: {
    'react-d3kit': 'path/to/react-d3kit'
  }
});
require(['react-d3kit'], function(ReactD3Kit) {
  // do something with reactD3Kit
});
Choice 3: node.js / browserify

This library also supports usage in commonjs style.

const { createComponent } = require('react-d3kit');
Choice 4: ES6 Import
import { createComponent } from 'react-d3kit';

License

© 2016-2018 Krist Wongsuphasawat (@kristw) Apache-2.0 License

About

Adapter for converting d3Kit class into React class

https://react-d3kit.vercel.app

License:Other


Languages

Language:JavaScript 100.0%