Skip to content

Commit

Permalink
Add error handling on graph when error in not countable series
Browse files Browse the repository at this point in the history
  • Loading branch information
luukverhoeven committed May 13, 2024
1 parent 45f1938 commit 370c2e3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions components/plot/line/graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

$components = cr_unserialize($report->components);
$graphs = $components['plot']['elements'];

if (!empty($graphs)) {
$series = [];
foreach ($graphs as $g) {
Expand All @@ -80,7 +79,6 @@
}

if ($g['id'] == $id) {

$min = optional_param('min', 0, PARAM_INT);
$max = optional_param('max', 0, PARAM_INT);
$abcise = optional_param('abcise', -1, PARAM_INT);
Expand All @@ -98,10 +96,16 @@
// Dataset definition.
$dataset = new pData;
$lastid = 0;

foreach ($series as $key => $val) {
$dataset->AddPoint($val['serie'], "Serie$key");
$dataset->AddAllSeries("Serie$key");
$lastid = $key;

try {
$dataset->AddPoint($val['serie'], "Serie$key");
$dataset->AddAllSeries();
$lastid = $key;
} catch (Throwable $e) {
continue;
}
}

if (!empty($abciselabel)) {
Expand All @@ -114,6 +118,11 @@

foreach ($series as $key => $val) {
$value = $val['name'];

if (!is_countable($value)) {
continue;
}

$ishebrew = preg_match("/[\xE0-\xFA]/", iconv("UTF-8", "ISO-8859-8", $value));
$fixedvalue = ($ishebrew == 1) ? $reportclass->utf8_strrev($value) : $value;
$dataset->SetSerieName($fixedvalue, "Serie$key");
Expand Down

0 comments on commit 370c2e3

Please sign in to comment.