Code Monkey home page Code Monkey logo

react-google-sheet-to-chart's Introduction

React Google Sheet to Chart

Postlight's React Google Sheet to Chart React component transforms Google Sheets to attractive charts in your webapp with minimal effort. Read all about it in this handy introduction.

Try it now at the demo site and check out the demo site GitHub repository.

Robo Chart preview

Installation

The package can be installed via NPM:

npm install @postlight/react-google-sheet-to-chart --save

# or

yarn add @postlight/react-google-sheet-to-chart

Usage

To use this component, you'll need a Google API key. First enable Google Sheets API and then generate the API Key here and restrict it to HTTP referrers (web sites).

Second, you'll need a Google Sheet containing the data you wish to plot. (Be sure to check out the spreadsheet format guidelines.)

Finally, import the React component and initialize it with at least three required props:

  • id: Spreadsheet ID, e.g. 1RE_JYUCXBXY2LNV5Tp5GegLnMue-CpfTVMxjdudZ8Js (extractable from a Google sheet URL)
  • sheet: Sheet name to parse data from, e.g. Sheet1
  • token: The Google API key you created above
import RoboChart from '@postlight/react-google-sheet-to-chart';

// ...your component code and then...

<RoboChart
  id="GOOGLE_SPREADSHEET_ID"
  sheet="Sheet1"
  token="GENERATED_GOOGLE_API_KEY"
/>;

Quick setup in an app

yarn create react-app my-app
cd my-app
  • Install the package
yarn add @postlight/react-google-sheet-to-chart
  • Paste the following in App.js and replace GOOGLE_SPREADSHEET_ID and GENERATED_GOOGLE_API_KEY with appropriate values:
import React, { Component } from 'react';
import RoboChart from '@postlight/react-google-sheet-to-chart';
import './App.css';

const style = { width: '1200px', margin: '0 auto' };
class App extends Component {
  render() {
    return (
      <div style={style}>
        <RoboChart
          id="GOOGLE_SPREADSHEET_ID"
          sheet="Sheet1"
          token="GENERATED_GOOGLE_API_KEY"
        />
      </div>
    );
  }
}
export default App;
  • Start the project
yarn start

Optional props

  • start e.g. "A5" (start and end create a custom range for your data)
  • end e.g. "E15"
  • title This is the chart title, e.g. "My Accounts"
  • flipAxis default: {false}
  • startFrom default: {0}
  • stacked Use only with type bar, default: {false}
  • type default: "line", should be one of: "line", "bar", "horizontalBar", "pie", "semi-pie", "doughnut", "semi-doughnut"
  • colors e.g. {['#a1a1a1', '#434343', '#ff0055']}
  • xsuffix Add a suffix to x-Axis labels, e.g. " USD"
  • ysuffix Add a suffix to y-Axis labels

Example:

<RoboChart
  id="GOOGLE_SPREADSHEET_ID"
  sheet="Companies Values"
  token="GENERATED_GOOGLE_API_KEY"
  type="semi-pie"
  title="Companies values in Billion $"
  colors={['#a1a1a1', '#995500', '#990055', '#009955']}
/>

Robo Chart preview

Spreadsheet format

In order to successfuly generate a chart, the Spreadsheet should have Row titles, Column titles and Values, example:

Spreadsheet example

License

Licensed under either of the below, at your preference:

Contributing

Unless it is explicitly stated otherwise, any contribution intentionally submitted for inclusion in the work, as defined in the Apache-2.0 license, shall be dual licensed as above without any additional terms or conditions.


๐Ÿ”ฌ A Labs project from your friends at Postlight. Happy coding!

react-google-sheet-to-chart's People

Contributors

adampash avatar alexiakl avatar anthonychoueiri avatar aortbals avatar dependabot[bot] avatar fadihasrouni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-google-sheet-to-chart's Issues

Fail with the information about my google sheet is private

After I set up my app as described in the README, I got the following text and no sheet shown up:

It looks like your Spreadsheet is private, please change its access to Anyone with the link and then try again

But my google sheet opened its access: https://docs.google.com/spreadsheets/d/1tKMSI7XQ24WYWOAO7k8_qbdziULfRTQryrzSQHPGhjU

and I set the google sheet id using the middle string -- 1tKMSI7XQ24WYWOAO7k8_qbdziULfRTQryrzSQHPGhjU

Which part of above is wrong?

Title color?

Hi I'm wondering if there's a way to change the title color? That grey is really hard to see because my website is dark themed. If not, any plans to release that feature in the future?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.