mikepsinn/php-highcharts-exporter

Export highcharts from PHP without running the NodeJS export server

1.0.4 2020-02-19 17:55 UTC

This package is auto-updated.

Last update: 2020-07-15 09:37:32 UTC


README

Generate Charts on Server Side using Highcharts without NodeJS

Latest Version on Packagist Build Status Quality Score Total Downloads

Install

Via Composer

$ composer require mikepsinn/php-highcharts-exporter

Add the following post-install-cmd to your composer.json file so that phantomjs is executable

  "scripts": {
    "post-install-cmd": [
      "chmod +x vendor/mikepsinn/php-highcharts-exporter/phantomjs"
    ]
  }

Usage

$export = new HighchartsExport(HighchartsExport::getConfigContents('test-basic-line'));
$export->setOutputFileName("test-chart.png"); // optional
$export->setImageType("png"); // optional
$path = $export->getFilePath(); // Absolute output file path on server
$data = $export->getImageData(); // Raw image data can be saved to file
$html = $export->getHtml(); // Inline this in any html file

Testing

$ composer test

Security

If you discover any security related issues, please email m@thinkbynumbers.org instead of using the issue tracker.

Credits

  • Mike P. Sinn
  • All Contributors
  • PhantomJS (phantomjs.org) is a headless WebKit scriptable with JavaScript.
  • Highcharts JS (highcharts.com) is a JavaScript charting library based on SVG, with fallbacks to VML and canvas for old browsers.

License

The MIT License (MIT). Please see License File for more information.

Development Notes

Test to Make Sure it Works With Known Good Options File

  • cd && ./phantomjs highcharts-convert.js -infile test-options.json -constr Chart -outfile images/test.png

Basic Command Line Test

  • ./phantomjs highcharts-convert.js -infile test-basic-line.json -constr Chart -outfile images/basic-line.png

Command Line Usage

  • Save your highchart config to images/options.json
  • cd && ./phantomjs highcharts-convert.js -infile images/options.json -constr Chart -outfile images/test.png

Tutorial