<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Adding images and country flags to the background of the graph</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="ch14.html" title="Chapter 14. Common features for all Cartesian (x,y) 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">Adding images and country flags to the background of the graph</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 14. Common features for all Cartesian (x,y) graph types</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Adding images and country flags to the background of the graph"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec2.img-country-background"></a>Adding images and country flags to the background of the graph</h2></div></div></div> <p>The background can not only be a solid (or semi-transperant) color. It is also possible to use images as backgrounds. These can be arbitrary user specified images in any format (as determined by there file suffix). Since the library has a built in support for all established countries (as of 20 Dec 2008) in regards to there flags (all flags are encoded within the library) it is also possible to use a country flag as a background. This could be considered a special case of the user defined image background.</p> <p> </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> <p><code class="code">Graph::SetBackgroundImage($aFileName,$aBgType=BGIMG_FILLPLOT,$aImgFormat='auto')</code></p> </li><li class="listitem"> <p><code class="code">Graph::SetBackgroundImageMix($aMix)</code></p> </li><li class="listitem"> <p><code class="code">Graph::SetBackgroundImagePos($aXpos,$aYpos)</code></p> </li><li class="listitem"> <p><code class="code">Graph::SetBackgroundCountryFlag($aName,$aBgType=BGIMG_FILLPLOT,$aMix=100)</code></p> </li></ol></div><p> </p> <p>For both background images and flags it is possible to define how the image should be used on the page with the background type parameters. This parameter specifies how the image should be placed on the graph. The following options are available:</p> <p> </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> <p>BGIMG_FILLPLOT . This means that the background image will be scaled to that it exactly fits the plot area</p> </li><li class="listitem"> <p>BGIMG_FILLFRAME . This means the the background image will be scaled so that it exactly fits the entire graph</p> </li><li class="listitem"> <p>BGIMG_COPY . This means that the background image will be copied in tis original size without and size adjustments</p> </li><li class="listitem"> <p>BGIMG_CENTER . Almost the same as BGIMG_COPY but this also means that the image will be automatically centered in the graph</p> </li><li class="listitem"> <p>BGIMG_FREE, This is a variant of the BGIMG_COPY but in this case the image will be free on its own and have no color blending with the margin color</p> </li></ul></div><p> </p> <p>To help explain these types of backgrounds they are illustrated below by adding the image in <a class="xref" href="ch14s15.html#fig.background-image-for-examples" title="Figure 14.87. Background image (a closeup of our burnt server)">Figure 14.87. Background image (a closeup of our burnt server)</a> as a background to the plain graph in <a class="xref" href="ch14s15.html#fig.graph-for-background" title="Figure 14.86. The graph that will be used to add backgrounds to">Figure 14.86. The graph that will be used to add backgrounds to</a>. In order not to have the background image take to much emphasis in the graph we specify the mixing to 25% with a call to</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->SetBackgroundImageMix(25);</span></pre></td></tr></table></div><p> </p> <p> </p><div class="informaltable"> <table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td valign="bottom"> <div class="figure"><a name="fig.graph-for-background"></a><p class="title"><b>Figure 14.86. The graph that will be used to add backgrounds to</b></p><div class="figure-contents"> <div class="mediaobject"><img src="images/graph_for_background_example.png" alt="The graph that will be used to add backgrounds to"></div> </div></div><br class="figure-break"> </td><td valign="bottom"> <div class="figure"><a name="fig.background-image-for-examples"></a><p class="title"><b>Figure 14.87. Background image (a closeup of our burnt server)</b></p><div class="figure-contents"> <div class="mediaobject"><img src="images/heat1.jpg" alt="Background image (a closeup of our burnt server)"></div> </div></div><br class="figure-break"> </td></tr></tbody></table> </div><p> </p> <p>In the table below the various options for adjusting the size and position of the background image are shown</p> <p> </p><div class="informaltable"> <table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td align="center"> <p> </p><div class="figure"><a name="fig.background_type_ex0"></a><p class="title"><b>Figure 14.88. BGIMG_COPY <code class="uri"><a class="uri" href="example_src/background_type_ex0.html" target="_top">(<code class="filename">background_type_ex0.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/background_type_ex0.png" alt="BGIMG_COPY (background_type_ex0.php)"></span> </div></div><p><br class="figure-break"> </p> <p><code class="code">BGIMG_COPY</code></p> </td><td align="center"> <p> </p><div class="figure"><a name="fig.background_type_ex1"></a><p class="title"><b>Figure 14.89. BGIMG_CENTER <code class="uri"><a class="uri" href="example_src/background_type_ex1.html" target="_top">(<code class="filename">background_type_ex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/background_type_ex1.png" alt="BGIMG_CENTER (background_type_ex1.php)"></span> </div></div><p><br class="figure-break"> </p> <p><code class="code">BGIMG_CENTER</code></p> </td></tr><tr><td align="center"> <p> </p><div class="figure"><a name="fig.background_type_ex2"></a><p class="title"><b>Figure 14.90. BGIMG_FREE <code class="uri"><a class="uri" href="example_src/background_type_ex2.html" target="_top">(<code class="filename">background_type_ex2.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/background_type_ex2.png" alt="BGIMG_FREE (background_type_ex2.php)"></span> </div></div><p><br class="figure-break"> </p> <p><code class="code">BGIMG_FREE</code></p> </td><td align="center"> <p> </p><div class="figure"><a name="fig.background_type_ex3"></a><p class="title"><b>Figure 14.91. BGIMG_FILLPLOT <code class="uri"><a class="uri" href="example_src/background_type_ex3.html" target="_top">(<code class="filename">background_type_ex3.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/background_type_ex3.png" alt="BGIMG_FILLPLOT (background_type_ex3.php)"></span> </div></div><p><br class="figure-break"> </p> <p><code class="code">BGIMG_FILLPLOT</code></p> </td></tr><tr><td align="center"> <p> </p><div class="figure"><a name="fig.background_type_ex4"></a><p class="title"><b>Figure 14.92. BGIMG_FILLFRAME <code class="uri"><a class="uri" href="example_src/background_type_ex4.html" target="_top">(<code class="filename">background_type_ex4.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/background_type_ex4.png" alt="BGIMG_FILLFRAME (background_type_ex4.php)"></span> </div></div><p><br class="figure-break"> </p> <p><code class="code">BGIMG_FILLFRAME</code></p> </td><td> </td></tr></tbody></table> </div><p> </p> <p></p> <div class="sect2" title="Using country flags as backgrounds"><div class="titlepage"><div><div><h3 class="title"><a name="id2553256"></a>Using country flags as backgrounds</h3></div></div></div> <p>The method <code class="code">Graph::SetBackgroundCountryFlag($aName,$aBgType,$aMix)</code> makes it possible to use an of the built-in country flags as a background i the same way as any other user specified background image. All included country flags as of Dec 2008 are listed in <a class="xref" href="apf.html" title="Appendix F. List of all country flags">Appendix F. <i>List of all country flags</i></a>. The background country flag is specified by its short name as listed in <a class="xref" href="apf.html" title="Appendix F. List of all country flags">Appendix F. <i>List of all country flags</i></a>.</p> <p> </p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3> <p>The dynamics of world politics and geographic boundaries will no doubt make the list of included countries obsolete almost at the same time the library is released. The intention is that all currently known country and similar geographic entities should be included. Any missing flags shall and can not be interpreted as any political stand it is merely a consequence of political changes since the library was released or a possible oversight or simply a mistake either human or algorithmically in how the country flags are produced. </p> </div><p> </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="ch14.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>