сам скрипт:
<?php
error_reporting(0);
include 'pChart/pChart/pData.class';
include 'pChart/pChart/pChart.class';
$d = getdata(dirname(__FILE__).DIRECTORY_SEPARATOR.'rts.txt');
$d['date'] = array_reverse($d['date']);
$d['rts'] = array_reverse($d['rts']);
$d['rts2'] = array_reverse($d['rts2']);
$DataSet = new pData;
$DataSet->AddPoint($d['rts'],"Serie1");
$DataSet->AddPoint($d['rts2'],"Serie2");
$DataSet->AddPoint($d['date'],"Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetSerieName(mb_convert_encoding(
"Индекс РТС",'utf-8','windows-1251'), "Serie1");
$DataSet->SetSerieName(mb_convert_encoding(
"Индекс РТС2",'utf-8','windows-1251'), "Serie2");
$graph = new pChart(1000,500);
$graph->setFontProperties("Fonts/tahoma.ttf",10);
$graph->setGraphArea(85,30,950,400);
$graph->drawGraphArea(255,255,255,true);
$graph->drawScale($DataSet->GetData(),
$DataSet->GetDataDescription(),
SCALE_NORMAL,150,150,150,true,0,2,false,
1);
$graph->drawGrid(4,true,230,230,230,50);
$graph->drawLineGraph($DataSet->GetData(),
$DataSet->GetDataDescription());
$graph->setFontProperties("pChart/Fonts/tahoma.ttf",10);
$graph->drawTitle(480,22,
mb_convert_encoding("Индексы РТС",
'utf-8','windows-1251'),
50,50,50,-1,-1,true);
$graph->Stroke();
@return
function getdata($file)
{
if (file_exists($file)) {
$lines = file($file);
$data = array('date' => array(), 'rts' => array(),
'rts2' => array());
foreach ($lines as $line) {
$tmp = explode(' ', trim($line));
$data['date'][] = $tmp[0];
$data['rts'][] = trim($tmp[1]);
$data['rts2'][] = trim($tmp[2]);
}
return $data;
} else {
return false;
}
}
?>