PHPackages                             ianw/quickchart - 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. [Image &amp; Media](/categories/media)
4. /
5. ianw/quickchart

ActiveLibrary[Image &amp; Media](/categories/media)

ianw/quickchart
===============

QuickChart chart API

v1.3.2(2y ago)46638.6k—4.3%20MITPHPPHP &gt;=5.3.0

Since Nov 21Pushed 2y ago3 watchersCompare

[ Source](https://github.com/typpo/quickchart-php)[ Packagist](https://packagist.org/packages/ianw/quickchart)[ Docs](http://github.com/typpo/quickchart-php)[ RSS](/packages/ianw-quickchart/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (14)Used By (0)

quickchart-php
==============

[](#quickchart-php)

[![Packagist VERSION](https://camo.githubusercontent.com/742e09545f1085cd47563d47002012e0aad4ed7e671fe95cf25585459cf02088/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69616e772f717569636b63686172742e7376673f7374796c653d666c6174)](https://packagist.org/packages/ianw/quickchart)

A PHP client for the [quickchart.io](https://quickchart.io/) chart image API.

Installation
============

[](#installation)

Use the `QuickChart.php` library in this project, or [install from packagist](https://packagist.org/packages/ianw/quickchart).

```
composer require ianw/quickchart

```

Usage
=====

[](#usage)

This library provides a `QuickChart` class. Import and instantiate it. Then set properties on it and specify a [Chart.js](https://chartjs.org) config:

```
$chart = new QuickChart(array(
  'width' => 500,
  'height' => 300
));

$chart->setConfig('{
  type: "bar",
  data: {
    labels: ["Hello world", "Test"],
    datasets: [{
      label: "Foo",
      data: [1, 2]
    }]
  }
}');
```

Use `getUrl()` on your QuickChart object to get the encoded URL that renders your chart:

```
echo $chart->getUrl();
// https://quickchart.io/chart?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22Hello+world%22%2C%22Test%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Foo%22%2C%22data%22%3A%5B1%2C2%5D%7D%5D%7D%7D&w=500&h=300
```

If you have a long or complicated chart, use `getShortUrl()` to get a fixed-length URL using the quickchart.io web service (note that these URLs only persist for a short time unless you have a subscription):

```
echo $chart->getShortUrl();
// https://quickchart.io/chart/render/f-a1d3e804-dfea-442c-88b0-9801b9808401
```

The URLs will render an image of a chart:

[![](https://camo.githubusercontent.com/35c5ae135fbd096ba6bb6239184fa71ce660863d5eff75c8c6708352c04ead26/68747470733a2f2f717569636b63686172742e696f2f63686172743f633d253742253232747970652532322533412b2532326261722532322532432b253232646174612532322533412b2537422532326c6162656c732532322533412b25354225323248656c6c6f2b776f726c642532322532432b253232546573742532322535442532432b25323264617461736574732532322533412b2535422537422532326c6162656c2532322533412b253232466f6f2532322532432b253232646174612532322533412b253542312532432b3225354425374425354425374425374426773d36303026683d33303026626b673d25323366666666666626646576696365506978656c526174696f3d322e3026663d706e67)](https://camo.githubusercontent.com/35c5ae135fbd096ba6bb6239184fa71ce660863d5eff75c8c6708352c04ead26/68747470733a2f2f717569636b63686172742e696f2f63686172743f633d253742253232747970652532322533412b2532326261722532322532432b253232646174612532322533412b2537422532326c6162656c732532322533412b25354225323248656c6c6f2b776f726c642532322532432b253232546573742532322535442532432b25323264617461736574732532322533412b2535422537422532326c6162656c2532322533412b253232466f6f2532322532432b253232646174612532322533412b253542312532432b3225354425374425354425374425374426773d36303026683d33303026626b673d25323366666666666626646576696365506978656c526174696f3d322e3026663d706e67)

Creating the chart object
-------------------------

[](#creating-the-chart-object)

The `QuickChart` class constructor accepts an array containing the following keys. All are optional and can be set after object creation:

### config: array or string

[](#config-array-or-string)

The actual Chart.js chart configuration.

### width: int

[](#width-int)

Width of the chart image in pixels. Defaults to 500

### height: int

[](#height-int)

Height of the chart image in pixels. Defaults to 300

### format: string

[](#format-string)

Format of the chart. Defaults to png.

### backgroundColor: string

[](#backgroundcolor-string)

The background color of the chart. Any valid HTML color works. Defaults to #ffffff (white). Also takes rgb, rgba, and hsl values.

### devicePixelRatio: float

[](#devicepixelratio-float)

The device pixel ratio of the chart. This will multiply the number of pixels by the value. This is usually used for retina displays. Defaults to 1.0.

### version: string

[](#version-string)

The Chart.js version to use. See [documentation](https://quickchart.io/documentation/#parameters) for supported versions.

### apiKey: string

[](#apikey-string)

Your QuickChart API key, if you have one.

Setting properties
------------------

[](#setting-properties)

Each option above has an associated function call that you can invoke on your `QuickChart` object:

- `setConfig($config)`
- `setWidth($width)`
- `setHeight($height)`
- `setFormat($format)`
- `setBackgroundColor($backgroundColor)`
- `setDevicePixelRatio($devicePixelRatio)`
- `setVersion($version)`
- `setApiKey($apiKey)`

Getting URLs
------------

[](#getting-urls)

There are two ways to get a URL for your chart object.

### getUrl: string

[](#geturl-string)

Returns a URL that will display the chart image when loaded.

### getShortUrl: string

[](#getshorturl-string)

Uses the quickchart.io web service to create a fixed-length chart URL that displays the chart image. Returns a URL such as `https://quickchart.io/chart/render/f-a1d3e804-dfea-442c-88b0-9801b9808401`.

Note that short URLs expire after a few days for users of the free service. You can [subscribe](https://quickchart.io/pricing/) to keep them around longer.

Other outputs
-------------

[](#other-outputs)

### toBinary: binary string

[](#tobinary-binary-string)

Returns a binary string representing the chart image

### toFile($path: string)

[](#tofilepath-string)

Write the image to a file

For example:

```
$chart->toFile('/tmp/myfile.png')
```

More examples
-------------

[](#more-examples)

Checkout the `examples` directory to see other usage.

Troubleshooting
---------------

[](#troubleshooting)

**PHP5 users**: This package requires curl and json modules.

**sslv3 handshake alert failure**: You are using an outdated version of `curl`. Please upgrade curl on your machine.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% 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 ~95 days

Recently: every ~128 days

Total

13

Last Release

865d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b46b6420a3ee2d2594b7d33eb2bf16b48d3a3484b61a9ad6eceda70343ede57b?d=identicon)[ianww](/maintainers/ianww)

---

Top Contributors

[![typpo](https://avatars.githubusercontent.com/u/310310?v=4)](https://github.com/typpo "typpo (20 commits)")[![arnaudgoulpeau](https://avatars.githubusercontent.com/u/14837692?v=4)](https://github.com/arnaudgoulpeau "arnaudgoulpeau (1 commits)")[![kyletaylored](https://avatars.githubusercontent.com/u/1759794?v=4)](https://github.com/kyletaylored "kyletaylored (1 commits)")[![ammiranda](https://avatars.githubusercontent.com/u/4405732?v=4)](https://github.com/ammiranda "ammiranda (1 commits)")[![MrGabriCavi](https://avatars.githubusercontent.com/u/1543667?v=4)](https://github.com/MrGabriCavi "MrGabriCavi (1 commits)")[![vdumontier](https://avatars.githubusercontent.com/u/325251?v=4)](https://github.com/vdumontier "vdumontier (1 commits)")[![MarcosBL](https://avatars.githubusercontent.com/u/389801?v=4)](https://github.com/MarcosBL "MarcosBL (1 commits)")

---

Tags

chart-apiimage-chart-apiphp-chartimagechartchartsbar-chartline-chartchart-api

### Embed Badge

![Health badge](/badges/ianw-quickchart/health.svg)

```
[![Health](https://phpackages.com/badges/ianw-quickchart/health.svg)](https://phpackages.com/packages/ianw-quickchart)
```

###  Alternatives

[intervention/image

PHP Image Processing

14.3k194.3M2.2k](/packages/intervention-image)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[liip/imagine-bundle

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

1.7k38.3M217](/packages/liip-imagine-bundle)[spatie/image

Manipulate images with an expressive API

1.4k54.4M138](/packages/spatie-image)[intervention/image-laravel

Laravel Integration of Intervention Image

1536.5M102](/packages/intervention-image-laravel)[intervention/gif

PHP GIF Encoder/Decoder

5720.3M9](/packages/intervention-gif)

PHPackages © 2026

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