React Google Charts Wrapper

5.2.1 · active · verified Sun Apr 19

react-google-charts is a fully typed React component library that provides a lightweight wrapper around the official Google Charts library. It simplifies the integration of over 25 different Google Chart types, supporting animations and extensive customization options. The package is currently at version 5.2.1 and shows an active release cadence with frequent updates, including new features, bug fixes, and typings enhancements, as evidenced by recent 5.x releases. Its primary differentiator is providing a modern React component API with TypeScript support, abstracting away the direct interaction with the Google Charts loader script and API, making it easier for React developers to quickly add data visualizations to their applications without deep knowledge of the underlying Google Charts library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to render a basic Line Chart using `react-google-charts`, providing data and options.

import React from 'react';
import { Chart } from 'react-google-charts';

function MyChartComponent() {
  const data = [
    ["Year", "Sales", "Expenses"],
    ["2004", 1000, 400],
    ["2005", 1170, 460],
    ["2006", 660, 1120],
    ["2007", 1030, 540]
  ];

  const options = {
    title: "Company Performance",
    curveType: "function",
    legend: { position: "bottom" }
  };

  return (
    <div style={{ width: '100%', maxWidth: '800px', margin: '0 auto' }}>
      <h2>Sales & Expenses Over Time</h2>
      <Chart
        chartType="LineChart"
        data={data}
        options={options}
        width="100%"
        height="400px"
        legendToggle
      />
    </div>
  );
}

export default MyChartComponent;

view raw JSON →