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="716Usingabackgroundgradient.html"><LINK REL="Next" HREF="718Rotatinggraphs90degrees.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="716Usingabackgroundgradient.html">Previous</A><A HREF="718Rotatinggraphs90degrees.html">Next</A><HR NOSHADE><H2><A NAME="7_17">7.17 Using callbacks for Plot marks</A></H2><P> An interesting enhancement when using Plotmarks is the possibilityto add a callback function to control the size and color of theplotmarks.</P><P> This callback function will get called with the current Y-value (forthe plotmark) as it's argument. As return value the callback functionmust return an array containing three (possible null) values. Thevalues returned must be</P><OL><LI> Plot mark Weight</LI><LI> Plot mark Color</LI><LI> Plot mark Fill color</LI></OL><P> The exact meaning of the parameters will of course depend on thetype of plot marks being used.</P><P> The callback must be a global function and is installed with a callto <A href="../ref/PlotMark.html#_PLOTMARK_SETCALLBACK">PlotMark::SetCallback()</A></P><P> So for example to install a callback that changes the fill color forall marks with a (Y) value higher than 90 you could add the lines</P><P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB"> </FONT><FONT color="#007700">function </FONT><FONT color="#0000BB">MarkCallback</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$aVal</FONT><FONT color="#007700">) {<BR> if( </FONT><FONT color="#0000BB">$aVal </FONT><FONT color="#007700">> </FONT><FONT color="#0000BB">90</FONT><FONT color="#007700">) <BR> </FONT><FONT color="#0000BB">$fcolor</FONT><FONT color="#007700">=</FONT><FONT color="#DD0000">"red"<BR> </FONT><FONT color="#007700">else<BR> </FONT><FONT color="#0000BB">$fcolor</FONT><FONT color="#007700">=</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">;<BR> return array(</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">""</FONT><FONT color="#007700">,</FONT><FONTcolor="#0000BB">$fcolor</FONT><FONT color="#007700">);<BR>}<BR>...<BR></FONT><FONT color="#0000BB">$plot</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">mark</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">SetCallback</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">"MarkCallback"</FONT><FONT color="#007700">);<BR>...</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P><P></P><P> As you can see in the above example we have left some of the returnvalues blank. Doing this will just ignore any change of these value anduse the global settings for the plotmarks.</P><P> If you also let the (Y) value affect the size of the plot marks youcan get what is sometimes known as a "balloon plot". The example belowis basically a scatter plot that uses filled circles to mark thepoints. A format callback is then used to change the color and sizedepending on the Y-value for each plot.</P><P><DIV class="example"><BR> <A href="exframes/frame_balloonex1.html" target="blank"><IMG border="0"HEIGHT="300" src="img/img/img/img/img/img/balloonex1.png" WIDTH="400"></A><BR><B>Figure 96:</B> Creating a balloon plot by using plot markcallback function <A href="exframes/frame_balloonex1.html" target="blank">[src]</A> <P></P></DIV></P><P></P><HR NOSHADE><A HREF="toc.html">Contents</A><A HREF="716Usingabackgroundgradient.html">Previous</A><A HREF="718Rotatinggraphs90degrees.html">Next</A></BODY></HTML>