thepip3r Posted November 17, 2009 Share Posted November 17, 2009 5 | 4 | . 3 | . 2 | . . . 1 | . ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ a b c d e f g in my graph, the x axis heading values are actual date strings and they are vertically oriented using imagestringup(). i've tried assigning the value of imagestringup to a variable and then use that for the imagerotate() but i get an error when i do that. can anyone point me in the right direction pls? for($i=0;$i< $total_points; $i++){ # ------ Extract key and value pair from the current pointer position list($key,$value)=each($array); $x1 = $margins + $gap + $i * ($gap+$bar_width); $x2 = $x1 + $bar_width; $y1 = $margins + $graph_height - intval($value * $ratio) ; $y2 = $img_height-$margins; imagestring($img,0,intval(($bar_width-(strlen(trim($value)) * 6.5)) / 2) + $x1,$y1-10,$value,$bar_color); # numeric values written to screen $temp = imagestringup($img,0,$x1-2,$img_height-5, date("m/d/y D", $key),$bar_color); # x-axis heading values imagerotate($img, 90, 0); imagefilledellipse($img,$x1,$y1,5,5,$bar_color); if ($i > 0) { imageline($img, $x0, $y0, $x1, $y1, $bar_color); } $x0 = $x1; $y0 = $y1; } header("Content-type:image/png"); imagepng($img); Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/ Share on other sites More sharing options...
premiso Posted November 17, 2009 Share Posted November 17, 2009 What is the error you are getting? Providing that will help us out a bit Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959608 Share on other sites More sharing options...
thepip3r Posted November 17, 2009 Author Share Posted November 17, 2009 Warning: imagerotate() expects parameter 1 to be resource, boolean given in public_html/trigeo/graph_line.php on line 157 when i change the above code to: $temp = imagestringup($img,0,$x1-2,$img_height-5, date("m/d/y D", $key),$bar_color); # x-axis heading values imagerotate($temp, 90, 0); Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959609 Share on other sites More sharing options...
Alex Posted November 17, 2009 Share Posted November 17, 2009 Well that's because imagestringup() (as you can see in the manual) returns true or false depending on whether or not the operation was successful, which is not what imageroate() expects Exactly what're are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959610 Share on other sites More sharing options...
premiso Posted November 17, 2009 Share Posted November 17, 2009 I think you need an imagecreate function to create the initial image resource before continuing...I am no expert at GD, just gathered that from the manual. Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959612 Share on other sites More sharing options...
thepip3r Posted November 17, 2009 Author Share Posted November 17, 2009 right and i understood that... i'm trying to rotate the x-axis headers say 45 degrees so they're not vertical but slightly angled. all of the examples i can find are just creating a rotated image on the fly but not one that is created within the context of an existing "graph" image. do i ahve to create that x axis value as a separate image or something and then merge it into the graph body in order to get the x-axis headers rotated correctly? Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959613 Share on other sites More sharing options...
Alex Posted November 17, 2009 Share Posted November 17, 2009 Oh, now I understand what you mean. You might consider using imagettftext() as it includes an angle parameter for drawing the text. Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959617 Share on other sites More sharing options...
thepip3r Posted November 17, 2009 Author Share Posted November 17, 2009 thanx gents -- i will look into both of these. Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959627 Share on other sites More sharing options...
thepip3r Posted November 17, 2009 Author Share Posted November 17, 2009 Alex -- worked like a champ. http://www.zigsdigs.com/trigeo/graph_line.php now i just have to figure out how to calculate the x-offset so the end of the line is adjusted to the actual point instead of the start of the lean. i always read the manual, i just got to imagerotate() and got stuck and never looked any further -- my bad. ty for the help guys. Quote Link to comment https://forums.phpfreaks.com/topic/181932-solved-php-gd-image-rotation-with-building-php-graphs/#findComment-959637 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.