Openflashchart 2.0 Simple Case PHP version _php tutorial

Source: Internet
Author: User
1.openflashchart is a more useful icon rendering plug-in, and is open-source, url http://teethgrinder.co.uk/open-flash-chart/

2.FlashChart class
Copy CodeThe code is as follows:
Flashchart Class Code

Class Flashchart
{
Private $id;
Private $height;
Private $width;
Private $path;
function __construct ($path = "", $width =300, $height =500, $id = "MyChart")
{
Global $flash _chart;
$this->id= $id;
$this->height= $height;
$this->width= $width;
$this->path= $path;
if (! $flash _chart)
{
Echo ';
Echo ';
Echo ';
$flash _chart=true;
}
}

function __destruct ()
{
Unset ($this->id, $this->height, $this->width, $this->path);
}
function SetID ($id)
{
$this->id= $id;
}
function Setchart ($file, $info)
{
$TP =new TemplateData ($file);
Echo ';
}
}

3,templatedata class

The configuration of a simple icon is removed from the already written txt text to load the class used: for example
Copy CodeThe code is as follows:
{
"title":
{
"Text": "(title)",
"Style": "{color: #FF0000; font-size:24px;}"
},
"Y_legend": {
"Text": "Iwebshop",
"Style": "{color: #736AFF; font-size:16px;}"
},

"Elements": [
{
"Type": "Line",
"Colour": "#736AFF",
"Text": "Registered user Volume (person)",
"width": 1,
"Dot-style": {
"Type": "Solid-dot", "colour": "#a44a80", "Dot-size": 3,
"Tip": "#val # People
#x_label # "},
"On-show": {"type": "Shrink-in", "cascade": 1, "delay": 0.5},
"Values": [(Numbers)]
}
],

"X_axis": {
"Labels": {
"Labels": [(dates)]
}
},

"Y_axis": {
"Steps": (Steps),
"Max": (max)
}
}

This is the content of the class:
Copy CodeThe code is as follows:


Class TemplateData
{
Public $substitution;
Private $templateFile;
function __construct ($filename)
{
$this->templatefile= @file_get_contents ($filename) or Die ("not find TemplateFile");
}
function __destruct () {
Unset ($this->templatefile, $this->substitution);
}
function Settemplatefile ($tfile)
{
$this->templatefile= $tfile;
}
function Gettemplatefile ()
{
return $this->templatefile;
}
function Replacereal ($matches)
{
Extract ($this->substitution, extr_overwrite);
Return Isset ($ $matches [1])? $ $matches [1]: $matches [1];
}
function Changeinfo ($subs)
{
$this->substitution= $subs;
Return Preg_replace_callback ("(\ (\w+) \)", Array (& $this, ' Replacereal '), $this->gettemplatefile ());
}

}

4, calling the code
Copy CodeThe code is as follows:




Include ("flashchart.php");
Include ("templatedata.php");
$FC =new flashchart (' chart/', "100%", 320);
$infos =array (
' Numbers ' = ' 30000,10000,5000,6000000,700 ',
' dates ' = ' \ ' string 1\, \ "String 2\", \ "string 3\", \ "string 4\", \ "String 5\",
' Steps ' =>600000,
' Max ' =>6000000
);
$info =array ("title" + ' User Registration statistics ', ' numbers ' = ' + ' $infos [' numbers '], ' dates ' + $infos [' dates '], ' steps ' =>$ infos[' steps ', ' max ' = $infos [' Max '];
$FC->setchart ("Chart/templatechart/user-add.txt", $info);

5, there is also a function of processing data, the query out of the data set into the OFC data

Copy CodeThe code is as follows:


/**
* @brief OFC data processing
* @params database queries data about the x, Y axis data set
* @note Backstage
*/
/*
Public Function Init_count ($RS)
{

$numbers = ";
$dates = ";
$max = 0;
foreach ($rs as $row)
{

$numbers. = $row [' num ']. ', ';//y axis data
$dates. = ' "'. $row [' Month ']. '", ';//x axis data
if ($max < $row [' num ']) $max = $row [' num '];
}
$steps =ceil ($max/10);
$result = Array (
' Steps ' = $steps,
' Numbers ' = strlen ($numbers) >1? substr ($numbers, 0,-1): null,
' Dates ' = strlen ($dates) >1? substr ($dates, 0,-1): null,
' Max ' = $max + $steps
);
return $result;
}

http://www.bkjia.com/PHPjc/325447.html www.bkjia.com true http://www.bkjia.com/PHPjc/325447.html techarticle 1.openflashchart is a more useful icon rendering plug-in, and is open source, URL Http://teethgrinder.co.uk/open-flash-chart/2.FlashChart class copy code code is as follows: FLASHC ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.