天天看點

Ext Js 3.2 柱狀圖應用

1:源代碼

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>gridPanel</title>
    
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">    
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  
  <link rel="stylesheet" type="text/css" href="ext3.2/resources/css/ext-all.css"></link>
  <script type="text/javascript" src="ext3.2/adapter/ext/ext-base.js"></script>
  <script type="text/javascript" src="ext3.2/ext-all.js"></script>
  <script type="text/javascript" src="ext3.2/src/local/ext-lang-zh_CN.js"></script>
  
  <script type="text/javascript">
    Ext.onReady(function() {   //定義ColumnModel
      var store = new Ext.data.JsonStore({
      fields: ['name', 'visits', 'views'],
      data: [
        {name: '日本', visits: 245000, views: 3000000},
        {name: '南韓', visits: 240000, views: 3500000},
        {name: '泰國', visits: 355000, views: 2000000},
        {name: '伊朗', visits: 375000, views: 3200000},
        {name: '法國', visits: 590000, views: 3500000},
          {name: '德國', visits: 395000, views: 6800000},
        {name: '中國', visits: 580600, views: 8500000}
        ]
        });
    
     new Ext.Panel({
     title: '國際某某統計圖',
     renderTo: 'container',
     width: 500,
     height: 300,
     layout: 'fit',
     items: {
          xtype:'columnchart',
          store: store,
          xField: 'name',
          yField: 'visits',
          listeners: {
               itemclick: function(o) {
                      var rec = store.getAt(o.index);
                      Ext.example.msg('選擇提示', '你選擇了-{0}.', rec.get('name'));
               }
          }
     }
   });
});
  </script>
  </head>
  
  <body>
    <div id="container"> </div>
  </body>
</html>      

2:效果圖