设为首页收藏本站

birt家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3525|回复: 0

RGraph 官方图表示例(二十二)瀑布图

[复制链接]
发表于 2012-8-14 10:25:55 | 显示全部楼层 |阅读模式
这是RGraph 官方的瀑布图示例   
效果如下:


代码如下:
  1. <%@ include file="/common/tags.jsp"%>
  2. <%@ page contentType="text/html; charset=utf-8"%>
  3. <!DOCTYPE html>
  4. <html>
  5.     <head>
  6.         <title>RGraph: An example of the Waterfall chart</title>
  7.         <meta name="keywords" content="rgraph html5 canvas example waterfall charts" />
  8.         <meta name="description" content="An example of the Waterfall chart that RGraph can produce" />
  9.         <meta name="googlebot" content="NOODP">
  10.         <meta property="og:title" content="RGraph: HTML5 Javascript charts library" />
  11.         <meta property="og:description" content="A charts library based on the HTML5 canvas tag" />
  12.         <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/>
  13.         <link rel="stylesheet" href="${ctx}/script/html5/rgraph/css/website.css" type="text/css" media="screen" />
  14.         <link rel="icon" type="image/png" href="${ctx}/script/html5/rgraph/images/favicon.png">
  15.         <!-- Place this tag in your head or just before your close body tag -->
  16.         <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  17.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.core.js"></script>
  18.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.tooltips.js" ></script>
  19.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.dynamic.js" ></script>
  20.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.waterfall.js"></script>
  21.                 <!--[if lt IE 9]><script src="${ctx}/script/html5/rgraph/excanvas/excanvas.original.js"></script><![endif]-->
  22.         <script>
  23.             $(function(){
  24.                 _createChart();
  25.             });
  26.             /**
  27.              * 瀑布图
  28.              */
  29.             function _createChart(){
  30.                 var waterfall1 = new RGraph.Waterfall('waterfall1', [50,12,-50,-19, -130, 230])
  31.                 waterfall1.Set('chart.background.grid.autofit', true);
  32.                 waterfall1.Set('chart.background.grid.autofit.numhlines', 10);
  33.                 waterfall1.Set('chart.background.grid.autofit.numvlines', 25);
  34.                 waterfall1.Set('chart.title', 'A chart showing income/expenditure');
  35.                 waterfall1.Set('chart.colors', ['black','red','blue']);
  36.                 waterfall1.Set('chart.strokestyle', 'rgba(0,0,0,0)');
  37.                 waterfall1.Set('chart.units.pre', '$');
  38.                 waterfall1.Set('chart.units.post', 'k');
  39.                 waterfall1.Set('chart.total', true);
  40.                 waterfall1.Set('chart.labels', ['Sales',
  41.                     'Misc income',
  42.                     'Salaries',
  43.                     'Running costs',
  44.                     'Snacks',
  45.                     'Bake sales',
  46.                     'Gross']);
  47.                 waterfall1.Set('chart.tooltips', ['Traditional sales from the shops',
  48.                     'Miscellaneous income from neer-do-wells',
  49.                     'Salaries of the henchmen',
  50.                     'Running costs including fuel for the cars',
  51.                     'Sweets and snacks for the office',
  52.                     'Bake sales',
  53.                     'Gross before "tax"']);
  54.                 waterfall1.Set('chart.highlight.stroke', 'rgba(0,0,0,0)');
  55.                 waterfall1.Set('chart.shadow', navigator.userAgent.indexOf('Firefox') == -1); // In Firefox this seriously slows down the Grow animation
  56.                 waterfall1.Set('chart.shadow.color', '#aaa');
  57.                 waterfall1.Set('chart.shadow.blur', 5);
  58.                 waterfall1.Set('chart.shadow.offsetx', 0);
  59.                 waterfall1.Set('chart.shadow.offsety', 0);
  60.                 waterfall1.Set('chart.gutter.left', 50);
  61.                 waterfall1.Set('chart.xaxispos', 'center');
  62.                 waterfall1.Draw();
  63.             }
  64.         </script>
  65.     </head>
  66.     <body>
  67.         <script>
  68.             if (RGraph.isOld()) {
  69.                 document.write('<div style="background-color: #fee; border: 2px dashed red; padding: 5px"><b>Important</b><br /><br /> Internet Explorer does not natively support the HTML5 canvas tag, so if you want to see the charts, you can either:<ul><li>Install <a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a></li><li>Use ExCanvas. This is provided in the RGraph Archive.</li><li>Use another browser entirely. Your choices are Firefox 3.5+, Chrome 2+, Safari 4+ or Opera 10.5+. </li></ul> <b>Note:</b> Internet Explorer 9 fully supports the canvas tag.</div>');
  70.             }
  71.         </script>
  72.         <div>
  73.             <canvas width="900" height="300" id="waterfall1">[No canvas support]</canvas>
  74.         </div>
  75.     </body>
  76. </html>
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|birt家园    

GMT+8, 2020-8-7 16:44 , Processed in 0.255835 second(s), 19 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表