| 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="716Usingabackgroundgradient.html">
|
|
|
8 |
<LINK REL="Next" HREF="718Rotatinggraphs90degrees.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="716Usingabackgroundgradient.html">Previous</A>
|
|
|
26 |
<A HREF="718Rotatinggraphs90degrees.html">Next</A>
|
|
|
27 |
<HR NOSHADE>
|
|
|
28 |
<H2><A NAME="7_17">7.17 Using callbacks for Plot marks</A></H2>
|
|
|
29 |
<P> An interesting enhancement when using Plotmarks is the possibility
|
|
|
30 |
to add a callback function to control the size and color of the
|
|
|
31 |
plotmarks.</P>
|
|
|
32 |
<P> This callback function will get called with the current Y-value (for
|
|
|
33 |
the plotmark) as it's argument. As return value the callback function
|
|
|
34 |
must return an array containing three (possible null) values. The
|
|
|
35 |
values returned must be</P>
|
|
|
36 |
<OL>
|
|
|
37 |
<LI> Plot mark Weight</LI>
|
|
|
38 |
<LI> Plot mark Color</LI>
|
|
|
39 |
<LI> Plot mark Fill color</LI>
|
|
|
40 |
</OL>
|
|
|
41 |
<P> The exact meaning of the parameters will of course depend on the
|
|
|
42 |
type of plot marks being used.</P>
|
|
|
43 |
<P> The callback must be a global function and is installed with a call
|
|
|
44 |
to <A href="../ref/PlotMark.html#_PLOTMARK_SETCALLBACK">
|
|
|
45 |
PlotMark::SetCallback()</A></P>
|
|
|
46 |
<P> So for example to install a callback that changes the fill color for
|
|
|
47 |
all marks with a (Y) value higher than 90 you could add the lines</P>
|
|
|
48 |
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
|
|
|
49 |
</FONT><FONT color="#007700">function </FONT><FONT color="#0000BB">
|
|
|
50 |
MarkCallback</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
51 |
$aVal</FONT><FONT color="#007700">) {
|
|
|
52 |
<BR> if( </FONT><FONT color="#0000BB">$aVal </FONT><FONT color="#007700">
|
|
|
53 |
> </FONT><FONT color="#0000BB">90</FONT><FONT color="#007700">)
|
|
|
54 |
<BR> </FONT><FONT color="#0000BB">$fcolor</FONT><FONT color="#007700">
|
|
|
55 |
=</FONT><FONT color="#DD0000">"red"
|
|
|
56 |
<BR> </FONT><FONT color="#007700">else
|
|
|
57 |
<BR> </FONT><FONT color="#0000BB">$fcolor</FONT><FONT color="#007700">
|
|
|
58 |
=</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">;
|
|
|
59 |
<BR> return array(</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">
|
|
|
60 |
,</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">,</FONT><FONT
|
|
|
61 |
color="#0000BB">$fcolor</FONT><FONT color="#007700">);
|
|
|
62 |
<BR>}
|
|
|
63 |
<BR>...
|
|
|
64 |
<BR></FONT><FONT color="#0000BB">$plot</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
65 |
color="#0000BB">mark</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">
|
|
|
66 |
SetCallback</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
|
|
|
67 |
"MarkCallback"</FONT><FONT color="#007700">);
|
|
|
68 |
<BR>...</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
|
|
|
69 |
<P></P>
|
|
|
70 |
<P> As you can see in the above example we have left some of the return
|
|
|
71 |
values blank. Doing this will just ignore any change of these value and
|
|
|
72 |
use the global settings for the plotmarks.</P>
|
|
|
73 |
<P> If you also let the (Y) value affect the size of the plot marks you
|
|
|
74 |
can get what is sometimes known as a "balloon plot". The example below
|
|
|
75 |
is basically a scatter plot that uses filled circles to mark the
|
|
|
76 |
points. A format callback is then used to change the color and size
|
|
|
77 |
depending on the Y-value for each plot.</P>
|
|
|
78 |
<P><DIV class="example">
|
|
|
79 |
<BR> <A href="exframes/frame_balloonex1.html" target="blank"><IMG border="0"
|
|
|
80 |
HEIGHT="300" src="img/img/img/img/img/img/balloonex1.png" WIDTH="400"></A>
|
|
|
81 |
<BR><B>Figure 96:</B> Creating a balloon plot by using plot mark
|
|
|
82 |
callback function <A href="exframes/frame_balloonex1.html" target="blank">
|
|
|
83 |
[src]</A>
|
|
|
84 |
<P></P>
|
|
|
85 |
</DIV></P>
|
|
|
86 |
<P></P>
|
|
|
87 |
<HR NOSHADE>
|
|
|
88 |
<A HREF="toc.html">Contents</A>
|
|
|
89 |
<A HREF="716Usingabackgroundgradient.html">Previous</A>
|
|
|
90 |
<A HREF="718Rotatinggraphs90degrees.html">Next</A>
|
|
|
91 |
</BODY>
|
|
|
92 |
</HTML>
|