设为首页收藏本站

birt家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3078|回复: 0

RGraph 官方图表示例(二)柱状图示例

[复制链接]
发表于 2012-5-24 11:22:53 | 显示全部楼层 |阅读模式
这是 RGraph官方提供的柱状图示例
效果如下:


代码如下:
  1. <%--
  2.     Document   : bar-charts
  3.     Created on : 2012-4-9, 17:01:22
  4.     Author     : 呼唤
  5. --%>
  6. <%@ include file="/common/tags.jsp"%>
  7. <%@ page contentType="text/html; charset=utf-8"%>
  8. <!DOCTYPE html>
  9. <html>
  10.     <head>
  11.         <title>RGraph: An example of a Bar chart</title>
  12.         <meta name="keywords" content="rgraph html5 canvas example bar charts" />
  13.         <meta name="description" content="An example of the Bar chart that RGraph can produce" />
  14.         <meta name="googlebot" content="NOODP">
  15.         <meta property="og:title" content="RGraph: HTML5 Javascript charts library" />
  16.         <meta property="og:description" content="A javascript charts library based on the HTML5 canvas tag" />
  17.         <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/>
  18.         <link rel="stylesheet" href="${ctx}/script/html5/rgraph/css/website.css" type="text/css" media="screen" />
  19.         <link rel="icon" type="image/png" href="${ctx}/script/html5/rgraph/images/favicon.png">
  20.         <!-- Place this tag in your head or just before your close body tag -->
  21.         <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  22.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.core.js" ></script>
  23.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.effects.js" ></script>
  24.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.tooltips.js" ></script>
  25.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.key.js" ></script>
  26.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.bar.js" ></script>
  27.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.common.core.js" ></script>
  28.         <script src="${ctx}/script/html5/rgraph/libraries/RGraph.bar.js" ></script>
  29.         <script>
  30.             $(function(){
  31.                 _createBar();
  32.             });
  33.             /**
  34.              * 创建柱状图
  35.              */
  36.             function _createBar(){
  37.                 var data = [[50,75],[32, 44],[61, 56],[91, 81],[92, 8],[34, 57],[56, 62],[55, 45],[36, 12],[44, 56],[51, 66],[68, 88]];
  38.                 var bar1 = new RGraph.Bar('bar1', data);
  39.                 bar1.Set('chart.background.barcolor1', 'white');
  40.                 bar1.Set('chart.background.barcolor2', 'white');
  41.                 bar1.Set('chart.labels', ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']);
  42.                 bar1.Set('chart.key', ['John', 'Bob']);
  43.                 bar1.Set('chart.key.position.y', 35);
  44.                 bar1.Set('chart.key.position', 'gutter');
  45.                 bar1.Set('chart.key.background', 'rgb(255,255,255)');
  46.                 bar1.Set('chart.colors', ['#77f', '#7f7']);
  47.                 bar1.Set('chart.shadow', true);
  48.                 bar1.Set('chart.shadow.blur', 15);
  49.                 bar1.Set('chart.shadow.offsetx', 0);
  50.                 bar1.Set('chart.shadow.offsety', 0);
  51.                 bar1.Set('chart.shadow.color', '#aaa');
  52.                 bar1.Set('chart.strokestyle', 'rgba(0,0,0,0)');
  53.                 bar1.Set('chart.gutter.left', 55);
  54.                 bar1.Set('chart.gutter.right', 5);
  55.                 bar1.Draw();
  56.             }
  57.         </script>
  58.     </head>
  59.     <body>
  60.         <canvas id="bar1" width="900" height="200">[No canvas support]</canvas>
  61.     </body>
  62. </html>
复制代码

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2020-8-7 17:22 , Processed in 0.273067 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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