<?php
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_bar.php');
function toFahrenheit($aVal) {
return round(($aVal*9/5)+32,2);
}
function toCelcius($aVal) {
return round(($aVal-32)*5/9,2);
}
$datay =array(2,3,8,19,7,17,6,22);
$graph = new Graph(400,280);
$graph->SetMargin(50,60,40,45);
$graph->SetMarginColor('white');
$graph->SetScale("intlin");
$graph->SetY2Scale("lin");
$graph->title->Set('Synchronized Y & Y2 scales');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->xaxis->title->Set('Measurement');
$graph->xaxis->title->SetMargin(5);
$graph->xaxis->title->SetFont(FF_ARIAL,FS_NORMAL,11);
$lplot = new LinePlot($datay);
$graph->yaxis->title->Set('Celcius (C)');
$graph->yaxis->title->SetMargin(5);
$graph->yaxis->title->SetFont(FF_ARIAL,FS_NORMAL,11);
$graph->Add($lplot);
$l2plot = new LinePlot($datay);
$l2plot->SetWeight(0);
$graph->y2axis->title->Set('Fahrenheit (F)');
$graph->y2axis->title->SetMargin(5);
$graph->y2axis->title->SetFont(FF_ARIAL,FS_NORMAL,11);
$graph->y2axis->SetLabelFormatCallback('toFahrenheit');
$graph->y2axis->SetColor('navy');
$graph->AddY2($l2plot);
$graph->Stroke();
?> |