玩转Highcharts图表库系列(二) 沿X轴设置不同的背景色分辨带

在Highcharts中文网里,介绍了如何按照Y轴的数值范围设置背景色,也叫分辨带,它提供的demo效果像这样:

这里写图片描述

代码在这里

而如果要想沿着X轴设置不同的背景色或者叫分辨带该怎么办呢,在笔者的项目中,就曾经碰到过这样的需求。因为电能统计的时候是按照用电时间区分峰平谷电价的。尽量调节用电高峰到谷时电价区间,是节能的一个办法。效果图如下:

这里写图片描述

代码如下:

        // 一天24小时的曲线图,有峰平谷背景色
        function chartsDay(renderTo) {
   
            return {
                chart: {
                    zoomType: 'x',
                    resetZoomButton: {
                        theme: {
                            fill: 'white',
                            stroke: 'silver',
                            r: 0,
                            states: {
                                hover: {
                                    fill: '#000',
                                    style: {
                                        color: 'white'
                                    }
                                }
                            }
                        }
                    },
                    renderTo: renderTo,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    height: 382,
                    plotShadow: false,
                    type: 'spline'
                },
                title: {
                    text: currentRoom == 0 ? '总功率 ' + theYear + '年' + (theMonth + 1) + '月' + theDay + '日' : currentRoom + ' 号房间 ' + currentRoomName + ' ' + theYear + '年'
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值