This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/ch16s02.html

495 lines
50 KiB
HTML
Raw Normal View History

2011-05-28 09:51:52 +00:00
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Radar graphs</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch16.html" title="Chapter 16. Non-Linear graph types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Radar graphs</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 16. Non-Linear graph types</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Radar graphs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.radar-graphs"></a>Radar graphs</h2></div></div></div>
<p>In order to create Radar graphs the module
"<code class="filename">jpgraph_radar.php</code>" must first be included. </p>
<p>Radar plots are most often used to display how a number of results compare to some
set targets. They make good use of the human ability to spot symmetry (or rather
un-symmetry). Radar plots are not suitable if high accuracy readings from the graph
are needed since, by it's nature, it can be difficult to read out very detailed
values. </p>
<p><a class="xref" href="ch16s02.html#fig.radarex7" title="Figure 16.33. A typical radar graph with two radar plots added (radarex7.php)">Figure 16.33. A typical radar graph with two radar plots added <code class="uri"><a class="uri" href="example_src/radarex7.html" target="_top">(<code class="filename">radarex7.php</code>)</a></code> </a> shows a basic radar graph with two radar plots
added.</p>
<p>
</p><div class="figure"><a name="fig.radarex7"></a><p class="title"><b>Figure 16.33. A typical radar graph with two radar plots added <code class="uri"><a class="uri" href="example_src/radarex7.html" target="_top">(<code class="filename">radarex7.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarex7.png" alt="A typical radar graph with two radar plots added (radarex7.php)"></span> </div></div><p><br class="figure-break">
</p>
<p>Radar graphs are created as an instance of <code class="code">class RadarGraph</code> which
inherits all common formatting options from the standard <code class="code">class Graph</code>
such as titles, background colors, background titles, etc. </p>
<p>
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
<p>Tabbed titles cannot not be used for radar graphs since there is no
applicable concept of a plot area</p>
</div><p>
</p>
<p>The following facts applies to a radar graph</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p>There is one axis for each data point</p>
</li><li class="listitem">
<p>Each axis may have an arbitrary title which is automatically
positioned</p>
</li><li class="listitem">
<p>A radar plot may be filled or open</p>
</li><li class="listitem">
<p>The first axis is always oriented vertical and is the only axis with
labels</p>
</li><li class="listitem">
<p>Several radar plots can be combined in one radar graph</p>
</li><li class="listitem">
<p>Axis can have either linear or logarithmic scale on the axis</p>
</li></ul></div><p>
</p>
<p>In addition all the normal formatting of labels, background colors, grid lines,
plot colors, fill colors etc. can be adjusted. The rest of this sections will show
some of the typical formatting options available.</p>
<div class="sect2" title="Adding radar plots to a radar graph"><div class="titlepage"><div><div><h3 class="title"><a name="id2567444"></a>Adding radar plots to a radar graph</h3></div></div></div>
<p>The principle is exactly the same as for line plots but instead of an x-y
coordinate each data point represents a value on one of the axis. The number of
axis will automatically be the same as the number of data points. Even through
the library itself does not impose any restrictions on the number of axis there
is a practical limit so it is probably best to keep the number of data points
limited to around 10-12.</p>
<p>Typical data set for a radar plot is then given as</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$data = array( axis&lt;1&gt;_value, axis&lt;2&gt;_value, ..., axis&lt;n&gt;_value );</span></pre></td></tr></table></div><p>
</p>
<p>The plot points are assigned to the axis in a counter-clockwise direction
starting at 12 a'clock. If clock-wise order is needed the input data must be
reversed.</p>
<p>Creation of a radar graph follows the now familiar steps of first creating an
instance of <code class="code">class RadarGraph</code> and then adding one or several
instances of <code class="code">class RadarPlot </code>as the following code snippet
shows</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Some data</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$data1</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> ... </span><span class="hl-brackets">)</span><span class="hl-code"> ;
</span><span class="hl-var">$data2</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> ... </span><span class="hl-brackets">)</span><span class="hl-code"> ;
</span><span class="hl-var">$width</span><span class="hl-code"> = ... ;
</span><span class="hl-var">$height</span><span class="hl-code"> = ... ;
</span><span class="hl-comment">//</span><span class="hl-comment"> Setup a basic radar graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">RadarGraph</span><span class="hl-brackets">(</span><span class="hl-var">$width</span><span class="hl-code">,</span><span class="hl-var">$height</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">lin</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Add a title to the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Quality result</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> .. add any other common graph formatting</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create the first radar plot with formatting</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$plot1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">RadarPlot</span><span class="hl-brackets">(</span><span class="hl-var">$data1</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot1</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLegend</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Goal</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot1</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-code">̈́</span><span class="hl-identifier">red</span><span class="hl-quotes">'</span><span class="hl-string">, </span><span class="hl-quotes">'</span><span class="hl-identifier">lightred</span><span class="hl-quotes">'</span><span class="hl-string">);
// Create the second radar plot
$plot2 = new RadarPlot($data2);
$plot2-&gt;SetLegend(</span><span class="hl-quotes">'</span><span class="hl-identifier">Actual</span><span class="hl-quotes">'</span><span class="hl-string">);
$plot2-&gt;SetColor(</span><span class="hl-quotes">'</span><span class="hl-identifier">blue</span><span class="hl-quotes">'</span><span class="hl-string">, </span><span class="hl-quotes">'</span><span class="hl-identifier">lightred</span><span class="hl-quotes">'</span><span class="hl-string">);
// Add the plots to the graph
$graph-&gt;Add($plot2);
$graph-&gt;Add($plot1);
// and display the graph
$graph-&gt;stroke()
?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>As an illustration two very basic radar graphs with one radar plot each are
displayed below. The left figure uses only default values and the right figure
uses the ame data but adjusts a few properties to make the graph a bit more
interesting.</p>
<p>
</p><div class="informaltable">
<table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td>
<div class="figure"><a name="fig.radarex1"></a><p class="title"><b>Figure 16.34. A basic radargraph with no formatting <code class="uri"><a class="uri" href="example_src/radarex1.html" target="_top">(<code class="filename">radarex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarex1.png" alt="A basic radargraph with no formatting (radarex1.php)"></span> </div></div><br class="figure-break">
</td><td>
<div class="figure"><a name="fig.radarex2"></a><p class="title"><b>Figure 16.35. A basic radargraph with minimal formatting <code class="uri"><a class="uri" href="example_src/radarex2.html" target="_top">(<code class="filename">radarex2.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarex2.png" alt="A basic radargraph with minimal formatting (radarex2.php)"></span> </div></div><br class="figure-break">
</td></tr></tbody></table>
</div><p>
</p>
<p>Each radar plot can also have a legend. As usual the text for the legend is
created by using the method</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarPlot::SetLegend($aText)</code></p>
</li></ul></div><p>
</p>
<p>The legend box is accessed through the "$legend" property of the graph and
this can be used to adjust the size, position and layout of the legend box (as
described in <a class="xref" href="ch14s04.html" title="Adjusting the position and layout of the legend">Adjusting the position and layout of the legend</a>).</p>
</div>
<div class="sect2" title="Adding plot-marks to radar plots"><div class="titlepage"><div><div><h3 class="title"><a name="id2567446"></a>Adding plot-marks to radar plots</h3></div></div></div>
<p>In exactly the same way as for line graphs it is possible to add plot marks in
radar plots. The mark property is accessed through the instance variable</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarPlot::mark </code></p>
</li></ul></div><p>
</p>
<p>(All available plot marks are listed in <a class="xref" href="ape.html" title="Appendix E. Available plot marks">Appendix E. <i>Available plot marks</i></a>)</p>
<p>For example to add a red ball marker the following line must be added</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$radarplot-&gt;mark-&gt;SetType(MARK_IMG_SBALL,'red');</span></pre></td></tr></table></div><p>
</p>
<p>In <a class="xref" href="ch16s02.html#fig.radarmarkex1" title="Figure 16.36. Adding plot marks to a radar graph (radarmarkex1.php)">Figure 16.36. Adding plot marks to a radar graph <code class="uri"><a class="uri" href="example_src/radarmarkex1.html" target="_top">(<code class="filename">radarmarkex1.php</code>)</a></code> </a> we show a radar graph with added
plot-marks. In addition we have also chosen to hide the tick marks on the axis
and adjust some of the default colors.</p>
<p>
</p><div class="figure"><a name="fig.radarmarkex1"></a><p class="title"><b>Figure 16.36. Adding plot marks to a radar graph <code class="uri"><a class="uri" href="example_src/radarmarkex1.html" target="_top">(<code class="filename">radarmarkex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarmarkex1.png" alt="Adding plot marks to a radar graph (radarmarkex1.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Client Side Image maps"><div class="titlepage"><div><div><h3 class="title"><a name="id2567709"></a>Client Side Image maps</h3></div></div></div>
<p>(See <a class="xref" href="ch10.html" title="Chapter 10. Using CSIM (Client side image maps)">Chapter 10. <i>Using CSIM (Client side image maps)</i></a> for a full description on the usage
of CSIM together with the library)</p>
<p>If markers are shown for the polar plot (by setting the mark property of the
plot) each marker can be a hot spot in a client side image map. The target URL
are as usual specified with the<code class="code"> SetCSIMTargets()</code> as the following
short code snippet shows</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Start by specifying the proper URL targets</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$targets</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-quotes">&quot;</span><span class="hl-string">#1</span><span class="hl-quotes">&quot;</span><span class="hl-code"> , </span><span class="hl-quotes">&quot;</span><span class="hl-string">#2</span><span class="hl-quotes">&quot;</span><span class="hl-code"> , ....... </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$radarplot</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">RadarPlot</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$data</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$radarplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">mark</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetType</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">MARK_SQUARE</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$radarplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetCSIMTargets</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$targets</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$radarplot</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">StrokeCSIM</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
</div>
<div class="sect2" title="Adjusting the overall properties of the radar graph"><div class="titlepage"><div><div><h3 class="title"><a name="id2567731"></a>Adjusting the overall properties of the radar graph</h3></div></div></div>
<p>The scale of the axis can be either a linear or a logarithmic scale and is
specified with the method</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::SetScale($aScale, $aYMin=1,
$aYMax=1)</code></p>
<p>The scale is specified as a string and can be either
"<code class="code">lin</code>" or "<code class="code">log</code>"</p>
</li></ul></div><p>
</p>
<p>The size and position of the radar graph are adjusted by the two
methods</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::SetSize($aSize)</code></p>
<p>The size is specified as a fraction of min($weight,$height) and
indicates the length of the axis.</p>
</li><li class="listitem">
<p><code class="code">RadarGraph::SetCenter($aXPos, $aYPos=0.5)</code></p>
<p>The center of the graph can be specified as either a fraction of
the width/height or as an absolute position.</p>
</li></ul></div><p>
</p>
<p>The background color can be adjusted by</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::SetColor($aColor)</code></p>
</li></ul></div><p>
</p>
</div>
<div class="sect2" title="Adjusting the axis formatting"><div class="titlepage"><div><div><h3 class="title"><a name="id2567884"></a>Adjusting the axis formatting</h3></div></div></div>
<p>All axis have the same formatting and the axis is access through the "$axis"
property of the RadarGraph class. For example make the axis 2 pixels wide the
following lines would be needed</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$radargraph = new RadarGraph($width,$height);
$radargraph-&gt;axis-&gt;SetWeight(2);</span></pre></td></tr></table></div><p>
</p>
<p>The axis supports all the same formatting options as for standard x-y graphs.
Some of the more commonly used methods for the axis formatting are</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">Axis::SetColor($aColor,$aLabelColor=false)</code></p>
<p>Set the color of the axis and (optional) the labels </p>
</li><li class="listitem">
<p><code class="code">Axis::SetWeight($aWeight)</code></p>
<p>Specifies width in pixels of the axis</p>
</li><li class="listitem">
<p><code class="code">Axis::SetLabelFormatString($aFormStr,$aIsDateFormat=false)</code></p>
<p>Specify the format string to be used for the labels </p>
</li><li class="listitem">
<p><code class="code">Axis::SetLabelFormatCallback($aFuncName)</code></p>
<p>Set the callback function to be used for the label
formatting</p>
</li><li class="listitem">
<p><code class="code">Axis::SetFont($aFamily,$aStyle,$aSize)</code></p>
<p>Sets the font property for the labels of the axis. Note that this
will <span class="bold"><strong>not</strong></span> effect the font property
of the title of the axis.</p>
</li></ul></div><p>
</p>
<p>In order to specify the titles for each axis the method </p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::SetTitles($aTitleArray)</code></p>
<p>The argument is an array with as many entries as there are axis
and where each entry specifies a text string which is the title of
the axis.</p>
<div class="example"><a name="id2568024"></a><p class="title"><b>Example 16.4. Having the name of the months as title of the axis</b></p><div class="example-contents">
<p>The easiest way to have the month name as titles is to use the
library global variable "<code class="code">$gDateLocale</code>" as
follows</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$titles = $gDateLocale-&gt;GetShortMonth();
$radargraph-&gt;SetTitles( $titles );</span></pre></td></tr></table></div><p>
</p>
</div></div><br class="example-break">
</li></ul></div><p>
</p>
<p>In order to adjust the property of the title for the axis the
"<code class="code">$title</code>" property of the axis is used. For example, to set the
font and color for the titles of the axis the following two lines are
needed</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$radargraph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">axis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFont</span><span class="hl-brackets">(</span><span class="hl-identifier">FF_ARIAL</span><span class="hl-code">,</span><span class="hl-identifier">FS_BOLD</span><span class="hl-code">,</span><span class="hl-number">12</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$radargraph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">axis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">darkred</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>The tick marks can also be adjusted with the following methods</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::HideTickMarks($aFlag=true)</code></p>
<p>Hide all tick marks</p>
</li><li class="listitem">
<p><code class="code">RadarGraph::ShowMinorTickmarks($aFlag=true)</code></p>
<p>Enable/Disable tick marks</p>
</li><li class="listitem">
<p><code class="code">RadarGraph::SetTickDensity($aDensity=TICKD_NORMAL)</code></p>
<p>Adjust the tick density</p>
</li></ul></div><p>
</p>
</div>
<div class="sect2" title="Adjusting grid lines for the radar graph"><div class="titlepage"><div><div><h3 class="title"><a name="id2568086"></a>Adjusting grid lines for the radar graph</h3></div></div></div>
<p>Each major tick mark can also be connected together to create a grid in the
graph. The grid is accessed through the '<code class="code">$grid</code>' property of the
graph. To enable the grid and set the line style to "dotted" the following two
lines must be added</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$radargraph-&gt;grid-&gt;Show ();
$radargraph-&gt;grid-&gt;SetLineStyle( 'dashed' );</span></pre></td></tr></table></div><p>
</p>
<p>An example of dashed grid lines are shown in <a class="xref" href="ch16s02.html#fig.radarex4" title="Figure 16.37. Enabling a dashed grid line (radarex4.php)">Figure 16.37. Enabling a dashed grid line <code class="uri"><a class="uri" href="example_src/radarex4.html" target="_top">(<code class="filename">radarex4.php</code>)</a></code> </a>. By default the grid lines have a gray color and are drawn behind the radar
plot and hence part of the grid lines are obscured.</p>
<p>The property of the grid lines are adjusted by accessing the
"<code class="code">$grid</code>" line. The available methods to format grid lines
are:</p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::grid::Show($aShowMajor=true)</code></p>
<p>Enable grid lines</p>
</li><li class="listitem">
<p><code class="code">RadarGraph::grid::SetColor($aMajColor)</code></p>
<p>Set the color of the grid lines</p>
</li><li class="listitem">
<p><code class="code">RadarGraph::grid::SetWeight($aWeight)</code></p>
<p>Set the weight of the grid line</p>
</li><li class="listitem">
<p><code class="code">RadarGraph::grid::SetLineStyle($aType)</code></p>
<p>Set the line style, can be one of
"<code class="code">dotted</code>","<code class="code">dashed</code>","l<code class="code">ong-dash</code>","<code class="code">solid</code>"</p>
</li></ul></div><p>
</p>
<p>To make the grid lines in <a class="xref" href="ch16s02.html#fig.radarex4" title="Figure 16.37. Enabling a dashed grid line (radarex4.php)">Figure 16.37. Enabling a dashed grid line <code class="uri"><a class="uri" href="example_src/radarex4.html" target="_top">(<code class="filename">radarex4.php</code>)</a></code> </a> more visible lets
change the color by using the <code class="code">SetColor()</code> method on the grid. In
addition we can also adjust the background color. The result of this is shown in
<a class="xref" href="ch16s02.html#fig.radarex6" title="Figure 16.38. Enabling a dashed grid line with red (radarex6.php)">Figure 16.38. Enabling a dashed grid line with red <code class="uri"><a class="uri" href="example_src/radarex6.html" target="_top">(<code class="filename">radarex6.php</code>)</a></code> </a></p>
<p>
</p><div class="informaltable">
<table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td>
<div class="figure"><a name="fig.radarex4"></a><p class="title"><b>Figure 16.37. Enabling a dashed grid line <code class="uri"><a class="uri" href="example_src/radarex4.html" target="_top">(<code class="filename">radarex4.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarex4.png" alt="Enabling a dashed grid line (radarex4.php)"></span> </div></div><br class="figure-break">
</td><td>
<div class="figure"><a name="fig.radarex6"></a><p class="title"><b>Figure 16.38. Enabling a dashed grid line with red <code class="uri"><a class="uri" href="example_src/radarex6.html" target="_top">(<code class="filename">radarex6.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarex6.png" alt="Enabling a dashed grid line with red (radarex6.php)"></span> </div></div><br class="figure-break">
</td></tr></tbody></table>
</div><p>
</p>
</div>
<div class="sect2" title="Using a logarithmic scale"><div class="titlepage"><div><div><h3 class="title"><a name="id2568340"></a>Using a logarithmic scale</h3></div></div></div>
<p>In order to change the (default) linear scale o the axis to use logarithmic
scale the following line must be added: </p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$graph-&gt;SetScale('log');</span></pre></td></tr></table></div><p>
</p>
<p>
<a class="xref" href="ch16s02.html#fig.radarlogex1" title="Figure 16.39. Using a logarithmic scale (radarlogex1.php)">Figure 16.39. Using a logarithmic scale <code class="uri"><a class="uri" href="example_src/radarlogex1.html" target="_top">(<code class="filename">radarlogex1.php</code>)</a></code> </a> shows an example of a logarithmic radar
graph </p>
<p>
</p><div class="figure"><a name="fig.radarlogex1"></a><p class="title"><b>Figure 16.39. Using a logarithmic scale <code class="uri"><a class="uri" href="example_src/radarlogex1.html" target="_top">(<code class="filename">radarlogex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarlogex1.png" alt="Using a logarithmic scale (radarlogex1.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Enabling anti-aliasing for radar graphs"><div class="titlepage"><div><div><h3 class="title"><a name="id2568414"></a>Enabling anti-aliasing for radar graphs</h3></div></div></div>
<p>Radar graph are an excellent example where enabling anti-alias can make a
large visual difference. In order to enable anti-aliasing the method </p>
<p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p><code class="code">RadarGraph::img::SetAntiAliasing($aFlg=true)</code></p>
</li></ul></div><p>
</p>
<p>must be called, for example as in</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$radargraph-&gt;img-&gt;SetAntiAliasing();</span></pre></td></tr></table></div><p>
</p>
<p>To give an example of this <a class="xref" href="ch16s02.html#fig.radarlogex1-aa" title="Figure 16.40. Enabling anti-alias for the logarithmic radar example (radarlogex1-aa.php)">Figure 16.40. Enabling anti-alias for the logarithmic radar example <code class="uri"><a class="uri" href="example_src/radarlogex1-aa.html" target="_top">(<code class="filename">radarlogex1-aa.php</code>)</a></code> </a> shows an
anti-aliased version of <a class="xref" href="ch16s02.html#fig.radarlogex1" title="Figure 16.39. Using a logarithmic scale (radarlogex1.php)">Figure 16.39. Using a logarithmic scale <code class="uri"><a class="uri" href="example_src/radarlogex1.html" target="_top">(<code class="filename">radarlogex1.php</code>)</a></code> </a> . (Another
comparative example of enabling anti-aliasing is also given in <a class="xref" href="ch14s13.html#fig.radarex8" title="Figure 14.80. Plain radar plot (radarex8.php)">Figure 14.80. Plain radar plot <code class="uri"><a class="uri" href="example_src/radarex8.html" target="_top">(<code class="filename">radarex8.php</code>)</a></code> </a> and <a class="xref" href="ch14s13.html#fig.radarex8.1" title="Figure 14.81. Anti-aliased radar plot (radarex8.1.php)">Figure 14.81. Anti-aliased radar plot <code class="uri"><a class="uri" href="example_src/radarex8.1.html" target="_top">(<code class="filename">radarex8.1.php</code>)</a></code> </a>.)</p>
<p>
</p><div class="figure"><a name="fig.radarlogex1-aa"></a><p class="title"><b>Figure 16.40. Enabling anti-alias for the logarithmic radar example <code class="uri"><a class="uri" href="example_src/radarlogex1-aa.html" target="_top">(<code class="filename">radarlogex1-aa.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/radarlogex1-aa.png" alt="Enabling anti-alias for the logarithmic radar example (radarlogex1-aa.php)"></span> </div></div><p><br class="figure-break">
</p>
<p>
</p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3>
<p>Remember the limitation when using anti-aliasing that lines will be
given line weight=1 regardless of the specified weight.</p>
</div><p>
</p>
</div>
<div class="sect2" title="A final example"><div class="titlepage"><div><div><h3 class="title"><a name="id2568558"></a>A final example</h3></div></div></div>
<p>As a final example we shown a radar graphs were we have adjusted many of the
available properties, such as specifying a manual scale, to achieve the result
shown in <a class="xref" href="ch16s02.html#fig.fixscale_radarex1" title="Figure 16.41. A more complex example of a radar graph with a manual scale (fixscale_radarex1.php)">Figure 16.41. A more complex example of a radar graph with a manual scale <code class="uri"><a class="uri" href="example_src/fixscale_radarex1.html" target="_top">(<code class="filename">fixscale_radarex1.php</code>)</a></code> </a></p>
<p>
</p><div class="example"><a name="example.fixscale_radarex1"></a><p class="title"><b>Example 16.5. A more complex example of a radar graph with a manual scale (<code class="filename">fixscale_radarex1.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment"> content=&quot;text/plain; charset=utf-8&quot;</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/jpgraph.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/jpgraph_radar.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">RadarGraph</span><span class="hl-brackets">(</span><span class="hl-number">300</span><span class="hl-code">,</span><span class="hl-number">300</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">lin</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">50</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yscale</span><span class="hl-code">-&gt;</span><span class="hl-identifier">ticks</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-number">25</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">white</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetShadow</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetCenter</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.5</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-number">.55</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">axis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFont</span><span class="hl-brackets">(</span><span class="hl-identifier">FF_FONT1</span><span class="hl-code">,</span><span class="hl-identifier">FS_BOLD</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">axis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetWeight</span><span class="hl-brackets">(</span><span class="hl-number">2</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Uncomment the following lines to also show grid lines.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">grid</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLineStyle</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">dashed</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">grid</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">navy@0.5</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">grid</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Show</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">ShowMinorTickMarks</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Quality result</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFont</span><span class="hl-brackets">(</span><span class="hl-identifier">FF_FONT1</span><span class="hl-code">,</span><span class="hl-identifier">FS_BOLD</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetTitles</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">One</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Two</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Three</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Four</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Five</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Sex</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Seven</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Eight</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Nine</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">Ten</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">RadarPlot</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">35</span><span class="hl-code">,</span><span class="hl-number">20</span><span class="hl-code">,</span><span class="hl-number">30</span><span class="hl-code">,</span><span class="hl-number">33</span><span class="hl-code">,</span><span class="hl-number">15</span><span class="hl-code">,</span><span class="hl-number">37</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLegend</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Goal</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">red</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">lightred</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFillColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">lightblue</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$plot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLineWeight</span><span class="hl-brackets">(</span><span class="hl-number">2</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$plot</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.fixscale_radarex1"></a><p class="title"><b>Figure 16.41. A more complex example of a radar graph with a manual scale <code class="uri"><a class="uri" href="example_src/fixscale_radarex1.html" target="_top">(<code class="filename">fixscale_radarex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/fixscale_radarex1.png" alt="A more complex example of a radar graph with a manual scale (fixscale_radarex1.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch16.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>