jpgraph 生成类型数据以图表,走势图的形式表现出来
/**
* ecshop jpgraph图表类库
* ==============================================================
* 利用开源的jpgraph库实现对各类型数据以图表,走势图的形式表现出来。
* ==============================================================
**/class cls_jpgraph
{
var $db = null;
var $ydata = array();
var $width = 350;
var $height = 250;var $graph = ''; //图形对象
var $piegraph = ''; //丙状图形var $lineplot = ''; //线性对象
var $barpot = ''; //柱状对象
var $gbplat = ''; //柱状组对象
var $txt = ''; //文本对象
var $p1 = ''; //丙状图对象var $scale = ''; //图表类型? (textlin,textlog,intlin)
var $yscale = ''; // (log,)
var $xgrid = false; //x轴网格显示
var $ygrid = false; //y轴网格显示
var $title = ''; //标题
var $subtitle = ''; //子标题(一般为日期)
var $xaxis = ''; //x轴名称
var $yaxis = ''; //y轴名称/*margin position*/
var $left = 0;
var $right = 0;
var $top = 0;
var $bottom = 0;/**
*构造函数
*/
function cls_jpgraph($width=350,$height=250)
{
$this->width = $width;
$this->height = $height;$this->graph = new graph($this->width,$this->height);
}
/**
* 图表类库的构造函数
*
*/
/*
function __construct($parms,$width,$height)
{
cls_jpgraph($parms,$width,$height);
}
*//*图片基本信息设置*/
function set_jpgraph($scale='intlin',$title='',$subtitle='',$bgcolor='',$xaxis='',
$yaxis='',$xgrid=false,$ygrid=false,$margin='') {$this->scale = $scale;
$this->title = $title;
$this->subtitle = $subtitle;
$this->xaxis = $xaxis;
$this->yaxis = $yaxis;
$this->xgrid = $xgrid;
$this->ygrid = $ygrid;if(!empty($scale)) {
$this->graph->setscale($this->scale);
}
else {
$this->graph->setscale('intlin');
}
$this->graph->xgrid->show($this->xgrid,$this->xgrid);
$this->graph->ygrid->show($this->ygrid,$this->ygrid);if(!empty($bgcolor)) {
$this->graph->setmargincolor($bgcolor);
}/*如果手工设置了图片位置*/
if(is_array($margin)) {
while(list($key,$val) = each($margin)) {
$this->$key = $val;
}
$this->graph->setmargin($this->left,$this->right,$this->top,$this->bottom);
}if(!empty($this->title)) {
$this->graph->title->set($this->title);
}
if(!empty($this->subtitle)) {
$this->graph->subtitle->set($this->subtitle);
}
else {
$this->graph->subtitle->set('('.date('y-m-d').')'); //默认子标题设置为当前日期
}
if(!empty($this->xaxis)) {
$this->graph->xaxis->title->set($this->xaxis);
}
if(!empty($this->yaxis)) {
$this->graph->yaxis->title->set($this->yaxis);
}}
/*创建线性关系图表(linear plot)*/
function create_lineplot($parms,$color='black',$weight=1)
{
$this->ydata = $parms;
$this->lineplot = new lineplot($this->ydata);
$this->lineplot->setcolor($color);
$this->lineplot->setweight($weight);return $this->lineplot;
}/*创建柱状图表(bar pot)*/
function create_barpot($parms,$color='black',$width='0')
{
$this->ydata = $parms;
$this->barpot = new barplot($this->ydata);
$this->barpot->setfillcolor($color);
if(!empty($width)) {
$this->barpot->setwidth($width);
}return $this->barpot;
}/*创建数据柱状图表组*/
function create_bargroup($plotarr,$width='0.8')
{
$this->gbplot = new groupbarplot($plotarr);
$this->gbplot->setwidth($width);return $this->gbplot;
}/*创建文本内容*/
function create_text($str,$postion='',$color='black')
{
$this->txt = new text($str);if(is_array($postion)) {
while(list($key,$val) = each($postion)) {
$this->$key = $val;
}
$this->txt->setpos($this->left,$this->top);
}
else {
$this->txt->setpos(10,20);
}
$this->txt->setcolor($color);$this->graph->add($this->txt);
}/*创建丙状图表*/
function create_pie($parms,$title,$type='3d',$size='0.5',$center='0.5',$width='350',$height='250')
{
$this->width = $width;
$this->height = $height;$this->piegraph = new piegraph(300,200);
$this->piegraph->setshadow();$this->piegraph->title->set($title);
if('3d' != $type) {
$this->p1 = new pieplot($parms);
$this->piegraph->add($this->p1);
}
else {
$this->p1 = new pieplot3d($parms);
$this->p1->setsize($size);
$this->p1->setcenter($center);
// $this->p1->setlegends($gdatelocale->getshortmonth());
$this->piegraph->add($this->p1);
}
$this->piegraph->stroke();
}function get_auth_code($length=4)
{
$spam = new antispam();
$chars = $spam->rand($length);if( $spam->stroke() === false ) {
return false;
}return $chars;
}/*完成图形创建并显示*/
function display($obj)
{
$this->graph->add($obj);
$this->graph->stroke();
}
}?>

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

AI Hentai Generator
Generate AI Hentai for free.

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

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

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

In 2025, global digital virtual currency trading platforms are fiercely competitive. This article authoritatively releases the top ten digital virtual currency trading platforms in the world in 2025 based on indicators such as transaction volume, security, and user experience. OKX ranks first with its strong technical strength and global operation strategy, and Binance follows closely with high liquidity and low fees. Platforms such as Gate.io, Coinbase, and Kraken are at the forefront with their respective advantages. The list covers trading platforms such as Huobi, KuCoin, Bitfinex, Crypto.com and Gemini, each with its own characteristics, but investment should be cautious. To choose a platform, you need to consider factors such as security, liquidity, fees, user experience, currency selection and regulatory compliance, and invest rationally

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

Ranking of the top ten virtual currency trading platforms (latest in 2025): Binance: Global leader, high liquidity, and regulation has attracted attention. OKX: Large user base, supports multiple currencies, and provides leveraged trading. Gate.io: A senior exchange, with a variety of fiat currency payment methods, providing a variety of trading pairs and investment products. Bitget: Derivatives Exchange, high liquidity, low fees. Huobi: An old exchange that supports a variety of currencies and trading pairs. Coinbase: A well-known American exchange, strictly regulated. Phemex and so on.

Top 10 digital currency trading platforms: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi Global, 5. Kraken, 6. Coinbase, 7. KuCoin, 8. Bitfinex, 9. Crypto.com, 10. Gemini, these exchanges have their own characteristics, and users can choose the platform that suits them based on factors such as security, fees, currency selection, user interface and customer support.
