Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // content="text/plain; charset=utf-8"
- require_once ('jpgraph/jpgraph.php');
- require_once ('jpgraph/jpgraph_line.php');
- function scaleNumber($val, $in_min, $in_max, $out_min, $out_max) {
- return intval(($val - $in_min) * ($out_max - $out_min) / ($in_max - $in_min) + $out_min);
- }
- $l1datay = [];
- $datax = [];
- $maxData = 266;
- for($i = 0; $i <= $maxData; ++$i) {
- // demodaten erzeugen
- $l1datay[] = $i % 35 == 0 ? rand(0, 200) : rand(10,100);
- // label erzeugen und auf interval [0,25] runterrechnen.
- $datax[] = scaleNumber($i, 0, $maxData, 0, 24);
- }
- $l1datay[$maxData] = 200; // letzten Datenpunkt als Ausreißer um zu sehen ob er noch im Bild ist
- // Create the graph.
- $graph = new Graph(800,400);
- $graph->clearTheme();
- $graph->SetScale("textlin");
- // Label nur alle /24 anzeigen
- $graph->xaxis->SetTextLabelInterval(266/24);
- // Label array setzen
- $graph->xaxis->SetTickLabels($datax);
- // Create the linear error plot
- $l1plot=new LinePlot($l1datay);
- $l1plot->SetColor("red");
- $l1plot->SetWeight(2);
- $l1plot->SetLegend("Prediction");
- //Center the line plot in the center of the bars
- $l1plot->SetBarCenter();
- // Add the plots to t'he graph
- $graph->Add($l1plot);
- $graph->title->Set("Linie");
- $graph->xaxis->title->Set("X-title");
- $graph->yaxis->title->Set("Y-title");
- $graph->title->SetFont(FF_FONT1,FS_BOLD);
- $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
- $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
- // Display the graph
- $graph->Stroke();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement