Detailed explanation of php graphics jpgraph operation
This article mainly introduces the operation of php graphics jpgraph, and analyzes the relevant operation skills of php based on the jpgraph graphics library to implement graphics drawing based on specific examples. Friends in need can refer to it
The details are as follows:
<?php include ("src/jpgraph.php"); include("src/jpgraph_bar.php"); include ("src/jpgraph_line.php"); //设置显示的数据数组; //调用类库 //设置图像的大小 $graph = new Graph(400,200,"auto"); $graph->SetScale("textlin"); //设置图形的边距 $graph->img->SetMargin(40,180,40,40); //设置图形的背景图片,填充方式有:BGIMG_FILLPLOT, BGIMG_FILLFRAME, BGIMG_COPY $graph->SetBackgroundImage("abc.jpg",BGIMG_FILLPLOT); $graph->img->SetAngle(45); //设置图形在图像中的角度 //设置背景图片的对比度,must be between -1 <= x <= 1, (0,0)=original image $graph->AdjBackgroundImage(0,0); //设置投影; //$graph->SetShadow(); //设置标题 $graph->title->Set("test image"); //设置标题字体样式 $graph->title->SetFont(FF_FONT1,FS_BOLD); //设置标题的边距 $graph->title->SetMargin(3); //设置图列的位置 $graph->legend->Pos(0.05,0.5,"right","center"); //设置图列的投影,颜色 $graph->legend->SetShadow('darkgray@0.1'); $graph->legend->SetFillColor('lightblue@0.3'); //设置x轴的标记 $graph->xaxis->SetTickLabels($label_x); //设置X轴的显示值的角度; $graph->xaxis->SetLabelAngle(30); //设置x轴标题和字体颜色 $graph->xaxis->title->Set('Year 2006'); $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); $graph->xaxis->title->SetColor('white'); //设置x轴的字体和颜色 $graph->xaxis->SetFont(FF_FONT1,FS_BOLD); $graph->xaxis->SetColor('yellow'); //设置y轴的字体和颜色 $graph->yaxis->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->SetColor('yellow'); //设置是否显示格子。默认为显示; //$graph->ygrid->Show(false); //设置格子的颜色和粗细。值越小,格子越粗。 $graph->ygrid->SetColor('yellow@0.5'); //设置y轴更优美一些 $graph->yaxis->scale->SetGrace(20); //设置图列的数据 $bplot1 = new BarPlot($datay1); $bplot2 = new BarPlot($datay2); //设置图列的填充颜色 $bplot1->SetFillColor('orange@0.4'); $bplot2->SetFillColor('brown@0.4'); //设置值的格式 $bplot1->value->SetFormat('%d'); //设置图列标签 $bplot1->SetLegend('Label 1'); $bplot2->SetLegend('Label 2'); //设置图列在图中的阴影 $bplot1->SetShadow('black@0.4'); $bplot2->SetShadow('black@0.4'); //生成图列 $gbarplot = new GroupBarPlot(array($bplot1,$bplot2)); $gbarplot->SetWidth(0.9); $graph->Add($gbarplot); //生成图形 $graph->Stroke(); //上面所说的时在生成柱形图,当生成线性图时用下面的方法 $p1 = new LinePlot($datay); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("red"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Triumph Tiger -98"); $graph->Add($p1); $p2 = new LinePlot($data2y); $p2->mark->SetType(MARK_STAR); $p2->mark->SetFillColor("red"); $p2->mark->SetWidth(4); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend("New tiger -99"); $graph->Add($p2); // Style can also be specified as SetStyle([1|2|3|4]) or // SetStyle("solid"|"dotted"|"dashed"|"lobgdashed") $lineplot->SetStyle("dashed");//设置线的样式 $graph->yaxis->scale->SetGrace(20); //设置y轴更优美一些 ?>
2. Examples of column charts and pie charts
if($tag == 1) { $graph = new Graph(600,400,"auto"); $graph->SetScale("textlin"); $graph->setMarginColor('lightblue'); $graph->SetShadow(); $graph->setMargin(30,100,30,60); //设置标题; $graph->title->set("文章分类汇总"); $graph->title->SetMargin(3); $graph->title->setfont(FF_SIMSUN,FS_BOLD); $graph->title->setcolor('black@0.5'); $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL); $graph->xaxis->SetColor('darkblue','black'); $graph->xaxis->SetTickLabels($name); $graph->xaxis->SetLabelAngle(30); $bplot = new BarPlot($article_num); $bplot->SetFillColor("orange"); $bplot->value->SetFormat('%d'); $bplot->SetShadow('darkgray'); $bplot->value->show(); $graph->legend->SetFont(FF_SIMSUN,FS_BOLD); $bplot->SetLegend("文章数"); $graph->Add($bplot); $graph->Stroke(); } else { $graph1 = new PieGraph(600,400,"auto"); $graph1->SetScale("textlin"); $graph1->SetShadow(); $graph1->title->setFont(FF_SIMSUN,FS_BOLD); $graph1->title->set("用户文章饼形图"); $graph1->setMargin(30,100,30,60); $p1 = new pieplot3d($article_num); $p1->setAngle(80); $p1->setsize(0.5); $p1->setShadow(); $p1->ExplodeSlice(2); $p1->SetCenter(0.4); $graph1->legend->SetFont(FF_SIMSUN,FS_NORMAL); $graph1->legend->setshadow(); $p1->SetLegends($name); $graph1->Add($p1); $graph1->Stroke(); } //生成本地图片 $graph->Stroke("路径/文件名.png");
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
Advanced article on using Jpgraph to draw coordinate diagrams
## Basics of using Jpgraph to draw coordinate charts in php
The above is the detailed content of Detailed explanation of php graphics jpgraph operation. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
