js highcharts拆线图

 var differDay = "<?=$differDay?>";
    var isRegion = <?=$isRegion?>;

//单条曲线图付费金额数据和配置
    var myDate = new Date();
    var time = myDate.getTime();
    console.log(time);
    var date = new Date(time - 15 * 24 * 3600 * 1000);//15天前的时间戳
    var param = {'time': time};

    if(differDay!=1){//区间日期筛选时
        time = "<?=($etime+1)*1000?>";
        date = new Date(<?=$stime*1000?>);
        param = {'time': time,'differDay':differDay};
    }
    if(isRegion==1&&differDay==1){
        time = "<?=($etime+1)*1000?>";
        date = new Date(<?=$stime*1000?> - 15 * 24 * 3600 * 1000);//15天前的时间戳
        param = {'time': time,'differDay':differDay};
    }

    var xAxis = {
            type: 'datetime',
            tickInterval:  24 * 36e5, // one day
            labels: {
                format: '{value: %m/%d}',
                align: 'right',
                rotation: -30
            }
        };
    var yAxis =  {
        max: 0
    };
    var series=  [{
        data: [],
        pointInterval: 24 * 36e5,
        // 比当前时间差4天
        pointStart: Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
    }];
    var opt1 = {
        plotOptions: {
            series: {
                label: {
                    connectorAllowed: false
                },
            }
        },
        // 前15天
        // 设置x轴
        xAxis: xAxis,
        yAxis: yAxis,
        series:series,
        responsive: {
            rules: [{
                condition: {
                    maxWidth: 500
                },
                chartOptions: {
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom'
                    }
                }
            }]
        },

    };
    $(function(){
        var url =  $('#a-tab-1').attr('data-url');
        MXHY.send(url, param, 'get', function (res) {
            eval("opt1").yAxis.max = res['max'];
            eval("opt1").series[0].name = '付费金额';
            eval("opt1").series[0].data = res['data'];
            MXHY.hchart('container1',  eval("opt1"));
        });
    });
 /**
         * 图表.
         *
         * @param obj
         * @param opt
         */
        this.hchart = function (id, opts) {

            var options = {};

            // 公共配置
            var common = {
                title: {
                    text: ''
                },
                subtitle: {
                    text: ''
                },
                yAxis: {
                    title: {
                        text: ''
                    }
                },
                credits: {
                    enabled: false // 禁用版权信息
                },
                tooltip: {
                    enabled: true,
                },
                legend: {
                    enabled:false,
                },
            };

            // 合并参数
            $.extend(options, common, opts);

            try {
                Highcharts.chart(id, options);
            } catch (e) {
                console.error('对像不存在');
            }
        };



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值