Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

jpgraph??
Hallo,

kennt sich jemand mit der Diagramm-Library jpgraph aus?
Ich versuche Werte in ein Diagramm zu schreiben, welche ich aus einer
mysql-DB auslese im Diagramm auf http://www.rideon.ch/php/schnee.php (ein
Ort auswählen und "Zeigen" klicken) wird aber nur die eine Kurve mit den
fixen ($ydata2 = array(1,19,15,7,22,14,5,9,21,13);) Werten angezeigt,
wesshalb?
[Code Chart.php]
<?php
// Code that uses the jpgraph library
include ( '../jpgraph/src/jpgraph.php');
include ('../jpgraph/src/jpgraph_line.php');

/* Datenbankserver - In der Regel die IP */
$db_server = "localhost";
/* Datenbankname */
$db_name = "usr_web2_1 ";
/* Datenbankuser */
$db_user = "web2";
/* Datenbankpasswort */
$db_passwort = "5thelement";

/* Erstellt Connect zu Datenbank her */
$db =  @MYSQL_CONNECT($db_server,$db_user,$db_p
asswort) or die ();
$db_check = @MYSQL_SELECT_DB($db_name);
if($db)
{
$sqlwhere="WHERE location=\"$location\"";
$result = mysql_query("SELECT * FROM schnee $sqlwhere ORDER BY location,
date DESC");
while ($row = mysql_fetch_array ($result))
{
$ydata[$i]=$row[snowheight];
$i++; //zählvariable inkrementieren
}
//********** DIGRAMM ************
//$ydata = array(11,3,8,12,5,1,9,13,5,50);
$ydata2 = array(1,19,15,7,22,14,5,9,21,13);

// Create the graph. These two calls are always required
$graph = new Graph(500,400,"auto");
$graph->SetScale("textlin");

// Create the linear plot
$lineplot=new LinePlot($ydata);

$lineplot2=new LinePlot($ydata2);

// Add the plot to the graph
$graph->Add($lineplot);
$graph->Add($lineplot2);

$graph->img->SetMargin(40,20,20,40);
$graph->title->Set("$location");
$graph->xaxis->title->Set("Datum [yyyy-mm-dd]");
$graph->yaxis->title->Set("Schneehöhe [cm]");

$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);

$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);

$graph->yaxis->SetColor("red");
$graph->yaxis->SetWeight(2);
$graph->SetShadow();

// Display the graph
$graph->Stroke();
}

?>
[/Code Chart.php]

Danke!

--
roN
www.rideon.ch



Report this thread to moderator Post Follow-up to this message
Old Post
Ron Eggler
12-21-04 08:55 AM


Re: jpgraph??

Ron Eggler wrote:
> Hallo,
>
> kennt sich jemand mit der Diagramm-Library jpgraph aus?
> Ich versuche Werte in ein Diagramm zu schreiben, welche ich aus einer
> mysql-DB auslese im Diagramm auf http://www.rideon.ch/php/schnee.php
> (ein Ort auswählen und "Zeigen" klicken) wird aber nur die eine Kurve
> mit den fixen ($ydata2 = array(1,19,15,7,22,14,5,9,21,13);) Werten
> angezeigt, wesshalb?
> [Code Chart.php]
> <?php
> // Code that uses the jpgraph library
> include ( '../jpgraph/src/jpgraph.php');
> include ('../jpgraph/src/jpgraph_line.php');
>
> /* Datenbankserver - In der Regel die IP */
>   $db_server = "localhost";
>   /* Datenbankname */
>   $db_name = "usr_web2_1 ";
>   /* Datenbankuser */
>   $db_user = "web2";
>    /* Datenbankpasswort */
>   $db_passwort = "5thelement";
>
> /* Erstellt Connect zu Datenbank her */
> $db =  @MYSQL_CONNECT($db_server,$db_user,$db_p
asswort) or die ();
> $db_check = @MYSQL_SELECT_DB($db_name);
> if($db)
>   {
>   $sqlwhere="WHERE location=\"$location\"";
>   $result = mysql_query("SELECT * FROM schnee $sqlwhere ORDER BY
> location, date DESC");
>   while ($row = mysql_fetch_array ($result))
>     {
>     $ydata[$i]=$row[snowheight];
>     $i++; //zählvariable inkrementieren
>     }
>   //********** DIGRAMM ************
>   //$ydata = array(11,3,8,12,5,1,9,13,5,50);
>   $ydata2 = array(1,19,15,7,22,14,5,9,21,13);
>
>   // Create the graph. These two calls are always required
>   $graph = new Graph(500,400,"auto");
>   $graph->SetScale("textlin");
>
>   // Create the linear plot
>   $lineplot=new LinePlot($ydata);
>
>   $lineplot2=new LinePlot($ydata2);
>
>   // Add the plot to the graph
>   $graph->Add($lineplot);
>   $graph->Add($lineplot2);
>
>   $graph->img->SetMargin(40,20,20,40);
>   $graph->title->Set("$location");
>   $graph->xaxis->title->Set("Datum [yyyy-mm-dd]");
>   $graph->yaxis->title->Set("Schneehöhe [cm]");
>
>   $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);
>
>   $lineplot2->SetColor("orange");
>   $lineplot2->SetWeight(2);
>
>   $graph->yaxis->SetColor("red");
>   $graph->yaxis->SetWeight(2);
>   $graph->SetShadow();
>
>   // Display the graph
>   $graph->Stroke();
>   }
> 
> [/Code Chart.php]
>
> Danke!

Okay, ich hab's... Danke trozdem! :)



Report this thread to moderator Post Follow-up to this message
Old Post
Ron Eggler @ Work
12-21-04 01:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:16 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.