So erstellen Sie mit PHP eine Liniendiagrammfunktion

高洛峰
Freigeben: 2023-03-02 21:12:01
Original
1033 Leute haben es durchsucht

Ich bin froh, dass jeder so ein Faible für PHP (als aktuelle Mainstream-Entwicklungssprache) hat!
Im Folgenden wird Ihnen die Funktion von PHP (als aktuelle Mainstream-Entwicklungssprache) zum Erstellen von Liniendiagrammen vorgestellt:

/*
Funktionsbeschreibung
$data: y-Achsendaten ( Array)
$graphdata: Y-Achsen-Daten – Prozentsatz (Array)
$label: X-Achsen-Daten (Array)
$height: Bildhöhe
$width: Bildbreite
$ Schriftart: Schriftgröße
$dot: Bestimmen Sie die Größe der Punkte
$bg: Hintergrundfarbe
$line: Linienfarbe
$text: Textfarbe
$dotcolor: Punktfarbe
$file: Name der Ausgabebilddatei
*/

function qximage($data,
$graphdata,
$label,
$height,
$width,
$font,
$dot,
$bg,
$line,
$text,
$dotcolor,
$file)
{
$jc =$height/100;
$fontwidth= imagefontwidth ($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); 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;
imagestring($image, $font,$x1,$ y1-2*$fontheight,$graphdata[$i]."%(".$data[$i].")",$text); 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); 🎜>

Verwandte Etiketten:
php
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!