Skip to content

oliverbienert/react-chartjs2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-chartjs2

React component for Chart.js

Installation

npm install react-chartjs2 --save

Example Usage

// using ES6
import {Bar} from 'react-chartjs2';
class Main extends Component {
  render() {
    return <Bar data={chartData} options={chartOptions} />;
  }
};
// not using ES6
var Bar = require('react-chartjs2').Bar;
var Main = React.createClass({
  render: function() {
    return <Bar data={chartData} options={chartOptions} />;
  }
});

Get your Chart instance, like

class Main extends Component {
  componentDidMount() {
    this.myChart = this.refs['canvas'].getChart();
    this.myChart.datasets[0].points[2].value = 50;
    this.myChart.update();
  }
  render() {
    return <Bar ref='canvas' data={chartData} options={chartOptions} />;
  }
};

Chart type

  • Bar
  • Doughnut
  • Line
  • Pie
  • PolarArea
  • Radar

About

React component for Chart.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%