- 浏览: 13733250 次
- 性别:
- 来自: 洛杉矶
文章分类
- 全部博客 (1994)
- Php / Pear / Mysql / Node.js (378)
- Javascript /Jquery / Bootstrap / Web (435)
- Phone / IOS / Objective-C / Swift (137)
- Ubuntu / Mac / Github / Aptana / Nginx / Shell / Linux (335)
- Perl / Koha / Ruby / Markdown (8)
- Java / Jsp (12)
- Python 2 / Wxpython (25)
- Codeigniter / CakePHP (32)
- Div / Css / XML / HTML5 (179)
- WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra (275)
- Apache / VPN / Software (31)
- AS3.0/2.0 / Flex / Flash (45)
- Smarty (6)
- SEO (24)
- Google / Facebook / Pinterest / SNS (80)
- Tools (22)
最新评论
-
1455975567:
xuezhongyu01 写道wocan23 写道我想问下那个 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
xuezhongyu01:
wocan23 写道我想问下那个111.1是怎么得来的我也看不 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
18335864773:
试试 pageoffice 在线打开 PDF 文件吧. pag ...
jquery在线预览PDF文件,打开PDF文件 -
青春依旧:
opacity: 0.5; 个人喜欢这种方式!关于其他css特 ...
css透明度的设置 (兼容所有浏览器) -
July01:
推荐用StratoIO打印控件,浏览器和系统的兼容性都很好,而 ...
搞定网页打印自动分页问题
简单型
Charting
Panaci: A Charting Library
Panaci is an application library for CodeIgniter.
If your application needs to output graphic charts at run-time, such as
bar, line
area, step or impulse charts, then Panaci makes this rather easy.It
utilises the Panachart
charting class released under the GPL by Eugen Fernea.
Features
Compact (23k) and efficient code.
Bandwidth friendly, the average image size for a 450*250 image is around
2K
Can output to a file or directly to an HTTP stream
Supports several plot types eg. bars, lines, dots, areas, step, impulse
Supports multiple series plots on the same image
Supports automatic scaling of plot area by axis labels size
An example plot
Basic usage
From your controller
$params = array('width' => 450, 'height' => 250, 'margin' => 15, 'backgroundColor' => '#eeeeee'); $this->load->library('chart', $params);
From your Controller function
function graph() { $data_2001 = array(43,163,56,21,0,22,0,5,73,152,123,294); $data_2002 = array(134,101,26,46,22,64,0,28,8,0,50,50); $Labels = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); $this->chart->setTitle("Annual Rainfall","#000000",2); $this->chart->setLegend(SOLID, "#444444", "#ffffff", 2); $this->chart->setPlotArea(SOLID,"#444444", '#dddddd'); $this->chart->setFormat(0,',','.'); $this->chart->addSeries($data_2001,'dot','2001 ', SOLID,'#00ff00', '#00ff00'); $this->chart->addSeries($data_2002,'area','2002 ', SOLID,'#ff0000', '#00ffff'); $this->chart->setXAxis('#000000', SOLID, 1, "2001"); $this->chart->setYAxis('#000000', SOLID, 2, "Rainfall in MM"); $this->chart->setLabels($Labels, '#000000', 1, HORIZONTAL); $this->chart->setGrid("#bbbbbb", DASHED, "#bbbbbb", DOTTED); $this->chart->plot('./images/file.png'); $this->load->view('graph'); }
Demo and Documentation
There is an online demo available at Panaci
Download
A download is available from here Panaci
========================================
pChart是一个免费的PHP图表生成库,可以生成多种图表如饼图或者柱状图等等,
需要GD库的支持
。下面我来简单讲讲如何在CI中方便地使用它。
首先我们要下载
pChart。访问http://pchart.sourceforge.net/download.php
就可以下载到最新版的pChart,目前最新的版本是1.27。解压下载到的文件
,我们要用到的只是其中的pChart文件夹,里面有pChart.class、pCache.class和pData.class这三个文件。我们把pChart文件夹复制到
application/libraries
/
下面。
然后要准备字体,因为我们做报表很可能要输出中文
,所以必须使用一种中文字体,至于选什么字体就看你的喜好了(如果是商业用途的话请注意字体的版权以免引起版权纠纷),把中文字体的ttf文件复制到
application/libraries/pChart
下面即可。
通过库的形式
来使用pChart,因此在
application/libraries/
下面创建一个文件,命名为 Chart.php,代码如下:
<?php class Chart { function Chart() { include(APPPATH."libraries/pChart/pData.class"); include(APPPATH."libraries/pChart/pChart.class"); } function draw_line_graph($params) { $DataSet = new pData; $DataSet->AddPoint($params['data'],"Serie1"); //需要显示的数据 $DataSet->AddPoint($params['date'],"Serie2"); //横坐标的数据 $DataSet->AddSerie("Serie1"); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName("订单总金额","Serie1"); $DataSet->SetYAxisName("RMB"); //纵坐标上显示的文字 $DataSet->SetXAxisName('横坐标:日期'); //横坐标上显示的文字 $DataSet->SetXAxisFormat("date"); //横坐标的数据类型 $Test = new pChart($params['height'],$params['width']); //图表文件的高度和宽度 $Test->setDateFormat($params['date_format']); //横坐标显示的日期格式 $Test->setColorPalette(0,255,0,0); $Test->setFontProperties(APPPATH."libraries/pChart/FZLTXIHK.ttf",12); //设置使用的字体及字号 $Test->setGraphArea(60,60,$params['x_area'],$params['y_area']); //图形区域的高度和宽度 $Test->drawGraphArea(252,252,252); //线的颜色 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2); $Test->drawGrid(4,TRUE,230,230,230,255); $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); $Test->setFontProperties(APPPATH."libraries/pChart/FZLTXIHK.ttf",8); //设置数据值所用字体及字号 $Test->writeValues($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1"); //输出每个点的数据值 $Test->setFontProperties(APPPATH."libraries/pChart/FZLTXIHK.ttf",11); //设置使用的字体及字号 $Test->drawLegend(75,65,$DataSet->GetDataDescription(),255,255,255); $Test->setFontProperties(APPPATH."libraries/pChart/FZLTXIHK.ttf",12); //设置使用的字体及字号 $Test->drawTitle(60,22,$params['title'],50,50,50,585); $imagefile='public/temp/'.$params['filename'].'.png'; //设置生成文件的保存路径 $Test->Render($imagefile); //生成文件 return $imagefile; //返回文件名 } }
控制器 :
function test(){ $this->load->library('chart'); //载入pChart库 $params['data']=array(100,200,150,600,230,150,510); //要显示的数据 for($i=0;$i<7;$i++){ $params['date'][$i]=1250217066+$i*86400; //要显示的日期,注意这里是Unix时间戳,pChart会自动传换成你要的格式 } $params['title']='销售报表'; //图片标题 $params['date_format']='m月j日';//设置日期格式 $params['filename']='test_image'; //文件名 $params['height']=600; //高度 $params['width']=300; //宽度 $params['x_area']=560; //图形区域高度 $params['y_area']=280; //图形区域宽度 $data['chart_image']=$this->chart->draw_line_graph($params);//生成图片 $data['baseurl']=site_url(); $this->load->view('test_view.html',$data); }
视图:test_view.html
<html> <head><title></title></head> <body> <img src="<?php echo $baseurl.$chart_image;?>" /> </body> </html>
最终生成的图表是这样的:
关于pChart的更多用法,请参考它的在线文档:
http://pchart.sourceforge.net/documentation.php
=======================================================
<!-- // end:header.php //--> <!-- CONTENT -->
Codeigniter: Intergrating OpenFlashCharts
Yes I know, it has been some time since I last posted anything on the site. Things have just been crazy at work, trying to get up to speed on using Pentaho for a major project. In fact, I might start posting some Pentaho related topics in the future. There’s definitely a need for more help and guides on using Pentaho for beginners.
Anyway, one of the things on the project was to pull data from Pentaho and display it inside OpenFlashCharts on a CI platform. If you don’t know what OpenFlashCharts is, go visit the website. It’s a pretty awesome kit.
There’s been quite a bit of chatter on the net about integrating CI
with OpenFlashCharts, but ever since version 2 came out there have been
more questions about how to do it.
In the new version of OpenFlashCharts, it uses the JSON format to
describe what type of chart to render in the flash object. OFC comes
with a bunch of libraries (in various programming languages) which will
generate the JSON format for the flash object. For PHP, the kit comes
with the generic PHP version and a PHP5 version.
Somebody by the name of Thomas did managed to stitch OpenFlashCharts 2 with CI and he posted it up on the CI wiki. So kudos to Thomas (whoever you are) for making my life easier. If you like you can download his library and give it a spin.
For Thomas, he used the PHP5 libraries of OpenFlashCharts, which unfortunately is a bit incomplete. I wasn’t able to generate more advance graphs such as Hollow Areas, Dotted lines etc. The flash object gave me an ‘infinity’ error. After some investigation, I found that the OFC PHP5 libraries are not generating the same JSON as the generic PHP version. Taking a page out of his book, I modified his library to work with the generic PHP version instead.
One advantage of doing this is that suddenly, you can apply all the tutorial codes on the OFC website because they were written for the generic PHP library and not the PHP5 version.
So, download the zip file and extract the files to the relevant
folders of your CI install. The assets folder should go to wherever you
put your stuff like images and javascript files. Just make sure you
change the view to reflect the correct path. I put my assets in the root
of my webserver folder, and I access my CI through http://dev.ci/
.
When I run the http://dev.ci/charts
, I would get this
graph with 3 data lines.
So how does it all work?
The OFC library, php-ofc-library
and the OpenFlashChartLib.php
can now be accessed by calling the load library call.
$this->load->library('OpenFlashChartLib', NULL, 'OFCL');
If you look inside the view folder for chart_view.php
,
you can see where the OFC flash object is getting its JSON feed from, http://dev.ci/charts/get_data
.
Inside get_data()
function of the charts controller,
it’s basically the same code as the tutorial at http://teethgrinder.co.uk/open-flash-chart-2/data-lines-2.php
The difference here is that instead of calling the
$chart = new open_flash_chart();
I’m now doing
$chart = $this->OFCL->create('open_flash_chart');
to perform the same instantiation but through the OpenFlashChartLib (OFCL) library.
So, just change all the object instantiation call accordingly, and the graph should show up nice and neat.
Here’s Dilbert to close out…
- Panaci.zip (35.5 KB)
- 下载次数: 2
- ci-ofc2.zip (314.3 KB)
- 下载次数: 2
发表评论
-
CakePHP你必须知道的21条技巧
2012-10-19 06:25 1883原文链接:http://www.avatarfinancial ... -
cakephp 1.3 Views
2012-10-09 06:12 1442Section 1 Views 视图 一个vie ... -
cakephp 1.3 Models
2012-10-09 06:07 2501Section 1 What is a model? ... -
cakephp 1.3 Controller
2012-10-09 05:49 3333Controller 一个controller用于管理 ... -
cakephp 1.3 配置CakePHP
2012-10-09 05:31 4645Section 1 数据库配置 app/config/ ... -
CakePHP 2.x十分钟博客教程
2012-10-07 01:27 244151. CakePHP2十分钟博客教 ... -
Create an Admin panel with CodeIgniter
2010-05-23 02:15 4175Create an Admin panel with Code ... -
Codeigniter Grid 使用方法 (flexigrid)
2010-05-23 02:05 2803来源:http://codeigniter.com/forum ... -
CI集成 ckeditor 配置
2010-05-23 01:34 3752配置 ckeditor 1.上传 下载 ckedito ... -
codeigniter 辅助函数 - 敏感词过滤
2010-05-05 06:18 4575我们都知道有些敏感的词汇是不适合出现在互联网上的,特别是在有用 ... -
实现简单 codeigniter 缓存 (cache)
2010-04-30 23:47 5278代码 class Test extends Contr ... -
CKEditor Helper for CodeIgniter
2010-04-19 00:37 3977Using CKEditor as a plugin in y ... -
codeigniter 生成 excel
2010-04-19 00:33 3323Excel Plugin Th ... -
CakePHP 中文手册
2010-04-14 21:04 2337基本概念 Section1 简介 ... -
利用 Cache_Lite代替codeigniter中的cache功能
2010-01-29 06:15 5512codeigniter的功能纵然强大,也有不足之处。其cach ... -
CodeIgniter 操作PDF ( Generating PDF files using CodeIgniter )
2010-01-03 04:03 3608PDF files rock! Some of the p ... -
CodeIgniter 合作 Authorize.net
2009-12-30 00:25 1612function payment(){ // 略... ... -
CodeIgniter 合作paypal
2009-12-30 00:15 2352<?php class Paypal extend ... -
CodeIgniter 操作 CSV
2009-12-29 07:17 4633A Comma separated values (CSV) ... -
codeigniter 操作 Rss
2009-12-29 07:12 1971I wrote a codeigniter library t ...
相关推荐
CodeIgniter提供了强大的数据库抽象层,支持多种数据库系统,简化了数据库操作。 6. 系统文件:`system`目录包含了CodeIgniter的核心框架文件,包括核心类、助手函数、库、驱动程序等。这些文件提供了框架的基础...
根据需求,你可以创建自定义组件,比如模拟桌面的面板,以及各种小部件,如图标、文件夹等。 4. **数据交互**:使用ExtJS的数据包(Store)和代理(Proxy)来与CodeIgniter API进行通信。配置Store的proxy属性,...
基于vue-element-admin的RBAC通用角色权限管理系统.zip ... 完全弃用 CI 自带数据库操作,使用 catfan/medoo 进行数据库操作 [X] 12. 系统日志: PHP CodeIgniter 3.1.10 RESTful 后端生成 logs 表
"ace后台管理系统"注重用户体验,界面设计既简洁又直观,采用了一流的图形用户界面(GUI),确保操作流程顺畅。丰富的颜色搭配和图标设计,使得整个系统看起来专业且吸引人,这在提高工作效率的同时,也提升了用户的...
- **Web框架**:可能会使用像Laravel、CodeIgniter这样的PHP框架来加速开发和提高代码质量。 4. **注意事项**: - 系统的安全性:防止SQL注入、XSS攻击等,确保用户数据安全。 - 性能优化:处理大量并发选课请求...
PHP的优势在于其语法简洁,学习曲线平缓,且有大量的开源库和框架可供使用,如PDO用于数据库操作,Laravel或CodeIgniter等框架可以提高开发效率。 **AJAX** 技术允许网页在不重新加载整个页面的情况下,与服务器...
3. **图片和其他资源文件**:如logo、背景图、图标等,它们是网站视觉元素的一部分。 4. **配置文件**:如`.ini`或`.config`文件,用于设置应用的参数和环境变量。 5. **数据库相关文件**:如`.sql`文件,用于导入...
9. 后端架构:后端可能使用了PHP框架(如Laravel、Symfony或CodeIgniter)来提高开发效率和代码质量。 10. 数据存储:如果应用有用户账户系统,可能涉及到数据库操作,如存储用户设置、历史记录等。 通过分析这个...
此外,可能会采用一些框架(如Laravel、Symfony或CodeIgniter)或内容管理系统(CMS)如WordPress,以提高开发效率和代码质量。 总而言之,教育品牌网的源代码展示了如何利用Apache服务器、MySQL数据库和PHP技术...
- img/:图片资源,用于图标、背景等。 - php/:PHP源代码文件,实现各种功能模块。 - database/:数据库相关文件,如SQL脚本用于初始化数据。 - config/:配置文件,存放系统配置信息。 - includes/:包含文件,...
- 图片和其他静态资源:如logo、图标等,用于美化网站。 - 配置文件:可能包含数据库连接信息,网站设置等。 - 文档:如安装指南、使用说明等。 综上所述,深度学习PHP爱墙程序是一个完整的Web应用实例,涵盖了PHP...
同时,良好的交互设计,如清晰的操作流程、直观的图标和色彩搭配,可以提高用户的工作效率。 5. **CI框架**:根据提供的文件名"ci_jxc80",推测此系统可能使用了CodeIgniter(CI)框架。CodeIgniter是PHP的一个轻量...
6. **图片和媒体文件**:图标、logo和其他图形资源。 7. **文档**:安装指南、API参考、用户手册等。 8. **库和框架**:lemocms可能依赖的一些第三方PHP库或框架,如`Laravel`、`Symfony`或`CodeIgniter`。 9. **...
6. **图片和其他媒体**:产品图片、图标等静态资源。 7. **文档**:项目说明、API文档、安装指南等。 8. **测试文件**:PHPUnit或其他单元测试或集成测试的代码。 为了全面理解并利用这个家装平台,你需要解压文件...
10. **图片和其他资源文件**:如图标、logo等,用于美化和增强用户体验。 使用这个PHP后台管理系统模板,开发者可以遵循MVC(Model-View-Controller)设计模式,将业务逻辑、数据处理和用户界面分离,使代码更易于...
4. 图片资源:包括图标、背景图等,提升视觉效果。 5. PHP文件:实现服务器端逻辑,如登录验证、数据处理等。 6. 脚本库和框架:可能包括jQuery、Bootstrap等,提供便利的开发工具和预设样式。 7. 数据库配置文件:...
7. **图片和其他资源**:如logo、图标等静态资源,用于美化和标识系统。 8. **许可证文件**:说明软件的使用许可条款,确保用户合法使用。 要运行此系统,首先需要一个支持PHP的服务器环境(如Apache或Nginx)和一...
10. images/ - 图片资源目录,存放图标或其他视觉元素。 这个基于PHP的网站目录系统可能使用了MVC(Model-View-Controller)设计模式,将业务逻辑、数据模型和用户界面分离,提高代码的可维护性和可扩展性。同时,...