免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1970 | 回复: 1
打印 上一主题 下一主题

我在linux下搭好环境后,运行下列代码,不出图是怎么回事? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-09 10:39 |只看该作者 |倒序浏览
<?php

require_once 'phplot.php';

//设置数据

$data = array(

  array('2010',  10,  2),

  array('2011',  15,  ,

  array('2012',  20,   14),

  array('2013',  25,   24),

  array('2014',  30,   35),

  array('2015',  35,   45),

  array('2016',  40,   60)

);



$p = new PHPlot(600, 300);



$p->SetDefaultTTFont('Fonts/simhei.ttf'); //设置字体,还是支持中文的吧

$p->SetTitle(iconv_arr('Phpwind疾风学院男女人数比例')); //设置标题,还是用iconv_arr来解决中文



# Select the data array representation and store the data:

$p->SetDataType('text-data'); //设置使用的数据类型,在这个里面可以使用多种类型。

$p->SetDataValues($data); //把一个数组$data赋给类的一个变量$this->data_values.要开始作图之前调用。

$p->SetPlotType('lines'); //选择图表类型为线性.可以是bars,lines,linepoints,area,points,pie等。



$p->SetPlotAreaWorld(0, 0, 7, 100);  //设置图表边距



# Select an overall image background color and another color under the plot:

$p->SetBackgroundColor('#ffffcc'); //设置整个图象的背景颜色。

$p->SetDrawPlotAreaBackground(True); //设置节点区域的背景

$p->SetPlotBgColor('#ffffff'); //设置使用SetPlotAreaPixels()函数设定的区域的颜色。

$p->SetLineWidth(3);  //线条宽度

# Draw lines on all 4 sides of the plot:

$p->SetPlotBorderType('full');  //设置线条类型



# Set a 3 line legend, and position it in the upper left corner:

$p->SetLegend(iconv_arr(array('男生人数', '女生人数'))); //显示在一个图列框中的说明

$p->SetLegendWorld(0.3, 95); //设定这个文本框位置



# Generate and output the graph now:

$p->DrawGraph();



function iconv_arr($data){

       if(is_array($data)){

          foreach($data as $k=>$v){

              $data[$k] = iconv_arr($v);

          }

       }else{

          $data = mb_convert_encoding($data, "html-entities","gbk" );

       }

       return $data;

}

论坛徽章:
0
2 [报告]
发表于 2011-12-09 17:44 |只看该作者
回复 1# 珍珍来了


    1,开启代码调试
        php.ini修改display_errors=On

    2,确认linux系统安装了gd库
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP