ホームページ >php教程 >php手册 >php折线图 布局图

php折线图 布局图

WBOY
WBOYオリジナル
2016-06-13 11:30:531119ブラウズ

<span 例子1:<br /> 1</span> <span <?</span><span php
</span><span  2</span> <span require_once("../conf.php");
</span><span  3</span> <span ?></span>
<span  4</span> <span <!</span><span DOCTYPE HTML</span><span ></span>
<span  5</span> <span <</span><span html</span><span ></span>
<span  6</span> <span <</span><span head</span><span ></span>
<span  7</span> <span <</span><span meta </span><span http-equiv</span><span ="Content-Type"</span><span  content</span><span ="text/html; charset=utf-8"</span> <span /></span>
<span  8</span> <span <</span><span title</span><span ></span>标准的chart显示<span </</span><span title</span><span ></span>
<span  9</span> <span </</span><span head</span><span ></span>
<span 10</span>     <span <</span><span body</span><span ></span>
<span 11</span> 
<span 12</span> <span <?</span><span php
</span><span 13</span> <span     $s2 = array(array(0, 6.29), array(0.1, 8.21), array(0.2, 8.92), array(0.3, 7.33), array(0.4, 7.91), array(0.5, 3.6), array(0.6, 6.88),
</span><span 14</span> <span       array(0.7, 1.5), array(0.8, 0.08), array(0.9, 6.36), array(1, 0.5), array(1.1, 9.14), array(1.2, 6.23), array(1.3, 2.66),
</span><span 15</span> <span       array(1.4, 9.9), array(1.5, 7.44), array(1.6, 7.82), array(1.7, 8.57), array(1.8, 3.99), array(1.9, 3.83), array(2, 6.78),
</span><span 16</span> <span       array(2.1, 7.63), array(2.2, 6.94), array(2.3, 1.24), array(2.4, 2.25), array(2.5, 0.67), array(2.6, 6.73), array(2.7, 2.25),
</span><span 17</span> <span       array(2.8, 7.72), array(2.9, 9.36), array(3, 8.49));
</span><span 18</span> 
<span 19</span> <span     /**
</span><span 20</span> <span      * 定义一个点的数组
</span><span 21</span> <span      */
</span><span 22</span> <span     $pc = new C_PhpChartX(array($s2));
</span><span 23</span> <span     /**
</span><span 24</span> <span     出现方式是否为动画显示
</span><span 25</span> <span     **/
</span><span 26</span> <span     //$pc->set_animate(true);
</span><span 27</span> <span     /**
</span><span 28</span> <span      * 设置标题
</span><span 29</span> <span      */
</span><span 30</span> <span     $pc->set_title(array('text'=>'标准折线图'));
</span><span 31</span>     
<span 32</span> <span     /**
</span><span 33</span> <span      * 设置横坐标的最小值和最大值(x)
</span><span 34</span> <span      **/
</span><span 35</span> <span     $pc->set_axes(array('xaxis'=> array('min'=>-0.5,'max'=>4)));
</span><span 36</span> <span     /**
</span><span 37</span> <span      * 设置纵坐标的最小值和最大值(y)
</span><span 38</span> <span      */
</span><span 39</span> <span     $pc->set_axes(array('yaxis'=> array('min'=>-10,'max'=>15)));
</span><span 40</span>     
<span 41</span>     
<span 42</span> <span     /**
</span><span 43</span> <span      * 设置默认线条方式
</span><span 44</span> <span      * linePattern=>dashed:设置线条为虚线,''不设置为实线.也可以为数组,数组中的参数表示将折线按照要求的数字值进行显示和隐藏,形成规则/不规则的折线
</span><span 45</span> <span      * showMarker=>true:设置显示折点加亮;false:设置节点隐藏.
</span><span 46</span> <span      * shadow=>false:设置线条没有有阴影,true:表示线条有阴影.
</span><span 47</span> <span      * lineWidth:表示折现的粗细程度。
</span><span 48</span> <span      * rendererOptions:线条操作,smooth:true:表示两点直间连接圆滑,false:表示两点之间直接连接。
</span><span 49</span> <span      */
</span><span 50</span> <span     //$pc->set_series_default(array('linePattern'=>array(2,2),'showMarker'=>true,'shadow'=>true,'lineWidth'=>3,'rendererOptions'=>array('smooth'=>true)));
</span><span 51</span> <span     $pc->set_series_default(array('linePattern'=>'','showMarker'=>true,'shadow'=>true,'lineWidth'=>3,'rendererOptions'=>array('smooth'=>false)));
</span><span 52</span> <span     /**
</span><span 53</span> <span      * 设置线条的坐标面板的显示和颜色
</span><span 54</span> <span      */
</span><span 55</span>    
<span 56</span> <span     $pc->add_series(array('label'=>'one','color'=>'red'));
</span><span 57</span>     
<span 58</span> <span     /**
</span><span 59</span> <span      * 设置折线图
</span><span 60</span> <span      **/
</span><span 61</span> <span     $pc->add_plugins(array('cursor'));
</span><span 62</span> <span     /**
</span><span 63</span> <span     showVerticalLine:表示设置是否有纵向比较线
</span><span 64</span> <span     showTooltip:表示设置是否显示纵向比较线的当前位置坐标(显示在图的右下角处)
</span><span 65</span> <span     followMouse:表示纵向比较线当前坐标是否跟随鼠标。
</span><span 66</span> <span     showTooltipDataPosition:是否让纵向比较线&ldquo;鼠标跟随坐标&rdquo;只显示在临近折点处的坐标。
</span><span 67</span> <span     tooltipFormatString:设置坐标提示格式
</span><span 68</span> <span     **/
</span><span 69</span> <span     $pc->set_cursor(array('showVerticalLine'=>true,'showTooltip'=>true,'followMouse'=>true,'showTooltipDataPosition'=>true,'zoom'=>false,'tooltipFormatString'=>'%s x:%s, y:%s'));
</span><span 70</span>     
<span 71</span>     
<span 72</span>     
<span 73</span> <span     /**
</span><span 74</span> <span     *设置图形显示的大小,即:长度和宽度。第一个参数是长度,第二个是高度
</span><span 75</span> <span     **/
</span><span 76</span> <span     $pc->draw(800,600);
</span><span 77</span> 
<span 78</span>    
<span 79</span> <span ?></span>
<span 80</span> 
<span 81</span>     <span </</span><span body</span><span ></span>
<span 82</span> <span </</span><span html</span><span ><br /><br /><br />图片显示如下:<br /><br /><br /></span>
<span>例子2:</span><br /><br />
<span  1</span> <span <?</span><span php
</span><span  2</span> <span require_once("../conf.php");
</span><span  3</span> <span ?></span>
<span  4</span> <span <!</span><span DOCTYPE HTML</span><span ></span>
<span  5</span> <span <</span><span html</span><span ></span>
<span  6</span>     <span <</span><span head</span><span ></span>
<span  7</span>           <span <</span><span style </span><span type</span><span ="text/css"</span><span  media</span><span ="screen"</span><span ></span>
<span  8</span> <span             .jqplot-axis </span><span {</span>
<span  9</span> <span               font-size</span><span :</span><span  0.85em</span><span ;</span>
<span 10</span>             <span }</span>
<span 11</span> <span             .jqplot-title </span><span {</span>
<span 12</span> <span               font-size</span><span :</span><span  1.1em</span><span ;</span>
<span 13</span>             <span }</span>
<span 14</span>           <span </</span><span style</span><span ></span>
<span 15</span>     <span </</span><span head</span><span ></span>
<span 16</span>     <span <</span><span body</span><span ></span>
<span 17</span>         <span <</span><span div</span><span ><</span><span span</span><span ></span> <span </</span><span span</span><span ><</span><span span </span><span id</span><span ="info1b"</span><span ></</span><span span</span><span ></</span><span div</span><span ></span>
<span 18</span> 
<span 19</span> <span <?</span><span php
</span><span 20</span>     
<span 21</span> 
<span 22</span> <span     $l1 = array(2, 3, 1, 4, 3);
</span><span 23</span> <span     $l2 = array(1, 4, 3, 2, 5);
</span><span 24</span>     
<span 25</span> <span     $pc = new C_PhpChartX(array($l1,$l2),'chart');
</span><span 26</span>     
<span 27</span> <span     $pc->set_title(array('text'=>'Stacked Filled Line Plot with Transparency (transparency not supported in IE6)'));
</span><span 28</span> <span     $pc->set_stack_series(true);
</span><span 29</span> <span     $pc->set_grid(array('background'=>'#fefbf3','borderWidth'=>2.5));
</span><span 30</span> <span     $pc->set_animate(true);
</span><span 31</span> <span     $pc->set_series_default(array('fill'=>true,'shadow'=>false,'showMarker'=>false));
</span><span 32</span> <span     $pc->set_axes(array(
</span><span 33</span> <span         'xaxis'=>array('pad'=>1.0,'numberTicks'=>5),
</span><span 34</span> <span         'yaxis'=>array('min'=>0,'max'=>12,'numberTicks'=>5)
</span><span 35</span> <span     ));
</span><span 36</span>     
<span 37</span> <span     $pc->add_series(array('color'=>'rgba(68, 124, 147, 0.7)'));
</span><span 38</span> <span     $pc->add_series(array('color'=>'rgba(150, 35, 90, 0.7)'));
</span><span 39</span>     
<span 40</span> <span     $pc->draw(560,400);
</span><span 41</span> 
<span 42</span> 
<span 43</span> 
<span 44</span>     <span ?></span>
<span 45</span> 
<span 46</span>     <span </</span><span body</span><span ></span>
<span 47</span> <span </</span><span html</span><span ><br /><br />显示图片如下:<br /><br /></span>

上面的代码是展示,详细代码请下载内容包:http://files.cnblogs.com/IT-Monkey/pietu.rar

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。