Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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="811Adjustinglabelsonatextscale.html">
8
<LINK REL="Next" HREF="813AddingtitlesandfooterstotheGraph.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="811Adjustinglabelsonatextscale.html">Previous</A>
26
<A HREF="813AddingtitlesandfooterstotheGraph.html">Next</A>
27
<HR NOSHADE>
28
<H2><A NAME="8_12">8.12 Adding arbitrary text strings to the graph</A></H2>
29
<P> To add clarification or other information text strings to the graph
30
 you can add arbitrary lines of text anywhere you like onto the graph.
31
 The text might have multiple lines and you can choose the paragraph
32
 alignment.</P>
33
<P> To add text you have to create one or more instances of the <A href="../ref/Text.html#_C_TEXT">
34
 Text()</A> object and then add the text object to the graph with the <A href="../ref/Graph.html#_GRAPH_ADDTEXT">
35
 AddText()</A> method.</P>
36
<P> The position of these text boxes are given as fraction of the width
37
 and height of the graph. When you are positioning these text boxes you
38
 might also choose what part of the text box should be considered the
39
 anchor point for the position you specify.</P>
40
<P> By default the anchor point is the upper left corner of the bounding
41
 box for the text.</P>
42
<P> To show some ways of positioning the text we use a very simple bar
43
 graph not to distract from the text. We first just add a single text
44
 line with most of the settings their default value by adding the
45
 following lines to the graph<DIV class="phpscript"><CODE><FONT color="#000000">
46
 <FONT color="#0000BB">&nbsp;$txt</FONT><FONT color="#007700">=new&nbsp;</FONT><FONT
47
color="#0000BB">Text</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
48
&quot;This&nbsp;is&nbsp;a&nbsp;text&quot;</FONT><FONT color="#007700">);
49
<BR></FONT><FONT color="#0000BB">$txt</FONT><FONT color="#007700">-&gt;</FONT><FONT
50
color="#0000BB">Pos</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
51
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT
52
color="#007700">);
53
<BR></FONT><FONT color="#0000BB">$txt</FONT><FONT color="#007700">-&gt;</FONT><FONT
54
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
55
&quot;red&quot;</FONT><FONT color="#007700">);
56
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
57
color="#0000BB">AddText</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
58
$txt</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT>
59
</CODE></DIV></P>
60
<P> The result is shown below.<DIV class="example">
61
<BR> <A href="exframes/frame_example25.html" target="blank"><IMG border="0"
62
HEIGHT="200"  src="img/example25.png" WIDTH="300"></A>
63
<BR><B>Figure 85:</B> Adding a single text string in the upper left
64
 corner <A href="exframes/frame_example25.html" target="blank">[src]</A>
65
&nbsp;
66
<P></P>
67
</DIV></P>
68
<P>Not too exiting. Let's make it more interesting by having a
69
 background color, using larger fonts and framing the text box and
70
 adding a drop shadow to the text box by using the methods <A href="../ref/Text.html#_TEXT_SETBOX">
71
 SetBox()</A> and <A href="../ref/Text.html#_TEXT_SETSHADOW"> SetBox()</A><DIV
72
class="example">
73
<BR> <A href="exframes/frame_example25.1.html" target="blank"><IMG border="0"
74
HEIGHT="200"  src="img/example25.1.png" WIDTH="300"></A>
75
<BR><B>Figure 86:</B> Making the text more interesting <A href="exframes/frame_example25.1.html"
76
target="blank">[src]</A>&nbsp;
77
<P></P>
78
</DIV></P>
79
<P> That's better. Now we get some attention. If you want to add a text
80
 with several lines you just need to separate the lines with a newline
81
 ('\n' character). The default paragraph alignment is left edge but you
82
 can also use right and center alignment.</P>
83
<P> As an illustration let's add a couple of more lines to the previous
84
 text, center the text box in the middle of the graph and also use
85
 centered paragraph alignment for the text. To adjust the paragraph
86
 alignment of the text you have to use the <A href="../ref/Text.html#_TEXT_PARAGRAPHALIGN">
87
 Text::ParagraphAlign()</A><DIV class="example">
88
<BR> <A href="exframes/frame_example25.2.html" target="blank"><IMG border="0"
89
HEIGHT="200"  src="img/example25.2.png" WIDTH="300"></A>
90
<BR><B>Figure 87:</B> Text with multiple lines and centered paragraph
91
 alignment <A href="exframes/frame_example25.2.html" target="blank">
92
[src]</A>&nbsp;
93
<P></P>
94
</DIV></P>
95
<P> Of course there is no limit to the number of text string you can add
96
 to the graph.</P>
97
<P> From version 1.12 it is also possible to add text strings to a graph
98
 using the scale coordinates instead. This is accomplished by using the <A
99
href="../ref/Text.html#_TEXT_SETSCALEPOS"> Text::SetScalePos()</A> Which
100
 is completely analog to SetPos() with the only difference that the
101
 positions given are interpretated as scale values instead of fractions
102
 of the width and height.</P>
103
<HR NOSHADE>
104
<A HREF="toc.html">Contents</A>
105
<A HREF="811Adjustinglabelsonatextscale.html">Previous</A>
106
<A HREF="813AddingtitlesandfooterstotheGraph.html">Next</A>
107
</BODY>
108
</HTML>