public function SetGraph($first_curr, $second_curr) { $updates = new UpdatesController(); $values = $updates->OHLC($first_curr, $second_curr); $datay = array(); $days = array(); $datav = array(); $alts = array(); $targ = array(); if (count($values['result']) <= 1) { $datay = array(0, 0, 0, 0, 0, 0, 0, 0); $datav = array(0, 0); $days = array('N', 'N'); } $i = 0; foreach ($values['result'] as $result) { array_push($datay, $result['Open']); array_push($datay, $result['High']); array_push($datay, $result['Low']); array_push($datay, $result['Close']); array_push($datav, $result['Volume']); array_push($alts, $result['Volume']); array_push($targ, "#"); if ($i % 2) { array_push($days, $result['_id']['day'] . "/" . $result['_id']['month'] . "\n " . $result['_id']['hour'] . "h"); } else { array_push($days, ""); } $i++; } $graph = new Graph(750, 300); $stock_color_list = array('pos_lcolor' => '#555555', 'pos_color' => '#5555ee', 'neg_lcolor' => '#555555', 'neg_color' => '#ee5555'); $color_list = array('#cc0055', '#00cc55'); $graph->SetScale("textlin"); $graph->SetFrame(true); $graph->yaxis->HideTicks(true); $graph->SetColor('#00fff'); $graph->tabtitle->Set($first_curr . " / " . $second_curr . " - Volume"); $p1 = new StockPlot($datay); $p1->SetCenter(); $p1->SetWidth(6); $p1->SetColor($stock_color_list['pos_lcolor'], $stock_color_list['pos_color'], $stock_color_list['neg_lcolor'], $stock_color_list['neg_color']); $p1->HideEndLines(false); $p1->SetCSIMTargets($targ, $alts); $p1->SetLegend($first_curr . " / " . $second_curr); $gb = new BarPlot($datav); $gb->SetCSIMTargets($targ, $alts); $gb->SetFillColor('#ffffdd'); $gb->SetWidth(6); $gb->SetLegend('Volume'); $graph->xaxis->SetTickLabels($days); $graph->SetY2Scale('lin'); $graph->y2scale->SetAutoMin(min($datav) - 0.01); $graph->y2scale->SetAutoMax(max($datav) + 1); $graph->y2axis->HideTicks(true); $graph->Add($p1); $graph->AddY2($gb); $graph->SetMargin(50, 50, 50, 30); $graph->legend->SetFrameWeight(0); $graph->legend->SetShadow(false); $graph->legend->SetFillColor('#aaaaaa@0.7'); $graph->legend->SetLineSpacing(8); $graph->legend->SetMarkAbsSize(8); $graph->legend->SetVColMargin(10); $graph->legend->SetHColMargin(15); $graph->legend->SetLeftMargin(15); $graph->legend->SetPos(0.08, 0.09); $image = $graph->Stroke(_IMG_HANDLER); $fileName = LITHIUM_APP_PATH . '/webroot/documents/' . $first_curr . "_" . $second_curr . ".png"; $graph->img->Stream($fileName); }