我请问一下,谁知道highchart的X轴整点显示啊!

解决方案 »

  1.   

    我把代码贴上,请牛人们帮我看看啊!
    <%@ page language="java" pageEncoding="UTF-8"%>
    
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <html>
    <head>
    <script type="text/javascript" src="<%=basePath %>/js/jquery.js"></script>
    <script type="text/javascript" src="<%=basePath %>/js/highstock.js"></script>
    <script type="text/javascript" src="<%=basePath %>/js/grid.js"></script>
    <script type="text/javascript">
       $(function() {
    $.getJSON('testAction.do?method=show', function(json) {
    var data = json.parames;
    var strArray = new Array();
    for(var i=0;i<data.length;i++){
    strArray[i] = data[i].data;
    }
    // Create the chart
    $('#container').highcharts('StockChart', {
        chart: {
    zoomType: 'x'
        },
    title : {
    text : '曲线图'//图表标题
    },
    tooltip: {
        text:'时间',
                 xDateFormat: '%H:%M'//鼠标移动到趋势线上时显示的日期格式(小时)
             },
    yAxis: {
    title: {
    text: 'Y轴'
    }
    },

    xAxis:{
    type: 'datetime',
    align: 'center',
    allowDecimals:false
    },  credits : { 
                 enabled : false//去掉右下角的标志            
      }, 
    rangeSelector: {
    buttons: [{//定义一组buttons,下标从0开始
    type: 'minute',
    count: 5,
    text: '5m'
    },{
    type: 'minute',
    count: 10,
    text: '10m'
    },{
    type: 'minute',
    count: 15,
    text: '15m'
    },{
    type: 'minute',
    count: 20,
    text: '20m'
    },{
    type: 'minute',
    count: 25,
    text: '25m'
    },{
    type: 'minute',
    count: 30,
    text: '30m'
    },{
    type: 'minute',
    count: 35,
    text: '35m'
    },{
    type: 'minute',
    count: 40,
    text: '40m'
    },{
    type: 'minute',
    count: 45,
    text: '45m'
    },{
    type: 'minute',
    count: 50,
    text: '50m'
    },{
    type: 'minute',
    count: 55,
    text: '55m'
    },{
    type: 'minute',
    count: 60,
    text: '60m'
    },{
    type: 'hour',
    count: 1,
    text: '1h'
    }, {
    type: 'all',
    text: 'All'
    }],
    selected: 1,//表示以上定义button的index,从0开始

                // 是否允许input标签选框
                inputEnabled: false

        },
    series: [{
            name: '数据',
            data: strArray
             //pointInterval: 24 * 3600 * 1000
           
        }] });
    });
    });
    </script>
    </head>
        <body>
            <div id="container"></div>
        </body>
    </html>