PHPackages                             sportlog/google-charts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sportlog/google-charts

ActiveProject[Utility &amp; Helpers](/categories/utility)

sportlog/google-charts
======================

PHP Wrapper for Google charts

v1.0.3(3y ago)11.1k↓22.2%MITPHPPHP &gt;=8.1CI passing

Since Aug 28Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/sportlog/google-charts)[ Packagist](https://packagist.org/packages/sportlog/google-charts)[ RSS](/packages/sportlog-google-charts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Google-charts
=============

[](#google-charts)

PHP Wrapper for Google charts library ()

Features:

- Typed chart options. You can use intellisense to set any chart option.
- Supported charts: Annotation, Area, Bar, Bubble, Calendar, Candlestick, Column, Combo, Gantt, Gauge, Geo, Histogram, Line, Map, Org, Pie, Scatter, SteppedArea, Table, Timeline, TreeMap and WordTree.
- Draw charts in either Classic or Material design. Material design is restricted to Bar, Column, Line and ScatterChart. (still in Beta from Google)

Install using composer
======================

[](#install-using-composer)

You can install sportlog/google-charts by using composer:

```
$ composer require sportlog/google-charts

```

Minimum PHP version required is 8.1.

How to use
==========

[](#how-to-use)

1. Create the chart service
---------------------------

[](#1-create-the-chart-service)

Create the chart service instance. You can optionally provide two parameters:

- Settings: some charts require a mapsApiKey to work
- ScriptNonceProvider: The chart service needs to load the Google Charts API (). If you're using [CSP](https://en.wikipedia.org/wiki/Content_Security_Policy) you may want to provide a nonce for the script.

```
$chartService = new ChartService();
```

Preferably use DI to for the service!

2. Create the data
------------------

[](#2-create-the-data)

Create a datatable and add columns and rows:

```
$data = new DataTable();
$data->addColumn(new Column(ColumnType::String, 'Task'));
$data->addColumn(new Column(ColumnType::Number, 'Hours per Day'));

// add the rows: you can also use addRows to add an array of rows
$data->addRow(['Work',     11]);
$data->addRow(['Eat',      2]);
$data->addRow(['Commute',  2]);
$data->addRow(['Watch TV', 2]);
$data->addRow(['Sleep',    7]);
```

Alternatively you can also use the factory function which automatically creates the columns by inferring their type from the first data row. This leads to the same result as above:

```
$data = DataTable::fromArray(
    [
        ['Task', 'Hours per Day'],
        ['Work',     11],
        ['Eat',      2],
        ['Commute',  2],
        ['Watch TV', 2],
        ['Sleep',    7]
    ]
);
```

3. Create the Chart
-------------------

[](#3-create-the-chart)

Create the chart by using the factory functions on the ChartService.

```
// pass a unique id to the chart; you will need it to draw it
$chart = $chartService->createPieChart('dailyActivities', $data);
// set options by using intellisense; for documentation see Google-Charts Homepage
$chart->options->title = 'My Daily Activities';
$chart->options->pieHole = 0.4;
$chart->options->width = 900;
$chart->options->height = 500;
```

4. Draw the chart
-----------------

[](#4-draw-the-chart)

Use the ChartService to render your chart. If you're using a template engine (like Latte, Twig, ...) you should add a filter for this.

```
// draw the chart; you can omit the id if you want to draw all charts
echo $chartService->render('dailyActivities');
```

Samples
=======

[](#samples)

You can find at least one sample for each chart in the samples folder.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance52

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Total

4

Last Release

1156d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19c308a0b06020a0127f8b3ae88dd1ec1d168691bb053db3fc4fff011333067d?d=identicon)[sportlog](/maintainers/sportlog)

---

Top Contributors

[![sportlog](https://avatars.githubusercontent.com/u/59764376?v=4)](https://github.com/sportlog "sportlog (84 commits)")

---

Tags

googlegraphscharts

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sportlog-google-charts/health.svg)

```
[![Health](https://phpackages.com/badges/sportlog-google-charts/health.svg)](https://phpackages.com/packages/sportlog-google-charts)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[khill/lavacharts

PHP wrapper library for the Google Chart API

6202.0M2](/packages/khill-lavacharts)[spatie/laravel-google-calendar

Manage events on a Google Calendar

1.4k1.5M21](/packages/spatie-laravel-google-calendar)[icehouse-ventures/laravel-chartjs

Simple package to facilitate and automate the use of charts in Laravel using the Chart.js library

117186.4k](/packages/icehouse-ventures-laravel-chartjs)[emcconville/google-map-polyline-encoding-tool

A simple class to handle polyline-encoding for Google Maps

1572.3M2](/packages/emcconville-google-map-polyline-encoding-tool)[cmen/google-charts-bundle

This Bundle provides a Twig extension and PHP objects to display Google charts in your Symfony application.

76844.8k2](/packages/cmen-google-charts-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
