Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // This graphs data found in $filename and outputs as a png file.
- // Expected format:
- // timestamp\tusdSpent\tusdPortfolioValue\n
- $filename = "totalUsdLog.txt";
- require_once 'jpgraph/jpgraph.php';
- require_once 'jpgraph/jpgraph_line.php';
- require_once 'jpgraph/jpgraph_date.php';
- require_once 'jpgraph/jpgraph_scatter.php';
- $a = preg_split("/\n/", file_get_contents($filename));
- $xvalues1 = array();
- $yvalues1 = array();
- $yvalues2 = array();
- foreach ($a as $b) {
- if ($b) {
- $c = preg_split("/\t/", $b);
- $xvalues1[] = (float)$c[0];
- $yvalues1[] = (float)$c[1];
- $yvalues2[] = (float)$c[2];
- $yvalues3[] = (float)($c[2] - $c[1]);
- }
- }
- $graph = new Graph(750,400);
- $graph->SetScale("datlin");
- $graph->xaxis->scale->SetTimeAlign( DAYADJ_1 );
- $graph->xaxis->SetTextTickInterval(3600*24*7);
- $graph->xaxis->SetTextLabelInterval(7);
- $graph->yaxis->SetTitle("USD");
- //$graph->yaxis->SetLabelMargin(15);
- //$graph->img->SetMargin(40,40,40,40);
- $graph->title->Set("Cryptocurrency portfolio value");
- $graph->title->SetFont(FF_FONT1,FS_BOLD);
- // waarde
- $sp1 = new ScatterPlot($yvalues2,$xvalues1);
- $sp1->mark->SetWidth(2);
- // inleg
- $sp2 = new ScatterPlot($yvalues1,$xvalues1);
- $sp2->mark->SetFillColor("red");
- $sp2->mark->SetWidth(2);
- // winst/verlies
- $sp3 = new ScatterPlot($yvalues3,$xvalues1);
- $sp3->mark->SetFillColor("green");
- $graph->Add($sp1);
- $graph->Add($sp2);
- $graph->Add($sp3);
- $graph->Stroke();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment