Coder Social home page Coder Social logo

yii2-googlecharts's Introduction

Google Charts widget for Yii2

A wrapper for Google's charts API (see https://developers.google.com/chart/) to use it with Yii2.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require "fruppel/yii2-googlecharts" "*"

or add

"fruppel/yii2-googlecharts" : "*"

to the require section of your application's composer.json file.

Usage

Example 1: 3D PieChart with data in DataTable format

demo

<?php
use \fruppel\googlecharts\GoogleCharts;
...
?>

<?= GoogleCharts::widget([
	'id' => 'my-id',
	'visualization' => 'PieChart',
	'data' => [
		'cols' => [
            [
	            'id' => 'topping',
                'label' => 'Topping',
				'type' => 'string'
            ],
	        [
		        'id' => 'slices',
		        'label' => 'Slices',
		        'type' => 'number'
	        ]
        ],
        'rows' => [
	        [
		        'c' => [
					['v' => 'Mushrooms'],
			        ['v' => 3]
		        ],
	        ],
	        [
		        'c' => [
			        ['v' => 'Onions'],
			        ['v' => 1]
		        ]
	        ],
	        [
		        'c' => [
			        ['v' => 'Olives'],
			        ['v' => 1]
		        ]
	        ],
	        [
		        'c' => [
			        ['v' => 'Zucchini'],
                    ['v' => 1]
		        ]
	        ],
	        [
		        'c' => [
			        ['v' => 'Pepperoni'],
                    ['v' => 2]
		        ]
	        ],
        ]
    ],
    'options' => [
        'title' => 'How Much Pizza I Ate Last Night',
        'width' => 400,
        'height' => 300,
        'is3D' => true,
    ],
    'responsive' => true,
]) ?>

Example 2: AreaChart with data array (will be converted to DataTable)

demo2

<?php
use \fruppel\googlecharts\GoogleCharts;
...
<?= GoogleCharts::widget([
	'visualization' => 'AreaChart',
		'options' => [
			'title' => 'Company Performance',
			'hAxis' => [
				'title' => 'Year',
				'titleTextStyle' => [
					'color' => '#333'
				]
			],
			'vAxis' => [
				'minValue' => 0
			]
		],
	'dataArray' => [
	        ['Year', 'Sales', 'Expenses'],
	        ['2013',  1000,      400],
	        ['2014',  1170,      460],
	        ['2015',  660,       1120],
	        ['2016',  1030,      540]
	]
])
?>

yii2-googlecharts's People

Contributors

fruppel avatar

Watchers

 avatar

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.