码迷,mamicode.com
首页 > 其他好文 > 详细

Highcharts动态获取值

时间:2015-01-13 17:28:44      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">
        $(document).ready(function (){
        var options = {
                chart: {
                    renderTo: ‘container‘,
                    defaultSeriesType: ‘spline‘, //图表类型 line, spline, area, areaspline, column, bar, pie , column,scatter
                    inverted: false //左右显示,默认上下正向。假如设置为true,则横纵坐标调换位置
                },
                xAxis: {
                   categories:[],
                    title: {text: ‘时间‘}  //x轴坐标标题  labels:纵柱标尺
                },
                yAxis: {
                    title: {text: ‘点击量‘},  //Y轴坐标标题  labels:纵柱标尺
                    min:0
                },
                tooltip: {
                    formatter: function() {
                        //当鼠标悬置数据点时的格式化提示
                        return ‘总人数:‘ + Highcharts.numberFormat(this.y, 1)+‘人<br/>当前时间:‘+ this.x ;
                    }
                },
                credits: {
                    enabled: false
                },
                plotOptions: {
                    column: {
                        pointPadding: 0.2,  //图表柱形的
                        borderWidth: 0      //图表柱形的粗细
                    },bar: {
                        dataLabels: {
                            enabled: false
                        }
                    }
                },
                title: { text: ‘指定时间点击量统计图‘}, //图表主标题
             series:[]
            };
             $("#btn").click(function(){
               $.post("/tgSpreadServlet",{page:"dayget",sdate:$("#sdate").val(),edate:$("#edate").val(),surl:$("#sUrl").val()},function(data){
              var sd=$("#sdate").val();
               var ed=$("#edate").val();
               //计算相差天数
               var datediff=DateDiff(sd, ed);
               for(var i=0;i<datediff;i++){
                 var s=AddDays(sd,i);
                 options.xAxis.categories.push(s);
               }
              data=eval("("+data+")");
              options.series.push(data);
              var chart=new Highcharts.Chart(options);
              });
            });
                      
        });

 </cript>

Highcharts动态获取值

标签:

原文地址:http://www.cnblogs.com/nickhan/p/4221791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!