Get started with react-chartjs-2 CDN

MIT licensed

React-chartjs-2 is a popular React library for rendering interactive charts using Chart.js.

Tags:
  • chart
  • chart-js
  • chart.js
  • react-chartjs-2
  • react chart.js

Stable version

Copied!

How to start using react-chartjs-2 CDN


import React from 'react';
import { Bar } from 'react-chartjs-2';

const data = {
  labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple'],
  datasets: [
    {
      label: '# of Votes',
      data: [12, 19, 3, 5, 2],
      backgroundColor: 'rgba(255, 99, 122, 0.2)',
    },
  ],
};

const options = {
  scales: {
    y: {
      beginAtZero: true,
    },
  },
};

const Chart = () => {
  return (
    <div className="chart-container">
      <Bar data={data} options={options} />
    </div>
  );
};

export default Chart;
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions