如何用php作线形图的函数_PHP-php教程
作者:二十三点二十三分_465 | 来源:互联网 | 2017-05-14 02:18
很高兴大家对PHP如此的情有独钟!下面就给大家介绍php作线形图的函数:*函数说明$data:y轴数据(数组)$graphdata:y轴数据--百分比(数组)$label:x轴数据(数组)$height:图像高度$width:图像宽度$font:字号$dot:决定点的大小$bg:背景色$line:线色$text
很高兴大家对PHP如此的情有独钟!
下面就给大家介绍php作线形图的函数:
/*
函数说明
$data:y轴数据(数组)
$graphdata:y轴数据--百分比(数组)
$label:x轴数据(数组)
$height:图像高度
$width:图像宽度
$font:字号
$dot:决定点的大小
$bg:背景色
$line :线色
$text :文本色
$dotcolor:点色
$file:输出图像文件名
*/
function qximage($data ,
$graphdata,
$label ,
$height,
$width ,
$font,
$dot,
$bg,
$line,
$text,
$dotcolor,
$file)
{
$jc=$height/100;
$fOntwidth= imagefontwidth ($font);
$fOntheight=imagefontheight($font);
$image= imagecreate ($width,$height+20);
$bg= imagecolorallocate($image ,$bg[0],$bg[1],$bg[2]);
$line=imagecolorallocate($image ,$line[0],$line[1],$line[2]);
$text=imagecolorallocate($image ,$text[0],$text[1],$text[2]);
$dotcolor=imagecolorallocate($image ,$dotcolor[0],$dotcolor[1],$$dotcolor[2]);
imageline ($image,0,0,0,$height,$line);
imageline($image,0,$height,$width,$height,$line);
for ($i=1;$i<11;$i++)
{
imagedashedline($image,0,$height - $jc*$i*10 ,$width ,$height -$jc*$i*10 ,$line );
imagestring ($image,$font,0,$height-$jc*$i*10,$i*10,$text);
}
for ($i=0;$i {
#echo $tmp."
";
$x1=(($width-50)/count($data))*($i)+40;
#echo $x1 ."
";
$y1=$height-$graphdata[$i]*$jc;
$x2=$x1;
$y2=$y1+$graphdata[$i]*$jc;
#echo $y1."
";
imagestring($image,$font,$x1,$y1-2*$fontheight,$graphdata[$i]."%(".$data[$i].")",$text);
imagearc ($image,$x1 ,$y1,$dot,$dot,0,360,$dotcolor);
imagefilltoborder ($image,$x1,$y1,$dotcolor,$dotcolor);
imagestring ($image,$font,$x1,$y2,$label[$i],$text);
if ($i>0)
{
imageline($image,$tmpx1,$tmpy1,$x1,$y1,$line);
}
$tmpx1=$x1;$tmpy1=$y1;
}
imagegif ($image,$file);
}
?>
推荐阅读
-
概念:组合模式(CompositePattern)将对象组合成树形结构以表示“部分-整体”的层次结构,组合模式使得用户对单个对象和组合对象的使用具有一致性。有时候又叫做部分-整体模 ...
[详细]
蜡笔小新 2023-09-23 15:55:31
-
2019独角兽企业重金招聘Python工程师标准MPP结构:129GTM节点,130coordinator、gtm_proxy、datanode& ...
[详细]
蜡笔小新 2023-10-12 18:49:46
-
-
Matlab:数学之美–绘制分形图形学习最好的动力是兴趣,所以我们先看看效果:这一篇与Java学习日记:数学之美-分形图形绘制有共同之处,只是所用的工具不同。clear;%不同的参 ...
[详细]
蜡笔小新 2023-10-11 15:36:53
-
A题这题贼水,直接暴力就可以了。用个bool数组记录一下,如果某一天,当前剩下的最大的出现了的话,就输出一段。1#include<stdio.h>2intn;3boolvi ...
[详细]
蜡笔小新 2023-10-11 15:01:52
-
#-*-coding:utf-8-*-print(upython与开源QGis课题研究组)#print(汉字)##创建矢量数据文件#try:fromosgeoimporto ...
[详细]
蜡笔小新 2023-10-11 07:51:54
-
主函数:CStringGetCPUIDString()Copyright(C)shangweixiao2011 ...
[详细]
蜡笔小新 2023-10-10 21:37:36
-
1引言在多线程并发编程中Synchronized一直是元老级角色,很多人都会称呼它为重量级锁,但是随着JavaSE1.6对Synchronized进行 ...
[详细]
蜡笔小新 2023-09-25 10:24:49
-
本文目录一览:1、\mysybase.dump对数据库正常使用有影响吗 ...
[详细]
蜡笔小新 2023-09-25 08:09:01
-
8种机械键盘轴体对比本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?THML中常见的8种长度1、常见的单位px:像素 ...
[详细]
蜡笔小新 2023-09-24 09:43:18
-
xmake-ftmpxxx.luaxmake--filexxx.lua最简单:--添加名为demo的目标到工程target(demo)--设置目标程序类型为二进制,一般为 ...
[详细]
蜡笔小新 2023-09-24 08:32:23
-
蜡笔小新 2023-09-24 04:47:29
-
我有一个vim默认安装在Linux上,在一个系统上有vt52终端仿真器和unicode功能。Vim不会接受换行一切都工作正常,直到今天,当 ...
[详细]
蜡笔小新 2023-09-24 03:23:37
-
并发系列之CAS与原子操作1、CAS的概念2、Java实现CAS的原理-Unsafe类3、原子操作-AtomicInteger类源码简析4、CAS实现原子操作的三大问题4.1、AB ...
[详细]
蜡笔小新 2023-09-23 19:48:49
-
本文主要介绍关于人工智能,shell的知识点,对【winyyy.sys,hcpidesk.sys,mtlrd.sys,uldfhjfh.sys,servets.exe等1】和【】有兴趣的朋友可以看下由 ...
[详细]
蜡笔小新 2023-09-23 16:17:58
-
openpyxlxlrdxlwtxlwingsxlsxwriter了解各个库的异同,从而在不同场景下可以灵活使用首先让我们来整体把握下不同库的特点“xlrdxlwtx ...
[详细]
蜡笔小新 2023-09-23 14:59:24
-
二十三点二十三分_465
这个家伙很懒,什么也没留下!