zoukankan      html  css  js  c++  java
  • Highcharts实例

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
        <head>
            <title>Highcharts Example</title>
            <script type="text/javascript" src="<%=request.getContextPath() %>/script/jquery/jquery-1.5.1.min.js"></script>
            <script type="text/javascript" src="<%=request.getContextPath() %>/script/highcharts/highcharts.js"></script>
            <script type="text/javascript" src="<%=request.getContextPath() %>/script/highcharts/exporting.js"></script>
    <script type="text/javascript">
         $(document).ready(function(){
            var jsonXDate=[];
            var jsonD1=[];
            var jsonD2=[];
            
            $.ajax({
                url: '/testServlet?command=getScreens1',
                context: document.body,
                success: function(data){
                                    
                    var screenMap = $.parseJSON(data),
                        screens = screenMap.screens;
                        
                    if(screens.length>0){    
                        for(var i=0;i<screens.length;i++){
                            jsonXDate.push(screens[i].name);
                            
                            jsonD1.push(parseInt(screens[i].title));
                        }
                        
                         var chart;
                                 
                                  chart = new Highcharts.Chart({
                                      chart: {
                                                  renderTo: 'container', 
                                                  //zoomType: 'xy',
                                                  //backgroundColor: '#CCCCCC',
                                                 // borderWidth: '1',
                                                  //borderRadius: '5',
                                                  //plotBackgroundColor: '#DDDDDD',
                                                  //plotBorderColor: '#EEEEEE',
                                                  reflow: true,
                                                  type: 'bar'
                                                  //line, spline, area, areaspline, column, bar, pie , scatter
                                              },
                                      
                                                  
                                                      
                                      title: {
                                                text: '柱状图'    
                                            },
                                    xAxis: {
                                                //categories:  ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'],
                                                categories:  jsonXDate,
                                                lineWidth: 2,
                                                labels: {  
                                                            rotation: -45, //字体倾斜
                                                            align: 'right',  
    
                                                            style: { font: 'normal 13px 宋体' }  
    
                                                            } 
                                                            
                                            },
                                    yAxis: {
                                                lineWidth: 2,
                                                title: {
                                                        text : '得分'
                                                }            
                                            },
                                    tooltip: {
                                                formatter: function() {
                                                            return '<b>'+ this.x +'</b><br/>'+this.series.name +': '+ Highcharts.numberFormat(this.y, 0); 
                                                }
                                            },
                                    plotOptions: {
                                                bar: {
                                                         dataLabels: { 
                                                            enabled: true 
                                                },  
                                                enableMouseTracking: true//是否显示title  
                                                        }    
                                            },
                                    series: [{
                                                name: '成绩',
                                                //data: [80, 60, 70, 90]
                                                //data: [jsonD1[0], jsonD1[1], jsonD1[2], jsonD1[3]]
                                                data: jsonD1
                                            },{
                                                name: '次数',
                                                data: [50, 40, 70, 80]
                                                //data: jsonD1
                                            }]
                                  });
                    }                
                  }
                  
            });
        });
    
    </script>
        </head>
        <body>
    
    <div id="container"  ></div>
        </body>
    </html>
  • 相关阅读:
    心情不好的时候
    离骚
    沁园春.雪
    顾炎武《精卫》
    韩愈《祝融峰》
    Python量化交易的简单介绍
    H5页面跳转到小程序代码
    小程序上拉加载,下拉刷新
    第一阶段:Python开发基础 day36 并发编程之Process的join用法和其他用法
    课后练习 第一阶段:Python开发基础 day38 多线程相关小练习
  • 原文地址:https://www.cnblogs.com/mgzy/p/4015710.html
Copyright © 2011-2022 走看看