Upgrade chart rendering support to be composer based

This allow to get rid of manual class loading and have simpler
usage of the library.
This commit is contained in:
Adrien Crivelli
2017-10-29 01:58:42 +09:00
parent dc9f4327b6
commit 782b4e4fae
14 changed files with 246 additions and 218 deletions
+3 -11
View File
@@ -6,16 +6,7 @@ use PhpOffice\PhpSpreadsheet\Settings;
require __DIR__ . '/../Header.php';
// Change these values to select the Rendering library that you wish to use
// and its directory location on your server
$rendererName = Settings::CHART_RENDERER_JPGRAPH;
$rendererLibrary = 'jpgraph3.5.0b1/src/';
$rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary;
if (!Settings::setChartRenderer($rendererName, $rendererLibraryPath)) {
$helper->log('NOTICE: Please set the $rendererName and $rendererLibraryPath values at the top of this script as appropriate for your directory structure');
return;
}
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
$inputFileType = 'Xlsx';
$inputFileNames = __DIR__ . '/../templates/32readwrite*[0-9].xlsx';
@@ -62,13 +53,14 @@ foreach ($inputFileNames as $inputFileName) {
}
$helper->log(' ' . $chartName . ' - ' . $caption);
$jpegFile = $helper->getFilename('35-' . $inputFileNameShort, 'jpg');
$jpegFile = $helper->getFilename('35-' . $inputFileNameShort, 'png');
if (file_exists($jpegFile)) {
unlink($jpegFile);
}
try {
$chart->render($jpegFile);
$helper->log('Rendered image: ' . $jpegFile);
} catch (Exception $e) {
$helper->log('Error rendering chart: ' . $e->getMessage());
}