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

  • 相关阅读:
    angularJS中的MVC思想?
    angularJs初体验,实现双向数据绑定!使用体会:比较爽
    原生JS去解析地址栏的链接?超好用的解决办法
    HDCMS多图字段的使用?
    sublime添加到鼠标右键打开文件的方法?
    Ajax做列表无限加载和Ajax做二级下拉选项
    Atitit.获取某个服务 网络邻居列表 解决方案
    Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
    Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
    Atitit.prototype-base class-based  基于“类” vs 基于“原型”
  • 原文地址:https://www.cnblogs.com/nickhan/p/4221791.html
Copyright © 2020-2023  润新知