echart时日周分别统计

博客一定要及时写,做完项目再写,有些细节就忘记了。


最终效果描述

选时、日、周分别画出相应时间段的统计曲线

代码

<div class="mui-row" id="menu">
<div class="mui-col-xs-3" id="min" style="background: white;">分</div>
<div class="mui-col-xs-3" id="hour">时</div>
<div class="mui-col-xs-3" id="day">日</div>
<div class="mui-col-xs-3" id="week">周</div>
</div>
<div class="chart" id="lineChart"></div>
<script>
    //小函数,作用仅限于改变日周月的背景
    function allgray() {
        h("#min").css({
            background: '#f7f7f7'
        });
        h("#hour").css({
            background: '#f7f7f7'
        });
        h("#day").css({
            background: '#f7f7f7'
        });
        h("#week").css({
            background: '#f7f7f7'
        });
    }

    h("#min").tap(function() {
        allgray();
        h("#min").css({
            background: '#ffffff'
        });

        changeUnit("minute");
        interval = setInterval(updateData, 1000);
    });

    h("#hour").tap(function() {
        //改变背景颜色
        allgray();
        h("#hour").css({
            background: '#ffffff'
        });

        //改变曲线
        clearInterval(interval);
        changeUnit("hour");
    });

    h("#day").tap(function() {
        allgray();
        h("#day").css({
            background: '#ffffff'
        });

        clearInterval(interval);
        changeUnit("day");
    });

    h("#week").tap(function() {
        allgray();
        h("#week").css({
            background: '#ffffff'
        });
        clearInterval(interval);
        changeUnit("week");
    });
</script>

就这样

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值