npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-google-charts-temp

v0.1.10

Published

React Google Charts Wrapper with modifications that have not yet been pulled in by the main repository

Downloads

13

Readme

React Wrapper to Google Charts

A React JS wrapper to make it easy and fun to work with Google Charts.

Installation

npm install react-google-charts

Usage

The library can be used as a simple wrapper to the Google Charts API (Full Detailed Guide) :

 <Chart chartType = "LineChart" data = {this.state.data} options = {this.state.options}  width={"100%"} height={"300px"} graph_id = "linechart_graph"  /> 

Where data and options are the dataTable and options parameters of ChartWrapper

For convenience, you can optionally use the rows and columns parameters and the component will build the data table for the chart.


 <Chart chartType = "LineChart" width={"100%"} height={"300px"} rows = {this.state.rows} columns = {this.state.columns} options = {this.state.options}  graph_id = "linechart_graph"  />  

You can also show and hide columns in the chart by clicking on the legend if you set legend_toggle to true :

 <Chart  chartType = "ScatterChart" width={"100%"} height={"300px"} rows = {this.state.rows} columns = {this.state.columns} options = {this.state.options}  graph_id = "linechart_graph" legend_toggle={true} />  

Examples

The examples directory is the source code of : http://rakannimer.github.io/react-google-charts/

So check it out.

Quick Walkthrough

Initialize from array :


	componentDidMount: function() {

        var options = {
          	title: 'Age vs. Weight comparison',
          	hAxis: {title: 'Age', minValue: 0, maxValue: 15},
          	vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
        	legend: 'none'
        };

	    var data = [
        	['Age', 'Weight'],
        	[ 8,      12],
        	[ 4,      5.5],
        	[ 11,     14],
        	[ 4,      5],
        	[ 3,      3.5],
        	[ 6.5,    7]
        ];
      	this.setState({
        	'data' : data,
        	'options' : options
      });


	},
    render: function() {
        <Chart chartType = "ScatterChart" data = {this.state.data} options = {this.state.options} graph_id = "ScatterChart"  width={"100%"} height={"400px"}  legend_toggle={true} />

    }

Initialize using rows and columns :


	componentDidMount: function() {

        var options = {
          	title: 'Age vs. Weight comparison',
          	hAxis: {title: 'Age', minValue: 0, maxValue: 15},
          	vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
        	legend: 'none'
        };

	     var rows = [
        	[ 8,      12],
        	[ 4,      5.5],
        	[ 11,     14],
        	[ 4,      5],
        	[ 3,      3.5],
        	[ 6.5,    7]
        ];

        var columns = [
			{
				'type': 'number',
				'label' : 'Age'
			}, 
			{
				'type' : 'number',
				'label' : 'Weight'
			}
		];

      	this.setState({
        	'rows' : rows,
            'columns' : columns,
        	'options' : options
      });


	},
    render: function() {
        <Chart chartType = "ScatterChart" rows = {this.state.rows} columns = {this.state.columns} options = {this.state.options} graph_id = "ScatterChart"  width={"100%"} height={"400px"}  legend_toggle={true} />

    }

Listen to chart events

Set the chart-specific events you want to listen to and the corresponding callback. The callback has the component as an argument.



	componentDidMount: function() {
		var chart_events = [
        {
        	eventName : 'onmouseover',
            callback  : function(Chart) { 
                // Returns Chart so you can access props and  the ChartWrapper object from chart.wrapper
                console.log("mouseover the chart"); 
            }
        }
        ];

	},
    render: function() {
        <Chart chartType = "ScatterChart" rows = {this.state.rows} columns = {this.state.columns} options = {this.state.options} graph_id = "ScatterChart"  width={"100%"} height={"400px"} chartEvents = {chart_events} />

    }

Development

Fork and clone

npm install
gulp 

Will browserify and reactify the files, put them in the dist folder and serve them on localhost:8000 with livereload on changes

gulp dist

Will browserify and reactify the files, uglify them and put them in the dist folder.

Examples :

git clone https://github.com/RakanNimer/react-google-charts/
cd react-google-charts && cd examples
npm install
gulp