Hallo,
ich versuche mir eine eine Klasse und Funktion zu schreiben die mir mehrere
linien Diagramme in ein Bild zeichnet.
das Bild selber zu generieren funktioniert !!
Aber nicht in einer Klasse mit Funktion.
Der Aufruf:
$dia = new diagram();
$dia->setDiagram()
$dia->getDiagram()
Class:
Quellcode:
<?php
// error_reporting(E_ALL);
include ('jpgraph/jpgraph.php');
include ('jpgraph/jpgraph_line.php');
class diagram {
function diagram(){
// empty
}
function setDiagram(){
$ydata = array(11,3,8,12,5,1,9,13,5,7);
// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");
$graph->SetScale("textlin");
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->mark->SetType(MARK_UTRIANGLE);
$graph->img->SetMargin(40,20,20,40);
$graph->title->Set("Example 3.1");
$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);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$graph->yaxis->SetColor("red");
$graph->yaxis->SetWeight(2);
$graph->SetShadow();
// Display the graph
// $graph->Stroke();
// imagepng($graph->Stroke(_IMG_HANDLER));
// Add the plot to the graph
$graph->Add($lineplot);
}// function
// ++++++++++++++++++++++++++++++++++++
function getDiagram(){
// Display the graph
imagepng($graph->Stroke(_IMG_HANDLER));
}
}// class
?>
Dann bekomme ich nur:
Quellcode:
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6667
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6668
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6669
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6670
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6672
�PNG
................................ usw
Wie kann ich die Klasse richtig initialisieren oder aufrufen damit es klappt ????
Bitte um Hilfe !!!
Vielen dank
Gruß
surfer
ich versuche mir eine eine Klasse und Funktion zu schreiben die mir mehrere
linien Diagramme in ein Bild zeichnet.
das Bild selber zu generieren funktioniert !!
Aber nicht in einer Klasse mit Funktion.
Der Aufruf:
$dia = new diagram();
$dia->setDiagram()
$dia->getDiagram()
Class:
Quellcode:
<?php
// error_reporting(E_ALL);
include ('jpgraph/jpgraph.php');
include ('jpgraph/jpgraph_line.php');
class diagram {
function diagram(){
// empty
}
function setDiagram(){
$ydata = array(11,3,8,12,5,1,9,13,5,7);
// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");
$graph->SetScale("textlin");
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->mark->SetType(MARK_UTRIANGLE);
$graph->img->SetMargin(40,20,20,40);
$graph->title->Set("Example 3.1");
$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);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$graph->yaxis->SetColor("red");
$graph->yaxis->SetWeight(2);
$graph->SetShadow();
// Display the graph
// $graph->Stroke();
// imagepng($graph->Stroke(_IMG_HANDLER));
// Add the plot to the graph
$graph->Add($lineplot);
}// function
// ++++++++++++++++++++++++++++++++++++
function getDiagram(){
// Display the graph
imagepng($graph->Stroke(_IMG_HANDLER));
}
}// class
?>
Dann bekomme ich nur:
Quellcode:
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6667
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6668
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6669
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6670
Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/diagramY.php:6) in /srv/www/htdocs/jpgraph/jpgraph.php on line 6672
�PNG
................................ usw
Wie kann ich die Klasse richtig initialisieren oder aufrufen damit es klappt ????
Bitte um Hilfe !!!
Vielen dank
Gruß
surfer
Kommentar