• Highcharts动态获取值


    <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>

  • 相关阅读:
    《SQL 基础教程》第五章:复杂查询
    Ruby on Rails Tutorial 第一章笔记
    《Practical Vim》第十章:复制和粘贴
    《Practical Vim》第五章:命令行模式
    《SQL 基础教程》第四章:数据更新
    用户的三次登录验证及进度条
    socket模块开启一个永久性服务
    TCP协议实现切换目录
    爬取好友微信信息
    TCP协议中传输系统命令及上传下载文件
  • 原文地址:https://www.cnblogs.com/nickhan/p/4221791.html
Copyright © 2020-2023  润新知