php利用flashchart生成柱状图
php教程利用flashchart生成柱状图
最近项目中需要生成类似excel的柱状图、饼图、趋势图等等。。。
网上google了一番,发现了 Open Flash Chart 地址: http://teethgrinder.co.uk/open-flash-chart-2/ 。
非常好用的一款开源工具。目前最新版是2.0
——————————————————————————–
http://ofcgwt.googlecode.com/svn/demo/Demo.html 这里有很多示例可供参考。
不过不太推荐使用 googlecode上的这个示例代码,建议采用官方的示例代码和flash chart 。
flash chart的使用很简单。
如下示例:
//url形式
function embSwfWithUrl(dataurl,divcon){
var params = {
"wmode": "transparent",
"menu": "false",
"scale": "noScale",
"allowFullscreen": "false",
"allowScriptAccess": "always",
"bgcolor": "#c0c0c0" //背景
};
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');这里的http://xxx.com/xxx.html返回的是相应的json格式的数据。
swfCon是放flash的div容器。
swfobject是开源的js处理flash的类。http://code.google.com/p/swfobject/
——————————————————————————–
注意下,flash chart 获得数据的方式有两种,
一种是 data-file 一种是 get-data
data-file 正是如上示例,值必须是个 url地址,里面返回的是 json数据。
而get-data的值则是一个函数名称。 函数返回 json 数据。
如下示例:
//get-data
function embSwfWithData(divcon,getdataFn){
var params = {
"wmode": "transparent", //窗口模式
"menu": "false", //菜单显示
"scale": "noScale", //缩放
"allowFullscreen": "false", //允许全屏
"allowScriptAccess": "always", //允许脚本
"bgcolor": "#c0c0c0" //背景
};
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';
}这里 “get-data”:getdataFn

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

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

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
