I am able to get_hotspots() only after I plot. Then I need to create and draw the new text. If I display the data at this time my labels will not appear. I need to plot again, then my labels will appear. However, when I plot twice like this I get a ghosted image of of the entire graph with the second image being stretched so it is noticeable.
In the examples, sample71.pl does plot, get_hotspots(), draw and then save_chart through save.pl and it has no problem. I am writing CGI so I just print an img tag with src="data:.." to display the image.
Here is a code snippet
I tried throwing away the plotdata from either plot call but could not get what I wanted. Thanks in advance Mark# need this plot in order for hotspots to have data my $plotdata = $graph->plot($rows)->gif; my $gd = $graph->gd; my $red = $gd->colorResolve(255,0,0); my @l = $graph->get_hotspot(1, 3); my ($x, $y) = ( ($l[1] + $l[3])/2, ($l[2] + $l[4])/2 ); my $gdta; $gdta = GD::Text::Align->new($gd, text => 'maximum', font => ['../Dustismo_Sans.ttf', GD::Font->Small], ptsize => 12, colour => $red, valign => 'bottom', halign => 'center', ) or warn $gdta->error; $gdta->draw($x, $y + 2); # must re-plot to get hotspots visible # without this call to plot, the graph is fine (sans labels) # but with it I get labels and a ghosting problem $plotdata = $graph->plot($rows)->png; my $uri = URI->new("data:"); $uri->media_type("image/png"); $uri->data($plotdata); print qq(<img src="$uri" alt="Didn't work."></html>\n);
In reply to gd::graph hotspots by elmoz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |