Home Backend Development PHP Tutorial php报表之jpgraph柱状图实例代码_PHP

php报表之jpgraph柱状图实例代码_PHP

Jun 01, 2016 pm 12:14 PM
jpgraph bar chart

新手初识jpgraph肯定会遇到各种各样的问题,比如乱码什么的,本案例是jpgraph3.0.7制作,也经过本人的多次实验,解决乱码问题
复制代码 代码如下:
$datay=array(); //纵坐标数据
$datax=array(); //横坐标数据
foreach ($usernums as $key => $value){
$datay[] = $value;
$datax[] = $userids[$key];
}
require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php');
require_once (‘jpgraph-3.0.7/jpgraph/jpgraph_bar.php');
// Create the graph. These two calls are always required
$graph = new Graph(800,600); //图像高宽
$graph->SetScale(“textlin”);
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->xaxis->SetLabelAngle(30);
$graph->yaxis->scale->SetGrace(20);
$graph->xaxis->scale->SetGrace(20);
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40,30,20,40);
// Create a bar pot
$bplot = new BarPlot($datay);
// Adjust fill color
$bplot->SetFillColor(‘orange');
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD,10);
$bplot->value->SetAngle(45);
$bplot->value->SetFormat(‘%d');
$graph->Add($bplot);
// Setup the titles
$graph->title->Set(iconv(“UTF-8″, “gb2312″,”用户消费报表图”));
$graph->xaxis->title->Set(iconv(“UTF-8″, “gb2312″,”用户姓名”));
$graph->yaxis->title->Set(iconv(“UTF-8″, “gb2312″,”用户订单数量”));
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->title->SetFont(FF_SIMSUN,FS_BOLD);
// Display the graph
$graph->Stroke();
?>

效果图:

官方网站 http://jpgraph.net/download/  下载地址 http://www.bitsCN.com/codes/38194.html

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)

How to make a histogram in WPS documents How to make a histogram in WPS documents Mar 20, 2024 pm 10:11 PM

WPS is a software we often use in our daily work. When doing statistics, we will use some charts for comparison and reference, such as the application of histograms. So do you know how to make a WPS histogram? The editor below will introduce how to make a WPS histogram. After we open the WPS software we are using, the interface will differ depending on the WPS version, but it will not affect the operation. Next, find the "Insert" option in the main menu bar. After opening it, you will see the chart option. After the chart is opened, the first one is the so-called column chart. In fact, there are three types of column charts, namely clustered column chart, stacked column chart and percentage stacked column chart. Which one we need can be done by ourselves. Select, let me first introduce the use of this clustered column chart. The choice is made

Implementation of column and line chart functions in Vue statistical charts Implementation of column and line chart functions in Vue statistical charts Aug 17, 2023 am 11:39 AM

Implementation of bar and line chart functions in Vue statistical charts Introduction: In data visualization applications, statistical charts are a commonly used way to display data. Vue, as a popular JavaScript framework, provides rich functions and ease of use, and is very suitable for implementing statistical charts. This article will introduce the specific steps to implement bar charts and line charts using Vue, and attach code examples. 1. Bar chart implementation A bar chart is a chart that uses the height of a rectangle to represent the size of the data. The following is using Vue and echarts library

Data visualization techniques such as bar charts and pie charts in Vue Data visualization techniques such as bar charts and pie charts in Vue Jun 25, 2023 pm 12:43 PM

In recent years, the rapid development of data visualization related technologies has made complex data easier to understand and analyze. As a popular front-end framework, Vue has good scalability and ease of use, and is widely used in the field of data visualization. This article will introduce the techniques for realizing data visualization such as bar charts and pie charts in Vue. 1. Use ECharts to implement histograms ECharts is an open source visualization library based on JavaScript that provides a variety of chart types, including histograms. The following is

Use PHP and JpGraph to generate and draw charts Use PHP and JpGraph to generate and draw charts Jun 25, 2023 pm 06:16 PM

The use of charts is very common in developing web applications. Charts can clearly display data, making it easier for users to understand and analyze the information. In PHP, you can use the JpGraph library to generate and draw charts. This is a powerful chart generation tool that supports multiple types of charts, such as bar charts, pie charts, line charts, etc. In this article, we will introduce how to use PHP and JpGraph to generate and draw charts. To install JpGraph first, you need to download the JpGraph library and extract it locally

How to use histogram to display data in ECharts How to use histogram to display data in ECharts Dec 18, 2023 pm 02:21 PM

How to use histograms to display data in ECharts ECharts is a JavaScript-based data visualization library that is very popular and widely used in the field of data visualization. Among them, the histogram is the most common and commonly used chart type, which can be used to display the size, comparison and trend analysis of various numerical data. This article will introduce how to use ECharts to draw histograms and provide code examples. First, we need to introduce the ECharts library into the HTML file, which can be introduced in the following way

Python program to draw histogram using turtle Python program to draw histogram using turtle Aug 20, 2023 pm 04:57 PM

Graphical representations of data provide an enhanced understanding of the complex substructure of the data, helping us to easily interpret hidden patterns and trends. Imagine how convenient it would be if we could draw similar relationships programmatically? Python provides a rich module specifically designed to perform such operations, it is called "turtle". The "turtle" module is a built-in library in Python that allows us to draw graphics on the "turtle graphics screen". In this article, we will create a bar chart using the turtle module. Understanding the Turtle ModuleTheturtlemoduleusesavirtualturtleobjecttocreategraphic

Learn to draw line charts, bar charts and pie charts with Python in three minutes Learn to draw line charts, bar charts and pie charts with Python in three minutes Sep 27, 2023 am 09:29 AM

Learn to draw line charts, bar charts, and pie charts with Python in three minutes. Python is a very popular programming language that is widely used in data analysis and visualization. In this article, we will learn how to draw three common types of charts using Python: line charts, bar charts, and pie charts. I'll provide you with specific code examples to help you get started quickly. Line Chart A line chart is a type of chart that shows trend changes by connecting data points. In Python, we can use the matplotlib library to plot

How to generate histogram using ECharts and Python interface How to generate histogram using ECharts and Python interface Dec 17, 2023 pm 01:54 PM

Overview of how to use ECharts and Python interfaces to generate histograms: With the development of data visualization technology, histograms have become one of the common ways of displaying data. This article will introduce how to use ECharts and Python interfaces to generate histograms. ECharts is an open source visualization library based on JavaScript, which provides rich chart types and interactive functions. Python is a popular programming language that makes it easy to manipulate data and call external libraries. Step 1: Preparation

See all articles