php与Open Flash Chart多报表切换例子
发布:smiling 来源: PHP粉丝网 添加日期:2015-04-15 10:24:14 浏览: 评论:0
Open Flash Chart多报表我们在许多的网站都会看到这个功能了,今天小编就来为各位介绍Open Flash Chart多报表使用方法吧,将生成好的JSON数据传递给前端,前端通过JS来实现切换效果,例子.
- <?php
- //
- // This is the MODEL section:
- //
- <a href="/tags.php/include/" target="_blank">include</a> '../php-ofc-library/open-flash-chart.php';
- $title = new title( date("D M d Y") );
- $bar = new bar();
- $bar->set_values( array(9,8,7,6,5,4,3,2,1) );
- $chart_1 = new open_flash_chart();
- $chart_1->set_title( $title );
- $chart_1->add_element( $bar );
- // generate some random data
- srand((double)microtime()*1000000);
- $tmp = array();
- for( $i=0; $i<9; $i++ )
- $tmp[] = rand(1,10);
- $bar_2 = new bar();
- $bar_2->set_values( $tmp );
- $chart_2 = new open_flash_chart();
- $chart_2->set_title( new title( "Chart 2 :-)" ) );
- $chart_2->add_element( $bar_2 );
- //
- // This is the VIEW section:
- //
- ?>
- <html>
- <head>
- <script type="text/<a href="/js_a/js.html" target="_blank">javascript</a>" src="js/json/json2.js"></script>
- <script type="text/javascript" src="js/swfobject.js"></script>
- <script type="text/javascript">
- swfobject.embedSWF("open-flash-chart.swf", "my_chart", "350", "200", "9.0.0");
- </script>
- <script type="text/javascript">
- function ofc_ready()
- {
- alert('ofc_ready');
- }
- function open_flash_chart_data()
- {
- alert( 'reading data' );
- return JSON.stringify(data_1);
- }
- function load_1()
- {
- tmp = findSWF("my_chart");
- x = tmp.load( JSON.stringify(data_1) );
- }
- function load_2()
- {
- alert("loading data_2");
- tmp = findSWF("my_chart");
- x = tmp.load( JSON.stringify(data_2) );
- }
- function findSWF(movieName) {
- if (navigator.appName.indexOf("Microsoft")!= -1) {
- return window[movieName];
- } else {
- return document[movieName];
- }
- }
- var data_1 = <?php echo $chart_1->toPrettyString(); ?>;
- var data_2 = <?php echo $chart_2->toPrettyString(); ?>;
- </script>
- </head>
- <body>
- <p>Open Flash Chart</p>
- //开源软件:phpfensi.com
- <div id="my_chart"></div>
- <br>
- <a href="javascript:load_1()">display data_1</a> || <a href="javascript:load_2()">display data_2</a>
- <p>
- Don't forget to 'view source' to see how the Javascript JSON data is loaded.
- </p>
- </body>
- </html>
Tags: Open Flash Chart php多报表
相关文章
- ·php fsockopen邮箱发送实例代码(2014-01-22)
- ·openssl使用DSA算法生成签名实例详解(2014-08-21)
- ·php open_basedir安全与使用详解(2014-08-22)
- ·php中fsockopen模仿post与get详解(2014-08-27)
- ·php中fsockopen采集网页内容实例(2014-08-28)
- ·PHP利用socket模拟post之fsockopen发送数据(2014-09-05)
- ·php中fsockopen详细实例代码(2014-09-09)
- ·php fsockopen 伪造 post和get方法(2014-09-09)
- ·微信公众平台网页获取用户OpenID方法(2015-04-08)
- ·PHP tclip扩展调用opencv从内存中读取及解析图片数据的问题(2015-04-09)
- ·收藏PHP常用自定义函数(2016-08-25)
- ·OpenCart 开发支付宝,财付通,微信支付参数错误问题(2016-08-25)
- ·php fsockopen解决办法 php实现多线程(2020-08-28)
- ·php定时计划任务与fsockopen持续进程实例(2021-01-10)
- ·基于OpenCart 开发支付宝,财付通,微信支付参数错误问题(2021-06-19)
- ·PHP 7.1中AES加解密方法mcrypt_module_open()的替换方案(2021-08-12)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)