Php 用pChart渲染图像
我试图通过pChart 2.1.4库通过邮件发送图像。 该库在我的wordpress插件中使用 我尝试了以下方法:Php 用pChart渲染图像,php,pchart,Php,Pchart,我试图通过pChart 2.1.4库通过邮件发送图像。 该库在我的wordpress插件中使用 我尝试了以下方法: /* Create and populate the pData object */ $MyData = new pData(); for($i=0;$i<=30;$i++) { $MyData->addPoints(rand(1,15),"Probe 1"); } $MyData->setSerieTicks("Probe 2",4); $MyDat
/* Create and populate the pData object */
$MyData = new pData();
for($i=0;$i<=30;$i++) { $MyData->addPoints(rand(1,15),"Probe 1"); }
$MyData->setSerieTicks("Probe 2",4);
$MyData->setAxisName(0,"Temperatures");
/* Create the pChart object */
$myPicture = new pImage(700,230,$MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
/* Define the chart area */
$myPicture->setGraphArea(60,40,650,200);
/* Draw the scale */
$scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200, "DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
$myPicture->drawScale($scaleSettings);
/* Write the chart legend */
$myPicture->drawLegend(600,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Enable shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Draw the area chart */
$Threshold = "";
$Threshold[] = array("Min"=>0,"Max"=>5,"R"=>207,"G"=>240,"B"=>20,"Alpha"=>70);
$Threshold[] = array("Min"=>5,"Max"=>10,"R"=>240,"G"=>232,"B"=>20,"Alpha"=>70);
$Threshold[] = array("Min"=>10,"Max"=>20,"R"=>240,"G"=>191,"B"=>20,"Alpha"=>70);
$myPicture->drawAreaChart(array("Threshold"=>$Threshold));
/* Render the picture (choose the best way) */
$today = date("Ymd");
$curr_user = wp_get_current_user();
$img_name = $today . $curr_user->user_login . ".png";
$myPicture->render($img_name);
//#############################################################
//create mail
$message.=<<<HTML
<tr valign="top" align="center">
<img src='$img_name'>
</tr>
<tr>
<td width="25%" style="width:25%;" valign="top" align="center">
HTML;
<img src="https://ci6.googleusercontent.com/proxy/3y_3IDPObyXLCMINb1aKlZf3gh3yI9X3Co3OVv08MohNWIgv4eTR3bWw3KkcLQ=s0-d-e1-ft#http://20160727admin.png" class="CToWUd">
/*创建并填充pData对象*/
$MyData=new pData();
对于($i=0;$iaddPoints(rand(1,15),“Probe 1”);}
$MyData->setSerieTicks(“探针2”,4);
$MyData->setAxisName(0,“温度”);
/*创建pChart对象*/
$myPicture=new pImage(700230$MyData);
/*抗锯齿回合*/
$myPicture->Antialias=FALSE;
/*为图片添加边框*/
$myPicture->drawRectangle(0,0699229,数组(“R”=>0,“G”=>0,“B”=>0));
/*定义图表区域*/
$myPicture->setGraphArea(60,40650200);
/*绘制比例*/
$scaleSettings=array(“XMargin”=>10,“YMargin”=>10,“Floating”=>TRUE,“GridR”=>200,“GridG”=>200,“GridB”=>200,“DrawSubTicks”=>TRUE,“CycleBackground”=>TRUE);
$myPicture->drawScale($scaleSettings);
/*编写图表图例*/
$myPicture->drawLegend(600,20,数组(“样式”=>LEGEND\u NOBORDER,“模式”=>LEGEND\u HORIZONTAL”);
/*启用抗锯齿*/
$myPicture->antialas=TRUE;
/*启用阴影计算*/
$myPicture->setShadow(真,数组(“X”=>1,“Y”=>1,“R”=>0,“G”=>0,“B”=>0,“Alpha”=>10));
/*绘制面积图*/
$Threshold=“”;
$Threshold[]=数组(“最小”=>0,“最大”=>5,“R”=>207,“G”=>240,“B”=>20,“Alpha”=>70);
$Threshold[]=数组(“最小”=>5,“最大”=>10,“R”=>240,“G”=>232,“B”=>20,“Alpha”=>70);
$Threshold[]=数组(“最小”=>10,“最大”=>20,“R”=>240,“G”=>191,“B”=>20,“Alpha”=>70);
$myPicture->drawAreaChart(数组(“阈值”=>$Threshold));
/*渲染图片(选择最佳方式)*/
$today=日期(“Ymd”);
$curr\u user=wp\u get\u current\u user();
$img\u name=$today.$curr\u user->user\u login.“.png”;
$myPicture->render($img_name);
//#############################################################
//创建邮件
$message.=我知道有点晚了,但它会帮助其他人,犯同样的错误
OP正在使用
<img src='$img_name'>
那一定是
<img src="$img_name">
否则,它将把$img_name放在img src中,而不是$img_name的值;
另外,确保该位置上存在图像