PHPackages                             marmark0/highcharts-php - 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. marmark0/highcharts-php

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

marmark0/highcharts-php
=======================

A php wrapper for highcharts and highstock javascript libraries (for PHP 8.2)

v3.1.1(2y ago)09MITPHPPHP &gt;=8.2

Since Sep 21Pushed 2y agoCompare

[ Source](https://github.com/MaRmARk0/HighchartsPHP)[ Packagist](https://packagist.org/packages/marmark0/highcharts-php)[ Docs](https://goncaloqueiros.net/highcharts.php)[ RSS](/packages/marmark0-highcharts-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

HighchartsPHP
=============

[](#highchartsphp)

HighchartsPHP is a PHP library that works as a wrapper for the **Highchart js** library () and it was built with flexibility and maintainability in mind. It isn't a simple port of the JavaScript library to PHP, it was designed in a way that mimics the JavaScript counterpart API, so that the developer only needs to learn one API.

The companion webpage can be found at

Note on this fork
-----------------

[](#note-on-this-fork)

This fork was created to add support for PHP 8.2 and to fix some bugs. It is not intended to be a long-term fork, but rather a temporary solution until the original author has time to update the library.

Setup
-----

[](#setup)

The recommended way to install HighchartsPHP is through [`Composer`](http://getcomposer.org). Just create a `composer.json` file and run the `php composer.phar install` command to install it:

```
{
    "require": {
        "marmark0/highcharts-php": "^3"
    }
}
```

Current package version supports PHP &gt;= 8.2. For compatibility with older PHP versions, use the 3.x tag.

Usage
-----

[](#usage)

### Simple

[](#simple)

You can create a highchart or highstock chart using one of the three js engine available (jQuery, mootools, and prototype), using the Highchart constructor.

```
//This will create a highchart chart with the jquery js engine
$chart = new Highchart();
```

```
//To create a highstock chart with the jquery js engine
$stockChart = new Highchart(Highchart::HIGHSTOCK);
```

```
//Create a highchart chart with the mootools js engine
$chartWithMootools = new Highchart(null, Highchart::ENGINE_MOOTOOLS);
```

Now that there's a valid `$chart` object the developer only needs to add elements to it as if it was writing them in JavaScript.

```
$chart->title = array('text' => 'Monthly Average Temperature', 'x' => -20);
or
$chart->title->text = 'Monthly Average Temperature';
$chart->title->x = -20;
```

You can also create simple arrays

```
$chart->series[] = array('name' => 'Tokyo', 'data' => array(7.0, 6.9, 9.5));
or
$chart->series[0] = array('name' => 'Tokyo', 'data' => array(7.0, 6.9, 9.5));
or
$chart->series[0]->name = 'Tokyo';
$chart->series[0]->data = array(7.0, 6.9, 9.5);
```

### Render

[](#render)

To get all the script necessary to render your chart you can use the `printScripts()` method:

```
$chart->printScripts();
```

Or if you don't want to directly echo the scripts and rather the function to return the script string:

```
$chart->printScripts(true);
```

And finally to render the chart object use the `render()` method:

```
echo $chart->render("chart");
```

The first (optional) argument passed to render method is the var name to be used by JavaScript and the second (optional) argument is the callback to be passed to the `Highcharts.Chart` method. The third and last (optional) argument flags that you want your script already wrapped around HTML script tags.

Its also possible to render the chart options only by calling the `renderOptions()` method. Useful for times where the chart is used inside a `$.getJson` call for example

```
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=range.json&callback=?', function(data) {
    $('#container').highcharts()});
```

### Javascript expressions

[](#javascript-expressions)

If one of the chart options must be a JavaScript expression, you can't assign a simple string to it, otherwise it will be printed as a simple JavaScript string also. For that you must use the special `HighchartJsExpr` object:

```
$chart->tooltip->formatter = new HighchartJsExpr("function() {
        return '' + this.series.name + this.x + ': ' + this.y + '°C';
    }"
);
```

### Empty javascript object {}

[](#empty-javascript-object-)

If you wish to render an empty javascript object `{}`, just assign the variable you want with `new stdClass()`

### Extra scripts

[](#extra-scripts)

To manually include a script for render use the `addExtraScript` function:

```
$chart->addExtraScript('export', 'http://code.highcharts.com/modules/', 'exporting.js');
```

To include an extra script use the key that's on the config file or that was given manually via `addExtraScript`

```
$chart->includeExtraScripts(array('export'));
```

To include more than one script just add it to the array

```
$chart->includeExtraScripts(array('export', 'highcharts-more'));
```

If no arguments are passed, it will include all the extra scripts

```
$chart->includeExtraScripts();
```

If you want to add any extra script to the default config file, feel free to open a PR. Here is the list of the current extra scripts available:

- [Highcharts 3.0 charts](http://www.highcharts.com/component/content/article/2-articles/news/54-highcharts-3-0-released/)
- [Exporting module](http://www.highcharts.com/docs/export-module/export-module-overview/)

### Use new Highcharts 3.0 charts

[](#use-new-highcharts-30-charts)

Highcharts 3.0 introduced a new set of charts that require an additional javascript file `highcharts-more.js`.

To include this extra script you need to call the `includeExtraScripts` method with the **highcharts-more** key.

```
$chart = new Highchart();
$chart->includeExtraScripts(array('highcharts-more'));
```

### Render only some options

[](#render-only-some-options)

If you need to render a small portion of options, you can use the ` HighchartOptionRenderer::render($options)` method.

A good example of this can be found at [clock demo](https://github.com/ghunti/HighchartsPHP/blob/master/demos/highcharts/more_chart_types/clock.php)

```
$backgroundOptions = new HighchartOption();
$backgroundOptions->radialGradient = array(
    'cx' => 0.5,
    'cy' => -0.4,
    'r' => 1.9
);
...
$chart->pane->background[] = array(
    new stdClass(),
    array('backgroundColor' => new HighchartJsExpr('Highcharts.svg ? ' .
        HighchartOptionRenderer::render($backgroundOptions) . ' : null')
    )
);
```

This way it is possible to include option rendering inside a javascript expression

### Set up a general configuration

[](#set-up-a-general-configuration)

There are cases where a configuration is not created only for a chart, but for all the charts on the page ([lang](http://api.highcharts.com/highcharts#lang) and [global](http://api.highcharts.com/highcharts#global)) are examples of this.

To set a general option, just create a new `HighchartOption` (not chart) and send it to `Highchart::setOptions()` method.

The `Highchart::setOptions()` **must be placed before the chart render**

```
$option = new HighchartOption();
$option->global->useUTC = false;
echo Highchart::setOptions($option);
```

### Themes

[](#themes)

Theme creation follows the same process for a general option. You create a new `HighchartOption` object, use it has if it was a chart and then call `Highchart::setOptions()` method.

```
$theme = new HighchartOption();
//Code your theme as if this was a chart
$theme->colors = array('#058DC7', '#50B432', '#ED561B');
...
echo Highchart::setOptions($theme);
```

### Configuration

[](#configuration)

By default HighchartsPHP library comes with configurations to work out of the box. If you wish to change the path of any js library loaded, have a look at `src/config.php`. In case you need to change some of this values you should use the `setConfigurations` method:

```
$chart = new Highchart();
$chart->setConfigurations(
    array(
        'jQuery' => array(
            'name' => 'anotherName'
        )
    )
);
```

Demos
-----

[](#demos)

All the Highcharts and Highstocks live demos present on  under the demo gallery were reproduced using this library and you can find them on the demos folder or see a live example on

Tests
-----

[](#tests)

You can run the unit tests with the following command:

```
$ cd path/to/HighchartsPHP/
$ composer install
$ vendor/bin/phpunit
```

License
-------

[](#license)

The HighchartsPHP package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.7% 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 ~0 days

Total

2

Last Release

963d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e9933f4e420ed85b36a25a3d96eecbb61ab696aeadb2842c2245051b760dede?d=identicon)[MaRmARk0](/maintainers/MaRmARk0)

---

Top Contributors

[![ghunti](https://avatars.githubusercontent.com/u/392038?v=4)](https://github.com/ghunti "ghunti (61 commits)")[![jfloff](https://avatars.githubusercontent.com/u/1867656?v=4)](https://github.com/jfloff "jfloff (4 commits)")[![clrfrks](https://avatars.githubusercontent.com/u/15800103?v=4)](https://github.com/clrfrks "clrfrks (1 commits)")[![Gugiman](https://avatars.githubusercontent.com/u/5836639?v=4)](https://github.com/Gugiman "Gugiman (1 commits)")[![mbrown-lw](https://avatars.githubusercontent.com/u/243889486?v=4)](https://github.com/mbrown-lw "mbrown-lw (1 commits)")[![newk](https://avatars.githubusercontent.com/u/3924241?v=4)](https://github.com/newk "newk (1 commits)")[![arsenyg](https://avatars.githubusercontent.com/u/5833371?v=4)](https://github.com/arsenyg "arsenyg (1 commits)")[![rolandsusans](https://avatars.githubusercontent.com/u/6154604?v=4)](https://github.com/rolandsusans "rolandsusans (1 commits)")[![bencurio](https://avatars.githubusercontent.com/u/7604637?v=4)](https://github.com/bencurio "bencurio (1 commits)")

---

Tags

phpjavascripthighchartschartshighstock

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marmark0-highcharts-php/health.svg)

```
[![Health](https://phpackages.com/badges/marmark0-highcharts-php/health.svg)](https://phpackages.com/packages/marmark0-highcharts-php)
```

###  Alternatives

[ghunti/highcharts-php

A php wrapper for highcharts and highstock javascript libraries

3772.3M5](/packages/ghunti-highcharts-php)[hisune/echarts-php

A php wrapper for echarts javascript libraries

327201.9k5](/packages/hisune-echarts-php)

PHPackages © 2026

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