function lfGetGraphLine($arrResults, $keyname, $type, $xtitle, $ytitle, $sdate, $edate, $xincline) { $ret_path = ''; // 結果が0行以上ある場合のみグラフを生成する。 if (count($arrResults) > 0 && $this->install_GD) { // グラフの生成 $arrList = SC_Utils_Ex::sfArrKeyValue($arrResults, $keyname, 'total'); // 一時ファイル名の取得 $pngname = $this->lfGetGraphPng($type); $path = GRAPH_REALDIR . $pngname; // ラベル表示インターバルを求める $interval = intval(count($arrList) / 20); if ($interval < 1) { $interval = 1; } $objGraphLine = new SC_Graph_Line(); // 値のセット $objGraphLine->setData($arrList); $objGraphLine->setXLabel(array_keys($arrList)); // ラベル回転(日本語不可) if ($xincline == true) { $objGraphLine->setXLabelAngle(45); } // タイトルセット $objGraphLine->setXTitle($xtitle); $objGraphLine->setYTitle($ytitle); // メインタイトル作成 list($sy, $sm, $sd) = preg_split('|[/ ]|', $sdate); list($ey, $em, $ed) = preg_split('|[/ ]|', $edate); $start_date = t('c_T_ARG1/T_ARG2/T_ARG3_01', array('T_ARG1' => $sy, 'T_ARG2' => $sm, 'T_ARG3' => $sd)); $end_date = t('c_T_ARG1/T_ARG2/T_ARG3_01', array('T_ARG1' => $ey, 'T_ARG2' => $em, 'T_ARG3' => $ed)); $objGraphLine->drawTitle(t('c_Sales period: T_ARG1 - T_ARG2_01', array('T_ARG1' => $start_date, 'T_ARG2' => $end_date))); // グラフ描画 $objGraphLine->drawGraph(); // グラフの出力 if (DRAW_IMAGE) { $objGraphLine->outputGraph(); SC_Response_Ex::actionExit(); } // ファイルパスを返す $ret_path = GRAPH_URLPATH . $pngname; } return $ret_path; }
public function drawGraph(SC_Graph_Line $objGraphLine) { // グラフ背景を描画 $objGraphLine->drawYLine(); $objGraphLine->drawXLine(); for ($i = 0; $i < $objGraphLine->line_max; $i++) { // 折れ線グラフ描画 $objGraphLine->drawLine($i); // マークを描画 $objGraphLine->drawMark($i); // ラベルを描画 $line_no = $i; $arrData = $objGraphLine->arrDataList[$line_no]; $arrPointList = $objGraphLine->arrPointList[$line_no]; $count = count($arrPointList); for ($i2 = 0; $i2 < $count; $i2++) { $x = $arrPointList[$i2][0]; $y = $arrPointList[$i2][1]; $text_width = $objGraphLine->getTextWidth(number_format($arrData[$i2]), FONT_SIZE); $x_pos = $x - $text_width / 2; $y_pos = $y - FONT_SIZE - 5; $objGraphLine->setText(FONT_SIZE, $x_pos, $y_pos, number_format($arrData[$i2]), NULL, $objGraphLine->XLabelAngle); } } }