Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-chartjs-2

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chartjs-2

react-chartjs-2

  • 1.5.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-6.18%
Maintainers
1
Weekly downloads
 
Created

What is react-chartjs-2?

The react-chartjs-2 npm package is a React wrapper for Chart.js, a popular JavaScript library for creating simple yet flexible charts. It allows developers to create various types of charts such as line, bar, radar, doughnut, and pie charts, among others, with ease. The package provides React components that encapsulate Chart.js functionality, making it easy to integrate into React applications.

What are react-chartjs-2's main functionalities?

Line Chart

This code sample demonstrates how to create a simple line chart using react-chartjs-2. It includes a dataset for monthly sales and configures the chart to start the y-axis at zero.

{"import { Line } from 'react-chartjs-2';\n\nconst data = {\n  labels: ['January', 'February', 'March', 'April', 'May', 'June'],\n  datasets: [{\n    label: 'Monthly Sales',\n    data: [65, 59, 80, 81, 56, 55],\n    fill: false,\n    borderColor: 'rgb(75, 192, 192)',\n    tension: 0.1\n  }]\n};\n\nconst options = {\n  scales: {\n    y: {\n      beginAtZero: true\n    }\n  }\n};\n\nfunction MyLineChart() {\n  return <Line data={data} options={options} />;\n}"}

Bar Chart

This code sample shows how to create a bar chart with react-chartjs-2. It sets up a dataset with different colors for each bar representing votes for different options.

{"import { Bar } from 'react-chartjs-2';\n\nconst data = {\n  labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],\n  datasets: [{\n    label: 'Votes',\n    data: [12, 19, 3, 5, 2, 3],\n    backgroundColor: [\n      'rgba(255, 99, 132, 0.2)',\n      'rgba(54, 162, 235, 0.2)',\n      'rgba(255, 206, 86, 0.2)',\n      'rgba(75, 192, 192, 0.2)',\n      'rgba(153, 102, 255, 0.2)',\n      'rgba(255, 159, 64, 0.2)'\n    ],\n    borderColor: [\n      'rgba(255, 99, 132, 1)',\n      'rgba(54, 162, 235, 1)',\n      'rgba(255, 206, 86, 1)',\n      'rgba(75, 192, 192, 1)',\n      'rgba(153, 102, 255, 1)',\n      'rgba(255, 159, 64, 1)'\n    ],\n    borderWidth: 1\n  }]\n};\n\nfunction MyBarChart() {\n  return <Bar data={data} />;\n}"}

Doughnut Chart

This code sample illustrates how to create a doughnut chart using react-chartjs-2. It includes a dataset with three segments, each with its own color.

{"import { Doughnut } from 'react-chartjs-2';\n\nconst data = {\n  labels: ['Red', 'Blue', 'Yellow'],\n  datasets: [{\n    data: [300, 50, 100],\n    backgroundColor: [\n      '#FF6384',\n      '#36A2EB',\n      '#FFCE56'\n    ],\n    hoverBackgroundColor: [\n      '#FF6384',\n      '#36A2EB',\n      '#FFCE56'\n    ]\n  }]\n};\n\nfunction MyDoughnutChart() {\n  return <Doughnut data={data} />;\n}"}

Other packages similar to react-chartjs-2

Keywords

FAQs

Package last updated on 03 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc