| 1 |
lars |
1 |
<style type="text/css">
|
|
|
2 |
<!--
|
|
|
3 |
A:link {font-family: helvetica, arial, geneva, sans-serif; font-size: x-small; text-decoration: none; color: #0000ff}
|
|
|
4 |
A:visited {font-family: helvetica, arial, geneva, sans-serif; font-size: x-small; text-decoration: none; color: #0000ff}
|
|
|
5 |
A:hover {font-family: helvetica, arial, geneva, sans-serif; font-size: x-small; text-decoration: underline; color: #FF0000}
|
|
|
6 |
th {font-family: helvetica, arial; color : blue; font-size:85%; background : lightgrey; border-right:black solid 1pt; border-bottom:black solid 1pt;}
|
|
|
7 |
//-->
|
|
|
8 |
</style><hr><a name="_C_CANVASSCALE"><div style="background-color:yellow;font-family:courier new;"></a>CLASS <b>CanvasScale</b></div>
|
|
|
9 |
<i>(Defined in: jpgraph_canvtools.php : 24)</i><table border=1><tr><td> <a href="CanvasScale.html" style="font-family:arial;font-weight:bold;color:darkblue;">CanvasScale</a> </td></tr><tr><td valign=top> <a href="CanvasScale.html#_CANVASSCALE_CANVASSCALE">CanvasScale()</a> <br>
|
|
|
10 |
<a href="CanvasScale.html#_CANVASSCALE_SET">Set()</a> <br>
|
|
|
11 |
<a href="CanvasScale.html#_CANVASSCALE_TRANSLATE">Translate()</a> <br>
|
|
|
12 |
<a href="CanvasScale.html#_CANVASSCALE_TRANSLATEX">TranslateX()</a> <br>
|
|
|
13 |
<a href="CanvasScale.html#_CANVASSCALE_TRANSLATEY">TranslateY()</a> <br>
|
|
|
14 |
</td></tr></table> <p><div style="font-weight:bold;font-family:arial;font-size:100%;">Class usage and Overview</div>This class defines a scale which is meant to be used with canvas graphs to make it possibles to pecify a more convinient scale compared to absoilute pixels coordinates.
|
|
|
15 |
<br>
|
|
|
16 |
This will also let you scale the canvas without any coordinate changes. <p>
|
|
|
17 |
<hr><span style="font-family:arial;font-size:120%;font-weight:bold;">Class Methods</span><hr><p>
|
|
|
18 |
<p> <p> <span style='font-size:110%;'><a name="_CANVASSCALE_CANVASSCALE"><div style="border-top:solid black 2pt;background-color:lightblue;font-family:courier new;font-size:90%;font-weight:bold;"><b><font color="#000000">
|
|
|
19 |
function CanvasScale(&$graph,$xmin,$xmax,$ymin,$ymax)</font>
|
|
|
20 |
</b></div></a></span>
|
|
|
21 |
|
|
|
22 |
<span style='font-family:arial;font-size:90%;'><i>Define a scale for canvas graphs</i></span><p>
|
|
|
23 |
|
|
|
24 |
<table cellspacing=0 style='border:black solid 1pt;' width=100%>
|
|
|
25 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
26 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
27 |
&$graph</font>
|
|
|
28 |
|
|
|
29 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'> </td><td>Canvas graph</td></tr>
|
|
|
30 |
|
|
|
31 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
32 |
$xmin</font>
|
|
|
33 |
|
|
|
34 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
35 |
0</font>
|
|
|
36 |
</td><td>Min X-value for scale</td></tr>
|
|
|
37 |
|
|
|
38 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
39 |
$xmax</font>
|
|
|
40 |
|
|
|
41 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
42 |
10</font>
|
|
|
43 |
</td><td>Max X-value for scale</td></tr>
|
|
|
44 |
|
|
|
45 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
46 |
$ymin</font>
|
|
|
47 |
|
|
|
48 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
49 |
0</font>
|
|
|
50 |
</td><td>Min Y-value for scale</td></tr>
|
|
|
51 |
|
|
|
52 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
53 |
$ymax</font>
|
|
|
54 |
|
|
|
55 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
56 |
10</font>
|
|
|
57 |
</td><td>Max Y-value for scale</td></tr>
|
|
|
58 |
</table>
|
|
|
59 |
|
|
|
60 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>Define a scale for canvas graphs. Note the scale values is optionally in this call. The may be later set witha call to the Set() method. <br>
|
|
|
61 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">See also</div><a href="CanvasScale.html#_CANVASSCALE_SET">CanvasScale::Set</a><p>
|
|
|
62 |
<p> <p> <span style='font-size:110%;'><a name="_CANVASSCALE_SET"><div style="border-top:solid black 2pt;background-color:lightblue;font-family:courier new;font-size:90%;font-weight:bold;"><b><font color="#000000">
|
|
|
63 |
function Set($xmin,$xmax,$ymin,$ymax)</font>
|
|
|
64 |
</b></div></a></span>
|
|
|
65 |
|
|
|
66 |
<span style='font-family:arial;font-size:90%;'><i>Specify scale to use</i></span><p>
|
|
|
67 |
|
|
|
68 |
<table cellspacing=0 style='border:black solid 1pt;' width=100%>
|
|
|
69 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
70 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
71 |
$xmin</font>
|
|
|
72 |
|
|
|
73 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
74 |
0</font>
|
|
|
75 |
</td><td>Min X value</td></tr>
|
|
|
76 |
|
|
|
77 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
78 |
$xmax</font>
|
|
|
79 |
|
|
|
80 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
81 |
10</font>
|
|
|
82 |
</td><td>Max X-value</td></tr>
|
|
|
83 |
|
|
|
84 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
85 |
$ymin</font>
|
|
|
86 |
|
|
|
87 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
88 |
0</font>
|
|
|
89 |
</td><td>Min Y-value</td></tr>
|
|
|
90 |
|
|
|
91 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
92 |
$ymax</font>
|
|
|
93 |
|
|
|
94 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
95 |
10</font>
|
|
|
96 |
</td><td>Max Y-value</td></tr>
|
|
|
97 |
</table>
|
|
|
98 |
|
|
|
99 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>SPecify min/max values for scale. <br>
|
|
|
100 |
|
|
|
101 |
<div style="font-weight:bold;font-family:arial;font-size:85%;"><p>Example</div><span style="font-family:courier;font-size:85%;"><font color="#000000">
|
|
|
102 |
// Setup a basic canvas we can work
<br />$g = new CanvasGraph(400,200,'auto');
<br />$g->SetMargin(5,11,6,11);
<br />$g->SetShadow();
<br />$g->SetMarginColor("teal");
<br />
<br />// We need to stroke the plotarea and margin before we add the
<br />// text since we otherwise would overwrite the text.
<br />$g->InitFrame();
<br />
<br />// Create a new scale
<br />$scale = new CanvasScale($g);
<br />$scale->Set(0,$xmax,0,$ymax);
<br /></font>
|
|
|
103 |
</span><br>
|
|
|
104 |
<p>
|
|
|
105 |
<p> <p> <span style='font-size:110%;'><a name="_CANVASSCALE_TRANSLATE"><div style="border-top:solid black 2pt;background-color:lightblue;font-family:courier new;font-size:90%;font-weight:bold;"><b><font color="#000000">
|
|
|
106 |
function Translate($x,$y)</font>
|
|
|
107 |
</b></div></a></span>
|
|
|
108 |
|
|
|
109 |
<span style='font-family:arial;font-size:90%;'><i>Translate a point to absolute screen coordinates</i></span><p>
|
|
|
110 |
|
|
|
111 |
<table cellspacing=0 style='border:black solid 1pt;' width=100%>
|
|
|
112 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
113 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
114 |
$x</font>
|
|
|
115 |
|
|
|
116 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'> </td><td>X-value</td></tr>
|
|
|
117 |
|
|
|
118 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
119 |
$y</font>
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
</table>
|
|
|
123 |
|
|
|
124 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>Translate a point to absolute screen coordinates <br>
|
|
|
125 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">See also</div><a href="CanvasScale.html#_CANVASSCALE_TRANSLATEX">CanvasScale::TranslateX</a> and <a href="CanvasScale.html#_CANVASSCALE_TRANSLATEY">CanvasScale::TranslateY</a>
|
|
|
126 |
<div style="font-weight:bold;font-family:arial;font-size:85%;"><p>Example</div><span style="font-family:courier;font-size:85%;"><font color="#000000">
|
|
|
127 |
list($xt,$yt) = $scale->Translate($x,$y);
<br />$graph->img->Point($xt,$yt);</font>
|
|
|
128 |
|
|
|
129 |
<p>
|
|
|
130 |
|
|
|
131 |
function TranslateX($x)</font>
|
|
|
132 |
</b></div></a></span>
|
|
|
133 |
|
|
|
134 |
<span style='font-family:arial;font-size:90%;'><i>Translate X-coordinate</i></span><p>
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
138 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
139 |
$x</font>
|
|
|
140 |
|
|
|
141 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'> </td><td>X-value</td></tr>
|
|
|
142 |
</table>
|
|
|
143 |
|
|
|
144 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>Translate X-value into absolute screen coordinates <br>
|
|
|
145 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">See also</div><a href="CanvasScale.html#_CANVASSCALE_TRANSLATE">CanvasScale::Translate</a><p>
|
|
|
146 |
<p> <p> <span style='font-size:110%;'><a name="_CANVASSCALE_TRANSLATEY"><div style="border-top:solid black 2pt;background-color:lightblue;font-family:courier new;font-size:90%;font-weight:bold;"><b><font color="#000000">
|
|
|
147 |
|
|
|
148 |
</b></div></a></span>
|
|
|
149 |
|
|
|
150 |
<span style='font-family:arial;font-size:90%;'><i>Translate Y-value to absolute screen coordinates</i></span><p>
|
|
|
151 |
|
|
|
152 |
<table cellspacing=0 style='border:black solid 1pt;' width=100%>
|
|
|
153 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
154 |
|
|
|
155 |
$y</font>
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
</table>
|
|
|
159 |
|
|
|
160 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>Translate Y-value to absolute screen coordinates <br>
|
|
|
161 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">See also</div><a href="CanvasScale.html#_CANVASSCALE_TRANSLATE">CanvasScale::Translate</a><p> <hr> <p>
|