cmen / CMENGoogleChartsBundle

This Bundle provides a Twig extension and PHP objects to display Google charts in your Symfony application.
https://developers.google.com/chart/
Other
75 stars 21 forks source link

Fix call to constructor of ChartOptions #16

Closed nickveenhof closed 6 years ago

nickveenhof commented 6 years ago

[2018-01-12 13:32:47] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Cannot call constructor" at mypath/vendor/cmen/google-charts-bundle/GoogleCharts/Options/GaugeChart/GaugeChartOptions.php line 107 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Cannot call constructor at mypath/vendor/cmen/google-charts-bundle/GoogleCharts/Options/GaugeChart/GaugeChartOptions.php:107)"} []

So we need to add a constructor to avoid this issue.

Reproducible ->

$currentQuarterGauge = new GaugeChart();
$currentQuarterGauge->getData()->setArrayToDataTable(
  [
    ['Label', 'Value'],
    ['Quarter Target', (int)$report['totalSumOfDeals']['current']['total']],
  ]
);
$currentQuarterGauge->getOptions()->setWidth(200);
$currentQuarterGauge->getOptions()->setHeight(200);
$currentQuarterGauge->getOptions()->setGreenFrom(($quarterTarget/5)*4);
$currentQuarterGauge->getOptions()->setGreenTo($quarterTarget);
$currentQuarterGauge->getOptions()->setRedFrom($quarterTarget);
$currentQuarterGauge->getOptions()->setRedTo(($quarterTarget/5)*6);
$currentQuarterGauge->getOptions()->setMinorTicks(10);
$currentQuarterGauge->getOptions()->setMax(($quarterTarget/5)*6);
cmen commented 6 years ago

Thank you @nickveenhof