Home > Articles > PHP graphs using google visualizations chart api

PHP graphs using google visualizations chart api

In this post i want to explain about php graphs or charts using google visualizations api. We can implement with less code. I have used this code in several projects which is developed. And it is free. We can integrate in admin section dashboard to more visible to admin.

php graphs using google visualizations chart api | Anil Labs

php graphs using google visualizations chart api | Anil Labs

Javscript Code

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Task');
        data.addColumn('number', 'Hours per Day');
        data.setValue(0, 0, 'Articles');
        data.setValue(0, 1, 15);
        data.setValue(1, 0, 'CMS');
        data.setValue(1, 1, 2);
        data.setValue(2, 0, 'PHP');
        data.setValue(2, 1, 25);
        data.setValue(3, 0, 'Shopping cart');
        data.setValue(3, 1, 2);
        data.setValue(4, 0, 'Database');
        data.setValue(4, 1, 7);
        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 450, height: 300, title: 'Anil Labs Posts'});

We can simple way to use this code.

HTML Code:


    <div id="chart_div"></div>
You may also like
Website uptime monitoring using PHP script
Understanding the basic need of MVC architecture
How to convert feeds to html using javascript and php
Multi-language support for web application with MySql and PHP

7 Responses

  1. Pingback : Share A Code » Blog Archive » PHP graphs using google chart api

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.