<?php
require_once ('demo/src/jpgraph.php');
require_once (
'demo/src/jpgraph_bar.php');
require_once (
'demo/src/jpgraph_line.php');

//折れ線グラフの色とデータ配列
$line_list = array(
  
=> array(
    
'color' => '#3333aa',
    
'values' => array(50,30,80,70,120,7090,80,50,90,50,30,80,70,120,7090,80,50,90),
  ),
  
=> array(
    
'color' => '#eecc00',
    
'values' => array(110,70,100,120,80,60,80,40,80,50,110,70,100,120,80,60,80,40,80,50),
  ),
);

//棒グラフのデータ配列とX軸に表示する値配列
$ydata  = array(180,200,180,190,165,170,190,140,170,123,180,210,180,190,165,170,190,140,170,123);
$x_labels = array('Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec''Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec', );

$graph = new Graph(600,300);    
$graph->SetScale("textlin"0250);
$graph->SetY2Scale("lin"0100);
$graph->SetMarginColor('white');
$graph->SetMargin(30,30,50,30);
$graph->SetFrame(false);

$graph->ygrid->SetColor('#aa9988');

$graph->xaxis->SetTickLabels($x_labels);
$graph->xaxis->HideTicks(truetrue);
$graph->xaxis->SetFont(FF_PGOTHIC,FS_NORMAL,10);
$graph->xaxis->SetColor('#ffffee');

$graph->yaxis->SetColor('#ffffee');
$graph->yaxis->scale->ticks->Set(50,50);
$graph->yaxis->setTextTickInterval(50,0);
$graph->yaxis->setTickSize(14,44);
$graph->yaxis->HideTicks(true);

$graph->y2axis->SetColor('#ffffee');
$graph->y2axis->HideTicks(true);

$bplot = new BarPlot($ydata);
$bplot->SetLegend('合計');
$bplot->SetWidth(0.5);
$bplot->SetFillGradient('#cc8844','#553300',GRAD_HOR);
$bplot->SetWeight(0);

$graph->Add($bplot);
$graph->SetBackgroundGradient('#151100''#663300'GRAD_HORBGRAD_FRAME);

$count count($line_list);
for (
$i 0$i $count$i++) {
  
$lplot_list[$i] = new LinePlot($line_list[$i]['values']);
  
$lplot_list[$i]->SetColor($line_list[$i]['color']);
  
$lplot_list[$i]->SetBarCenter();
  
$lplot_list[$i]->SetWeight(4);

  
$lplot_list[$i]->mark->SetType(MARK_FILLEDCIRCLE);
  
$lplot_list[$i]->mark->SetColor($line_list[$i]['color']);
  
$lplot_list[$i]->mark->SetFillColor($line_list[$i]['color']);
  
$lplot_list[$i]->mark->SetSize(1);
  
$lplot_list[$i]->SetLegend('製品'intval($i+1));

  
$graph->Add($lplot_list[$i]);
}

//凡例のデザイン調整
$graph->legend->SetFrameWeight(0);
$graph->legend->SetShadow(false);
$graph->legend->SetFont(FF_PGOTHIC,FS_NORMAL,10);
$graph->legend->SetColor('#ffffff');
$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.050.075);

//グラフタイトルの設定
$graph->title->SetFont(FF_PGOTHICFS_NORMAL,15);
$graph->subtitle->SetFont(FF_PGOTHICFS_NORMAL,12);
$graph->title->SetColor('#ffffff');
$graph->subtitle->SetColor('#ffffff');
$graph->title->Set('製品売り上げ推移');
$graph->subtitle->Set('— 合計と注目製品比率の推移 —');

$graph->Stroke();
?>