<?php
require_once ('demo/src/jpgraph.php');
require_once ('demo/src/jpgraph_stock.php');
require_once ('demo/src/jpgraph_line.php');
require_once ('demo/src/jpgraph_bar.php');
$graph = new Graph(900,600);
$stock_color_list = array(
'pos_lcolor' => '#555555',
'pos_color' => '#5555ee',
'neg_lcolor' => '#555555',
'neg_color' => '#ee5555',
);
$color_list = array(
'#cc0055',
'#00cc55',
);
$stock_values = getDataValues('stock_values');
$line_values_list = getDataValues('line_values_list');
$dekidaka_values = getDataValues('dekidaka_values');
$x_labels = getDataValues('x_labels');
for ($lg_num = 0; $lg_num <= 1; $lg_num++) {
$line_plot_list[$lg_num] = new LinePlot($line_values_list[$lg_num]);
$line_plot_list[$lg_num]->SetColor($color_list[$lg_num]);
$line_plot_list[$lg_num]->SetWeight(2);
$line_plot_list[$lg_num]->SetBarCenter();
$line_plot_list[$lg_num]->SetLegend('平均'. intval($lg_num + 1));
$graph->add($line_plot_list[$lg_num]);
}
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->yaxis->HideTicks(true);
$graph->SetColor('#ffffff');
$p1 = new StockPlot($stock_values);
$p1->SetCenter();
$p1->SetWidth(4);
$p1->SetColor(
$stock_color_list['pos_lcolor'],
$stock_color_list['pos_color'],
$stock_color_list['neg_lcolor'],
$stock_color_list['neg_color']
);
$p1->HideEndLines(true);
$p1->SetLegend('株価A');
$gb = new LinePlot($dekidaka_values);
$gb->SetColor('#5555cc');
$gb->SetFillGradient('#aabbff@0.3','#ffffff');
$gb->SetLegend('出来高');
$graph->xaxis->SetFont(FF_PGOTHIC, FS_NORMAL, 8);
$graph->xaxis->SetTextLabelInterval(5);
$graph->xaxis->SetTickLabels($x_labels);
$graph->SetY2Scale('lin');
$graph->y2scale->SetAutoMin(min($dekidaka_values));
$graph->y2scale->SetAutoMax(600);
$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->SetFont(FF_PGOTHIC,FS_NORMAL,8);
$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);
$graph->Stroke();
/**
* グラフ化する各データ配列を取得する。
*/
function getDataValues($var_name) {
include('stock_data_values.php');
$var_name_list = array(
'stock_values' => true,
'line_values_list' => true,
'dekidaka_values' => true,
'x_labels' => true,
);
if (isset($var_name_list[$var_name])) {
return $$var_name;
}
return false;
}
?>