Home Backend Development PHP Tutorial PHP graphics operation Jpgraph study notes

PHP graphics operation Jpgraph study notes

Jul 29, 2016 am 09:09 AM
graph gt title

The example in this article describes the Jpgraph study notes of PHP graphics operations. Share it with everyone for your reference, the details are as follows:

1. Jpgraph installation configuration

Download the Jpgraph installation package

Unzip it and place it on the disk (preferably put it together with the web page)

Modify the php.ini file:

1. Memory memory_limit = , Contains the required class library files

Copy the code

The code is as follows:

require_once();

2. Initialization data

Copy the code

The code is as follows:

$data=array();

can be fixed data in the php program, that is, static data, obtained directly can be data stored in text files can be data stored in the database

can be data passed through URL parameters (GET or POST Method)

3. Create a Graph class instance


Copy the code

The code is as follows:

$graph=new Graph();

You can set the size of the graph here4. Set the title and x-axis title , the content of the y-axis title, its font, color, position, etc.

5. Create the corresponding graph instance

It can be a line chart, column chart, pie chart, 3D, etc.

6. Add data to the graph Copy the code on

The code is as follows:

$graph->Add();

Now a simple graphic is completedNote:

Chinese fonts are garbled

When Gpgraph displays Chinese characters by default, it regards the Chinese character encoding as gb2312, and converts it to utf-8 before displaying it. If the file encoding method It is gb2312, just set the first parameter of the SetFont() method to FF_SIMSUNIf it is utf-8 encoded, you need to convert the Chinese character encoding to gb2312 first, so that the Chinese characters can be displayed normallyThe conversion encoding method can be used iconv ("UTF-8","gb2312",$x);Some commonly used methods:

$graph->title->Set('设置图表的标题');
$graph->tabtitle->Set('设置图片头部文字');
$graph->xaxis->title->Set("设置X轴的标题");
$graph->yaxis->title->Set("设置Y轴的标题");
$graph->SetScale('textlin');//设置刻度值类型
$graph->img->SetMargin(50,40,40,55);//边框间距(左右上下)
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,12);//标题字体
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD,10);
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD,10);
$graph->xaxis->SetFont(FF_SIMSUN,FS_BOLD,12);//坐标柱上的字体
$graph->yaxis->SetFont(FF_SIMSUN,FS_BOLD,12);
$graph->title->SetColor('red'); ///标题颜色
$graph->xaxis->title->SetColor('red');
$graph->yaxis->title->SetColor('red');
$graph->xaxis->title->SetMargin(20);//距离坐标轴的距离
$graph->yaxis->title->SetMargin(20);//距离Y轴的距离
$linepot->SetColor('red');//折线的颜色(折线图)
$linepot->SetWeight(2);//折线的宽度
$linepot->value->SetFormat('%0.1f'); //值的格式化
$linepot->value->show(true);//显示值
$graph->SetBackGroundImage ( );设置背景
$graph->SetMarginColor('lightblue');//设置图形颜色
$graph->SetShadow();//
$graph->Set3DPerspecttive(); //设置3d效果图
/*倾斜3D效果 
 1、' SKEW3D_UP '
 2、' SKEW3D_DOWN'
 3、' SKEW3D_LEFT'
 4、' SKEW3D_RIGHT'*/
$p1->SetTheme('water');//设置样式
$p1->SetCenter(0.5,0.55);//设置图形位置
$graph->legend->Pos(0.1,0.9);//设置注释文字的位置
$graph->legend->SetFont(FF_SIMSUN,FS_BOLD,12);//设置注释文字的字体

Copy after login
I hope this article will be helpful to everyone in PHP programming.

The above introduces the Jpgraph study notes for PHP graphics operations, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

what does title mean what does title mean Aug 04, 2023 am 11:18 AM

Title is the meaning that defines the title of the web page. It is located within the tag and is the text displayed in the title bar of the browser. Title is very important for the search engine optimization and user experience of the web page. When writing HTML web pages, you should pay attention to using relevant keywords and attractive descriptions to define the title element to attract more users to click and browse.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

What is the meaning of title in HTML What is the meaning of title in HTML Mar 06, 2024 am 09:53 AM

The title in HTML displays the title tag of the web page, which allows the viewer to know what the current page is about, so each web page should have a separate title.

Is watch4pro better or gt? Is watch4pro better or gt? Sep 26, 2023 pm 02:45 PM

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

Steps to use Python to manipulate Ethereum Graph data Steps to use Python to manipulate Ethereum Graph data May 08, 2023 am 10:01 AM

Before we get started, let's look at some definitions. GraphQL is a query language TheGraph is a blockchain project using the GraphQL query language. The project allows anyone to build and publish an open API called subgraph. The Graph project uses GraphQL, a syntax that describes how to interrogate data. This syntax is not tied to a specific type of database or storage engine, but is supported by your existing code and data. GraphQL Let's start by looking at a very simple GraphQL query structure and the results we get when we run it. Once the GraphQL service is running, it can receive GraphQL queries

See all articles