设为首页收藏本站

birt家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2725|回复: 0

RGraph 官方图表示例(九)单杠图

[复制链接]
发表于 2012-8-8 16:08:35 | 显示全部楼层 |阅读模式
这是 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 Horizontal Bar chart</title>
  7.         <meta name="keywords" content="rgraph html5 canvas example horizontal bar charts" />
  8.         <meta name="description" content="An example of the Horizontal Bar 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.dynamic.js" ></script>
  19.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.tooltips.js" ></script>
  20.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.effects.js" ></script>
  21.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.hbar.js" ></script>
  22.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.pie.js" ></script>
  23.         <script>
  24.             $(function(){
  25.                 _createChart();
  26.             });
  27.             /**
  28.              * 横向的柱状图
  29.              */
  30.             function _createChart(){
  31.                 var hbar = new RGraph.HBar('cvs', [688.9,233.6,223.6,165.3]);
  32.                 hbar.Set('chart.units.pre', '$');
  33.                 hbar.Set('chart.units.post', 'm');
  34.                 hbar.Set('chart.colors', ['#FDB515']);
  35.                 hbar.Set('chart.strokestyle', 'rgba(0,0,0,0)');
  36.                 hbar.Set('chart.labels.above', true);
  37.                 hbar.Set('chart.labels.above', true);
  38.                 hbar.Set('chart.vmargin', 15);
  39.                 hbar.Set('chart.background.grid', false);
  40.                 hbar.Set('chart.labels', ['Government of Haiti, multilateral\r\nagencies NHOs and private contractors','Budget support to government','Haiti Reconstruction fund','Loans to goverment']);
  41.                 if (!RGraph.isOld()) {
  42.                     hbar.Set('chart.tooltips', ['Government of Haiti, multilateral<br />agencies NHOs and private contractors','Budget support to government','Haiti Reconstruction fund','Loans to goverment']);
  43.                 }
  44.                 hbar.Set('chart.labels.above.decimals', 1);
  45.                 hbar.Set('chart.xlabels', false);
  46.                 hbar.Set('chart.gutter.left', 250);
  47.                 hbar.Set('chart.gutter.right', 50);
  48.                 hbar.Set('chart.gutter.top', 25);
  49.                 hbar.Set('chart.noxaxis', true);
  50.                 hbar.Set('chart.noxtickmarks', true);
  51.                 hbar.Set('chart.noytickmarks', true);
  52.                 RGraph.isOld() ? hbar.Draw() : RGraph.Effects.HBar.Grow(hbar);
  53.                 var pie = new RGraph.Pie('cvs', [65,35]);
  54.                 pie.Set('chart.colors', ['#FDB515', 'gray']);
  55.                 pie.Set('chart.labels', ['$1.28bn disbursed','$2.01bn* pledged']);
  56.                 pie.Set('chart.labels.sticks', true);
  57.                 pie.Set('chart.labels.sticks.length', 15);
  58.                 pie.Set('chart.exploded', 5);
  59.                 if (!RGraph.isOld()) {
  60.                     pie.Set('chart.shadow', true);
  61.                     pie.Set('chart.shadow.offsetx', 0);
  62.                     pie.Set('chart.shadow.offsety', 0);
  63.                     pie.Set('chart.shadow.blur', 10);
  64.                     pie.Set('chart.tooltips', ['$1.28bn disbursed','$2.01bn* pledged']);
  65.                 }
  66.                 pie.Set('chart.radius', 50);
  67.                 pie.Set('chart.centerx', 700);
  68.                 pie.Set('chart.centery', 180);
  69.                 pie.Set('chart.strokestyle', 'rgba(0,0,0,0)');
  70.                 RGraph.isOld() ? pie.Draw() : RGraph.Effects.Pie.RoundRobin(pie);
  71.             }
  72.         </script>
  73.     </head>
  74.     <body>
  75.         <script>
  76.             if (RGraph.isOld()) {
  77.                 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>');
  78.             }
  79.         </script>
  80.         <div style="text-align: center">
  81.             <canvas id="cvs" width="900" height="300" style="border: 1px solid gray ">[No canvas support]</canvas>
  82.         </script>
  83.     </div>
  84. </body>
  85. </html>
复制代码

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2020-9-24 15:15 , Processed in 0.271143 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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