Last active
December 28, 2015 21:09
-
-
Save snoek09/7562656 to your computer and use it in GitHub Desktop.
Highcharts image export with PhantomJS. More info on: http://www.highcharts.com/component/content/article/2-news/56-improved-image-export-with-phantomjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function action_save_chart() { | |
$string = <<<EOD | |
{"infile":"{credits:{enabled:false},xAxis:{categories:['Jan','Feb','Mar']},series:[{data:[29.9,71.5,106.4]}]}"} | |
EOD; | |
$ch = curl_init('http://127.0.0.1:3003'); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($string)) | |
); | |
$base64string = curl_exec($ch); | |
file_put_contents('img.png', base64_decode($base64string)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment