Php uses flashchart to generate a bar chart

Source: Internet
Author: User
Tags php tutorial

Use flashchart to generate a bar chart in the php Tutorial

Recently, a bar chart, pie chart, and trend chart similar to excel needs to be generated...

Google some online, found the Open Flash Chart address: http://teethgrinder.co.uk/open-flash-chart-2.

A very useful open-source tool. The latest version is 2.0.

---------------------------

Http://ofcgwt.googlecode.com/svn/demo/Demo.html there are many examples for reference here.

However, we do not recommend using the sample code on googlecode. We recommend using the official sample code and flash chart.

Flash chart is easy to use.

Example:

// Url format
Function embSwfWithUrl (dataurl, divcon ){
Var params = {
"Wmode": "transparent ",
"Menu": "false ",
"Scale": "noScale ",
"AllowFullscreen": "false ",
"AllowScriptAccess": "always ",
"Bgcolor": "# c0c0c0" // background
};
Var flashvars = {
'Data-file': dataurl
};
Swfobject. embedSWF ("/swf/open-flash-chart.swf? Timestamp = "+ Math. random (), divcon," 450 "," 300 "," 10.0.0 ","./swf/expressInstall.swf ", flashvars, params );
}

EmbSwfWithUrl ('http: // xxx.com/xxx.html', 'swfcon'); here, http://xxx.com/xxx.htmlreturns the corresponding JSON data.

SwfCon is a div container for flash.

Swfobject is an open source js class for processing flash. Http://code.google.com/p/swfobject/

---------------------------

Note that there are two ways to obtain data from flash charts,

One is data-file and the other is get-data.

Data-file is exactly the same as in the preceding example. The value must be a url address and json data is returned.

The get-data value is a function name. The function returns json data.

Example:

// Get-data
Function embSwfWithData (divcon, getdataFn ){
Var params = {
"Wmode": "transparent", // window mode
"Menu": "false", // menu display
"Scale": "noScale", // scale
"AllowFullscreen": "false", // allow full screen
"AllowScriptAccess": "always", // allow scripts
"Bgcolor": "# c0c0c0" // background
};
Var flashVar = {
"Get-data": getdataFn
};
Swfobject. embedSWF ("/swf/open-flash-chart.swf? Timestamp = "+ Math. random (), divcon," 450 "," 300 "," 10 ","/swf/expressInstall.swf ", flashVar, params );
}

Function getJsonData (){
Return 'json data ';
} Here "get-data": getdataFn

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.