Blame | Letzte Änderung | Log anzeigen | RSS feed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1"><LINK REL="Start" HREF="index.html"><LINK REL="Contents" HREF="toc.html"><LINK REL="Prev" HREF="9181Enablingantialiasedlines.html"><LINK REL="Next" HREF="920Adjustingbrightnessandcontrastforimagesandbackgrounds.html"><STYLE TYPE="text/css"><!--BODY { font-family: serif }H1 { font-family: sans-serif }H2 { font-family: sans-serif }H3 { font-family: sans-serif }H4 { font-family: sans-serif }H5 { font-family: sans-serif }H6 { font-family: sans-serif }SUB { font-size: smaller }SUP { font-size: smaller }PRE { font-family: monospace }A { text-decoration: none }--></STYLE></HEAD><BODY><A HREF="toc.html">Contents</A><A HREF="9181Enablingantialiasedlines.html">Previous</A><A HREF="920Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Next</A><HR NOSHADE><H2><A NAME="9_19">9.19 Rotating the graphs</A></H2><P> JpGraph provide the possibility for you to rotate the generatedgraph an arbitrary angle. This will only affect the actual graph (axis,axis titles, labels and so on) and not fixed elements on the graph liketitle or footer.</P><P> Rotation is probably most used to rotate a graph 90 degrees, forexample a bar graph to get the effect of horizontal bars.</P><P></P><HR> <SMALL><P><STRONG> Performance note:</STRONG> Adding a rotation transformationwill make the graph generation slightly slower since each point of thegraph as to go through a transformation step before being stroked on tothe image. JpGraph optimizes this by using a pre-calculatedtransformation matric and also optimizes the special case 90 degrees.</P></SMALL><HR><P> By default the center of the rotation will be the center of the plotarea, which may or may not coincide with the center of the entireimage.</P><P> To control the rotation you use the two methods</P><UL><LI> <A href="../ref/RotImage.html#_ROTIMAGE_SETANGLE">Graph::image::SetAngle()</A>, Specify rotation angle in degrees.</LI><LI> <A href="../ref/RotImage.html#_ROTIMAGE_SETCENTER">Graph::image::SetCenter()</A>, Specify center of rotation in absoluteimage pixels</LI></UL><P> For example<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB"> $graph</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">image</FONT><FONTcolor="#007700">-></FONT><FONT color="#0000BB">SetAngle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">45</FONT><FONT color="#007700">);</FONT><FONTcolor="#0000BB"></FONT></FONT></CODE></DIV></P><P></P><P> There is actually a third method that you could use, adding atranslation to the graph<STRONG> after</STRONG> the rotation. Sincethis probably a very little used method we don't discuss it further butrefer the reader to the class reference instead <A href="../ref/RotImage.html#_ROTIMAGE_SETTRANSLATION">Graph:image::SetTranslation()</A></P><P> When you rotate an image you should be aware of that the individuallabels on the axis are not rotated. The design decision behind this is<BR><STRONG> a)</STRONG> Bit mapped font can't be rotated<BR><STRONG> b)</STRONG> Maintain readability</P><P> Please remember that you may still rotate the labels by calling the <Ahref="../ref/Axis.html#_AXIS_SETLABELANGLE"> Axis::SetLabelAngle()</A>method.</P><P> Since the anchor point for labels is by default the optimum forgraph at 0 degree you might want to adjust the anchor point andalignment for the labels on the axis to get a better visual appearanceon you rotated graph. This is accomplished by the method <A href="../ref/Axis.html#_AXIS_SETLABELALIGN">Axis::SetLabelAlign()</A> For a detailed discussion on how to do thisplease see the section on horizontal bar graphs, ( <A href="3030barplot.html">Working with bar plots</A> )</P><P> The table below shows some examples on different kinds of rotationto give you an idea of how changing the angle and rotation center maybe used to generate different effects. The top left graph is theoriginal image. The point of rotation has been marked with a red-crossin each of the images.</P><P><DIV class="example"><BR> <A href="exframes/frame_rotex0.html" target="blank"><IMG border="0" HEIGHT="170"src="img/img/img/img/img/img/rotex0.png" WIDTH="270"></A><BR><B>Figure 176:</B> Original image <A href="exframes/frame_rotex0.html"target="blank">[src]</A> <P></P></DIV></P><P><DIV class="example"><BR> <A href="exframes/frame_rotex1.html" target="blank"><IMG border="0" HEIGHT="170"src="img/img/img/img/img/img/rotex1.png" WIDTH="270"></A><BR><B>Figure 177:</B> Rotated 45 degrees around center of plot area <A href="exframes/frame_rotex1.html"target="blank">[src]</A> <P></P></DIV></P><P><DIV class="example"><BR> <A href="exframes/frame_rotex2.html" target="blank"><IMG border="0" HEIGHT="170"src="img/img/img/img/img/img/rotex2.png" WIDTH="270"></A><BR><B>Figure 178:</B> Rotated 90 degrees around center of plot area <A href="exframes/frame_rotex2.html"target="blank">[src]</A> <P></P></DIV></P><P><DIV class="example"><BR> <A href="exframes/frame_rotex3.html" target="blank"><IMG border="0" HEIGHT="170"src="img/img/img/img/img/img/rotex3.png" WIDTH="270"></A><BR><B>Figure 179:</B> Rotated 45 degrees around center of the image <A href="exframes/frame_rotex3.html"target="blank">[src]</A> <P></P></DIV></P><P><DIV class="example"><BR> <A href="exframes/frame_rotex4.html" target="blank"><IMG border="0" HEIGHT="170"src="img/img/img/img/img/img/rotex4.png" WIDTH="270"></A><BR><B>Figure 180:</B> Rotated 90 degrees around center of the image <A href="exframes/frame_rotex4.html"target="blank">[src]</A> <P></P></DIV></P><P><DIV class="example"><BR> <A href="exframes/frame_rotex5.html" target="blank"><IMG border="0" HEIGHT="170"src="img/img/img/img/img/img/rotex5.png" WIDTH="270"></A><BR><B>Figure 181:</B> Rotated -30 degrees around the lower left pointof the plot area <A href="exframes/frame_rotex5.html" target="blank">[src]</A> <P></P></DIV></P><P></P><P> As you can see from the images above if you rotate about any otherpoint than the center of the plot area the plot can be placed outsidethe image after rotation.</P><P> Since the rotation, by design, only affects the plot area it isoften most effective to use when the color of the margin is the same asthe background color.</P><HR NOSHADE><A HREF="toc.html">Contents</A><A HREF="9181Enablingantialiasedlines.html">Previous</A><A HREF="920Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Next</A></BODY></HTML>