| 1 |
lars |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
|
|
2 |
<HTML>
|
|
|
3 |
<HEAD>
|
|
|
4 |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
|
|
|
5 |
<LINK REL="Start" HREF="index.html">
|
|
|
6 |
<LINK REL="Contents" HREF="toc.html">
|
|
|
7 |
<LINK REL="Prev" HREF="10181Enablingantialiasedlines.html">
|
|
|
8 |
<LINK REL="Next" HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">
|
|
|
9 |
<STYLE TYPE="text/css"><!--
|
|
|
10 |
BODY { font-family: serif }
|
|
|
11 |
H1 { font-family: sans-serif }
|
|
|
12 |
H2 { font-family: sans-serif }
|
|
|
13 |
H3 { font-family: sans-serif }
|
|
|
14 |
H4 { font-family: sans-serif }
|
|
|
15 |
H5 { font-family: sans-serif }
|
|
|
16 |
H6 { font-family: sans-serif }
|
|
|
17 |
SUB { font-size: smaller }
|
|
|
18 |
SUP { font-size: smaller }
|
|
|
19 |
PRE { font-family: monospace }
|
|
|
20 |
A { text-decoration: none }
|
|
|
21 |
--></STYLE>
|
|
|
22 |
</HEAD>
|
|
|
23 |
<BODY>
|
|
|
24 |
<A HREF="toc.html">Contents</A>
|
|
|
25 |
<A HREF="10181Enablingantialiasedlines.html">Previous</A>
|
|
|
26 |
<A HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Next</A>
|
|
|
27 |
<HR NOSHADE>
|
|
|
28 |
<H2><A NAME="10_19">10.19 Rotating the graphs</A></H2>
|
|
|
29 |
<P> JpGraph provide the possibility for you to rotate the generated
|
|
|
30 |
graph an arbitrary angle. This will only affect the actual graph (axis,
|
|
|
31 |
axis titles, labels and so on) and not fixed elements on the graph like
|
|
|
32 |
title or footer.</P>
|
|
|
33 |
<P> Rotation is probably most used to rotate a graph 90 degrees, for
|
|
|
34 |
example a bar graph to get the effect of horizontal bars.</P>
|
|
|
35 |
<P></P>
|
|
|
36 |
<HR> <SMALL>
|
|
|
37 |
<P><STRONG> Performance note:</STRONG> Adding a rotation transformation
|
|
|
38 |
will make the graph generation slightly slower since each point of the
|
|
|
39 |
graph as to go through a transformation step before being stroked on to
|
|
|
40 |
the image. JpGraph optimizes this by using a pre-calculated
|
|
|
41 |
transformation matric and also optimizes the special case 90 degrees.</P>
|
|
|
42 |
</SMALL>
|
|
|
43 |
<HR>
|
|
|
44 |
<P> By default the center of the rotation will be the center of the plot
|
|
|
45 |
area, which may or may not coincide with the center of the entire
|
|
|
46 |
image.</P>
|
|
|
47 |
<P> To control the rotation you use the two methods</P>
|
|
|
48 |
<UL>
|
|
|
49 |
<LI> <A href="../ref/RotImage.html#_ROTIMAGE_SETANGLE">
|
|
|
50 |
Graph::image::SetAngle()</A>, Specify rotation angle in degrees.</LI>
|
|
|
51 |
<LI> <A href="../ref/RotImage.html#_ROTIMAGE_SETCENTER">
|
|
|
52 |
Graph::image::SetCenter()</A>, Specify center of rotation in absolute
|
|
|
53 |
image pixels</LI>
|
|
|
54 |
</UL>
|
|
|
55 |
<P> For example<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
|
|
|
56 |
$graph</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">image</FONT><FONT
|
|
|
57 |
color="#007700">-></FONT><FONT color="#0000BB">SetAngle</FONT><FONT color="#007700">
|
|
|
58 |
(</FONT><FONT color="#0000BB">45</FONT><FONT color="#007700">);</FONT><FONT
|
|
|
59 |
color="#0000BB"></FONT></FONT></CODE></DIV></P>
|
|
|
60 |
<P></P>
|
|
|
61 |
<P> There is actually a third method that you could use, adding a
|
|
|
62 |
translation to the graph<STRONG> after</STRONG> the rotation. Since
|
|
|
63 |
this probably a very little used method we don't discuss it further but
|
|
|
64 |
refer the reader to the class reference instead <A href="../ref/RotImage.html#_ROTIMAGE_SETTRANSLATION">
|
|
|
65 |
Graph:image::SetTranslation()</A></P>
|
|
|
66 |
<P> When you rotate an image you should be aware of that the individual
|
|
|
67 |
labels on the axis are not rotated. The design decision behind this is
|
|
|
68 |
<BR><STRONG> a)</STRONG> Bit mapped font can't be rotated
|
|
|
69 |
<BR><STRONG> b)</STRONG> Maintain readability</P>
|
|
|
70 |
<P> Please remember that you may still rotate the labels by calling the <A
|
|
|
71 |
href="../ref/Axis.html#_AXIS_SETLABELANGLE"> Axis::SetLabelAngle()</A>
|
|
|
72 |
method.</P>
|
|
|
73 |
<P> Since the anchor point for labels is by default the optimum for
|
|
|
74 |
graph at 0 degree you might want to adjust the anchor point and
|
|
|
75 |
alignment for the labels on the axis to get a better visual appearance
|
|
|
76 |
on you rotated graph. This is accomplished by the method <A href="../ref/Axis.html#_AXIS_SETLABELALIGN">
|
|
|
77 |
Axis::SetLabelAlign()</A> For a detailed discussion on how to do this
|
|
|
78 |
please see the section on horizontal bar graphs, ( <A href="3030barplot.html">
|
|
|
79 |
Working with bar plots</A> )</P>
|
|
|
80 |
<P> The table below shows some examples on different kinds of rotation
|
|
|
81 |
to give you an idea of how changing the angle and rotation center may
|
|
|
82 |
be used to generate different effects. The top left graph is the
|
|
|
83 |
original image. The point of rotation has been marked with a red-cross
|
|
|
84 |
in each of the images.</P>
|
|
|
85 |
<P><DIV class="example">
|
|
|
86 |
<BR> <A href="exframes/frame_rotex0.html" target="blank"><IMG border="0" HEIGHT="170"
|
|
|
87 |
src="img/rotex0.png" WIDTH="270"></A>
|
|
|
88 |
<BR><B>Figure 172:</B> Original image <A href="exframes/frame_rotex0.html"
|
|
|
89 |
target="blank">[src]</A>
|
|
|
90 |
<P></P>
|
|
|
91 |
</DIV></P>
|
|
|
92 |
<P><DIV class="example">
|
|
|
93 |
<BR> <A href="exframes/frame_rotex1.html" target="blank"><IMG border="0" HEIGHT="170"
|
|
|
94 |
src="img/rotex1.png" WIDTH="270"></A>
|
|
|
95 |
<BR><B>Figure 173:</B> Rotated 45 degrees around center of plot area <A href="exframes/frame_rotex1.html"
|
|
|
96 |
target="blank">[src]</A>
|
|
|
97 |
<P></P>
|
|
|
98 |
</DIV></P>
|
|
|
99 |
<P><DIV class="example">
|
|
|
100 |
<BR> <A href="exframes/frame_rotex2.html" target="blank"><IMG border="0" HEIGHT="170"
|
|
|
101 |
src="img/rotex2.png" WIDTH="270"></A>
|
|
|
102 |
<BR><B>Figure 174:</B> Rotated 90 degrees around center of plot area <A href="exframes/frame_rotex2.html"
|
|
|
103 |
target="blank">[src]</A>
|
|
|
104 |
<P></P>
|
|
|
105 |
</DIV></P>
|
|
|
106 |
<P><DIV class="example">
|
|
|
107 |
<BR> <A href="exframes/frame_rotex3.html" target="blank"><IMG border="0" HEIGHT="170"
|
|
|
108 |
src="img/rotex3.png" WIDTH="270"></A>
|
|
|
109 |
<BR><B>Figure 175:</B> Rotated 45 degrees around center of the image <A href="exframes/frame_rotex3.html"
|
|
|
110 |
target="blank">[src]</A>
|
|
|
111 |
<P></P>
|
|
|
112 |
</DIV></P>
|
|
|
113 |
<P><DIV class="example">
|
|
|
114 |
<BR> <A href="exframes/frame_rotex4.html" target="blank"><IMG border="0" HEIGHT="170"
|
|
|
115 |
src="img/rotex4.png" WIDTH="270"></A>
|
|
|
116 |
<BR><B>Figure 176:</B> Rotated 90 degrees around center of the image <A href="exframes/frame_rotex4.html"
|
|
|
117 |
target="blank">[src]</A>
|
|
|
118 |
<P></P>
|
|
|
119 |
</DIV></P>
|
|
|
120 |
<P><DIV class="example">
|
|
|
121 |
<BR> <A href="exframes/frame_rotex5.html" target="blank"><IMG border="0" HEIGHT="170"
|
|
|
122 |
src="img/rotex5.png" WIDTH="270"></A>
|
|
|
123 |
<BR><B>Figure 177:</B> Rotated -30 degrees around the lower left point
|
|
|
124 |
of the plot area <A href="exframes/frame_rotex5.html" target="blank">
|
|
|
125 |
[src]</A>
|
|
|
126 |
<P></P>
|
|
|
127 |
</DIV></P>
|
|
|
128 |
<P></P>
|
|
|
129 |
<P> As you can see from the images above if you rotate about any other
|
|
|
130 |
point than the center of the plot area the plot can be placed outside
|
|
|
131 |
the image after rotation.</P>
|
|
|
132 |
<P> Since the rotation, by design, only affects the plot area it is
|
|
|
133 |
often most effective to use when the color of the margin is the same as
|
|
|
134 |
the background color.</P>
|
|
|
135 |
<HR NOSHADE>
|
|
|
136 |
<A HREF="toc.html">Contents</A>
|
|
|
137 |
<A HREF="10181Enablingantialiasedlines.html">Previous</A>
|
|
|
138 |
<A HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Next</A>
|
|
|
139 |
</BODY>
|
|
|
140 |
</HTML>
|