foreach ($data as $dat) { $yAxis[$id][($dat['day'] + 6) % 7] = $dat['value'] / 3600; } } $Plot = new Plot("weekday", 350, 190); $max = 0; foreach ($yAxis as $key => $data) { $Plot->Data[] = array('label' => $key, 'data' => $data); $max += max($data); } $Plot->setLegendAsTable(); $Plot->setMarginForGrid(5); $Plot->setXLabels($xAxis); $Plot->addYAxis(1, 'left'); $Plot->addYUnit(1, 'h'); $Plot->setYTicks(1, 1, 0); $Plot->setYLimits(1, 0, $max); $Plot->showBars(true); $Plot->stacked(); $error = true; foreach ($yAxis as $t) { foreach ($t as $e) { if ($e != "0") { $error = false; } } } if ($error === true) { $Plot->raiseError(__('No data available.')); } $Plot->outputJavaScript();