hi friends .........
i am ploting a graph on which a black border comes i am not getting from where it is coming ........
can any one help me .......
plsssssss help out me
ploting of graph
Moderator: General Moderators
Re: ploting of graph
We're going to need a lot more information. How are you making this graph? GD? What does the (relevant!) code look like? What have you tried so far?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
shradhaparab
- Forum Newbie
- Posts: 6
- Joined: Fri May 09, 2008 6:50 am
Re: ploting of graph
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
hi ..........
i have first taken one png graph and call in map.php file.
In map.php file i am calling the image and defining all values
eg.
and then wrote the function to change values to Pixel.
2nd file is graph.php, in this file i am calling map.php file .
In this file i am taking the values which user has entered and form a query a fetch it from the database and plot a dot graph.
plot is coming correct but one thick black border comes in middle which is not correct and should not come .i want that black border should not come .
can u help me out in this...........
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
hi ..........
i have first taken one png graph and call in map.php file.
In map.php file i am calling the image and defining all values
eg.
Code: Select all
<?php
//define constants
define("MAPFILE","testmap.png");
define("MINX",0);
define("MAXX",699+MINX);
define("MINY", 0);
define("MAXY", 419+MINY);
define("MINLAT", -1210000);
define("MAXLAT", 2210000);
define("MINLONG", 5100000);
define("MAXLONG", 9310000);
define("GRIDSIZE", 10);
?>
2nd file is graph.php, in this file i am calling map.php file .
In this file i am taking the values which user has entered and form a query a fetch it from the database and plot a dot graph.
plot is coming correct but one thick black border comes in middle which is not correct and should not come .i want that black border should not come .
can u help me out in this...........
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Re: ploting of graph
I'd need to see the graphing function to help at all, but it's likely one of two things.
1) The data you're getting isn't what you think it is. Output the data (rather than plotting it into the image) & verify it makes sense.
2) Somewhere in your graphing function you're either a) drawing a big black line, or b) not covering the entire image with your background image. The default colour for images created with GD is black, so it might just be some background showing through. Are your points being plotted in black? Change it to another colour temporarily - if the line stays black it's probably not your graphing function, but rather the background.
1) The data you're getting isn't what you think it is. Output the data (rather than plotting it into the image) & verify it makes sense.
2) Somewhere in your graphing function you're either a) drawing a big black line, or b) not covering the entire image with your background image. The default colour for images created with GD is black, so it might just be some background showing through. Are your points being plotted in black? Change it to another colour temporarily - if the line stays black it's probably not your graphing function, but rather the background.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
shradhaparab
- Forum Newbie
- Posts: 6
- Joined: Fri May 09, 2008 6:50 am
Re: ploting of graph
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Don't make me tell you again.
i have checked there is no background color drawing by default and also i am ploting graph in red color. Black color is not at all involved.
when i am defining the constants in this range
the black border does not come , but when i give in this range
the thick black border form because of this border the scale of the graph gets hide .
is the problem with range which i am defining
And also when i am ploting graph with imagefilledarc() ; function, the function of it is in integer and my values stored is in lakhs ie. it is crossing the integer limits so, is it because of it
below is my code
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Don't make me tell you again.
hi..........pickle wrote:I'd need to see the graphing function to help at all, but it's likely one of two things.
1) The data you're getting isn't what you think it is. Output the data (rather than plotting it into the image) & verify it makes sense.
2) Somewhere in your graphing function you're either a) drawing a big black line, or b) not covering the entire image with your background image. The default colour for images created with GD is black, so it might just be some background showing through. Are your points being plotted in black? Change it to another colour temporarily - if the line stays black it's probably not your graphing function, but rather the background.
i have checked there is no background color drawing by default and also i am ploting graph in red color. Black color is not at all involved.
when i am defining the constants in this range
Code: Select all
ie.
define("MINLAT", 40);
define("MAXLAT", 2240717);
define("MINLONG", 4783280);
define("MAXLONG", 9262288);
define("GRIDSIZE", 10);Code: Select all
define("MINLAT", -1288000);
define("MAXLAT", 2297000);
define("MINLONG", 4000000);
define("MAXLONG", 9990000);
define("GRIDSIZE", 10);is the problem with range which i am defining
And also when i am ploting graph with imagefilledarc() ; function, the function of it is in integer and my values stored is in lakhs ie. it is crossing the integer limits so, is it because of it
below is my code
Code: Select all
<?php
//define constants
define("MAPFILE","testmap.png");
define("MINX",0);
define("MAXX",699+MINX);
define("MINY", 0);
define("MAXY", 419+MINY);
define("MINLAT", -1288000);
define("MAXLAT", 2297000);
define("MINLONG", 4000000);
define("MAXLONG", 9990000);
define("GRIDSIZE", 10);
/**no black border
define("MINLAT", 40);
define("MAXLAT", 2240717);
define("MINLONG", 4783280);
define("MAXLONG", 9262288);
define("GRIDSIZE", 10);
**/
if(trim($minLat)=="") $minLat=MINLAT;
if(trim($maxLat)=="") $maxLat=MAXLAT;
if(trim($minLong)=="") $minLong=MINLONG;
if(trim($maxLong)=="") $maxLong=MAXLONG;
function getPixelValueofLat($l)
{
$scaleY = (MAXY - MINY)/(MAXLAT - MINLAT);
$LAT_PIXEL = round(MINY + (MAXLAT - $l) * $scaleY);
return $LAT_PIXEL;
}
function getPixelValueofLong($l)
{
$scaleX = (MAXX - MINX)/( MAXLONG - MINLONG);
$LONG_PIXEL = round(MINX + ($l - MINLONG) * $scaleX);
return $LONG_PIXEL;
}
$im=imagecreatefrompng(MAPFILE);
//$background = imagecolorallocate($im, 150, 200, 255);
//$background = imagecolorallocate($im, 255, 255, 255);
//$background = imagecolorallocate($im,102, 102, 102);
//imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);
// output image in the browser
$red=imagecolorallocate($im, 255, 0, 0);
$green=imagecolorallocate($im, 0, 255, 0);
$darkgreen=imagecolorallocate($im, 105, 155, 160);
$darkgray=imagecolorallocate($im, 102, 102, 102);
$blue=imagecolorallocate($im, 0, 0, 255);
$black=imagecolorallocate($im, 0, 0, 0);
$linecolour=$darkgray;
$str="(".getPixelValueofLat(-90)." ,".getPixelValueofLong(180).")";
imageline ( $im, MINX, MINY, MAXX, MINY, $darkgreen );
imageline ( $im, MINX, MINY, MINX, MAXY, $darkgreen );
imageline ( $im, MINX, MAXY, MAXX, MAXY, $darkgreen );
imageline ( $im, MAXX, MINY, MAXX, MAXY, $darkgreen );
$text_color = $black;
$font_size=2;
for($i = 0 ; $i <= ((MAXLONG-MINLONG)/GRIDSIZE); $i++)
{
$lo=(MINLONG-(MINLONG-((MINLONG%GRIDSIZE)*GRIDSIZE)))+$i*GRIDSIZE;
if($lo < 0 )
{
$s="- ".($lo*-1);
}
else if($lo == 0 )
{
$s=" ".$lo;
}
else
{
$s="+ ".$lo;
}
$xcord=getPixelValueofLong($lo);
imagestringup($im, $font_size, $xcord-6, MINY-8, $s , $linecolour);
imageline ( $im, $xcord, MINY, $xcord, MAXY, $drakgray);
}
for($j = 0 ; $j <= ((MAXLAT-MINLAT)/GRIDSIZE) ; $j++)
{
$la=(MAXLAT-(MAXLAT-((MAXLAT%GRIDSIZE)*GRIDSIZE)))-$j*GRIDSIZE;
if($la < 0 )
{
$s="- ".($la*-1);
}
else if($la == 0 )
{
$s=" ".$la;
}
else
{
$s="+ ".$la;
}
$ycord=getPixelValueofLat($la);
imagestring($im, $font_size, 7, $ycord-7, str_pad($s,5, " ",STR_PAD_LEFT) , $linecolour);
imageline ($im, MINX, $ycord, MAXX, $ycord, $drakgray);
}
// header("Content-type: image/png");
//Output graph and clear image from memory
// imagepng($im);
?>
//----------------------------------------------------------------------------------------------------
//graph.php
<?php
include_once("connect_db.php");
include_once("map.php");
header("Content-type: image/png");
$colorRed=imagecolorallocate($im, 255, 0, 0);
//query to take values plot graph
$minLat=$_GET["minLat"];
//echo "minlat".$minLat."<br>";
$maxLat=$_GET["maxLat"];
//echo "maxlat".$maxLat."<br>";
$minLong=$_GET["minLong"];
//echo "minlong".$minLong."<br>";
$maxLong=$_GET["maxLong"];
//echo "maxlong".$maxLong."<br>";
$query="select distinct LATITUDE,LONGITUDE from tablename where LATITUDE >= $minLat and LATITUDE <= $maxLat and LONGITUDE >= $minLong and LONGITUDE <= $maxLong";
//echo "query".$query."<br>";
$result = mysql_query($query,$link);
$lat0="";
$lon0="";
$dotSize=2;
while($row = mysql_fetch_array($result))
{
$lat1=getPixelValueofLat($row[0]);
$lon1=getPixelValueofLong($row[1]);
if($lat0<>"" and $lon0<>"")
{
imagefilledarc($im,$lon1,$lat1, $dotSize, $dotSize, 0, 360, $colorRed, IMG_ARC_PIE);
}
$lat0=getPixelValueofLat($row[0]);
$lon0=getPixelValueofLong($row[1]);
}
// Output graph and clear image from memory
imagepng($im);
imagedestroy($im);
mysql_free_result($result);
?>~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Re: ploting of graph
You don't have to specify black. Black is the absence of colour, so if there's part of the image you're not drawing on with a colour, it will be black. Do you have an example image?
Also - post your code inside tags. I've already corrected you twice.
Also - post your code inside
Code: Select all
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.