echarts折线图

linechart: function(num) {
                var mySize = document.getElementById('consumer-trend-line');
                mySize.style.width = 360 + 'px';
                mySize.style.height = 260 + 'px';
                var myLineChart = echarts.init(mySize);
                var xdata = this.lineDatas.map(v => v.name);
                var year = this.dataRangeArr[this.dataRangeIndex].startDate.slice(0, 4);
                var month = this.dataRangeArr[this.dataRangeIndex].startDate.slice(5, 7);
                var saturdayList = this.getMonthSaturdayDate(year, month);
                switch (num) {
                    case 0:
                        var seriesData = [];
                        this.lineDatas.map(v => {
                            if (v.isException == 1) {
                                if (v.date == this.formatDateTwo(new Date(year, month, 0)) ||
                                    saturdayList
                                    .includes(v.date)) {
                                    seriesData.push(Object.assign(v, {
                                        itemStyle: {
                                            color: '#0BDB7E',
                                            borderWidth: 1.5
                                        }
                                    }))

                                } else {
                                    seriesData.push(Object.assign(v, {
                                        itemStyle: {
                                            color: '#0BDB7E',
                                            borderWidth: 1.5
                                        },
                                        symbol: 'none'
                                    }))
                                }
                            } else {
                                if (v.date == this.formatDateTwo(new Date(year, month, 0)) ||
                                    saturdayList
                                    .includes(v.date)) {
                                    seriesData.push(Object.assign(v, {
                                        itemStyle: {
                                            color: '#FF8646',
                                            borderWidth: 1.5
                                        }
                                    }))
                                } else {
                                    seriesData.push(Object.assign(v, {
                                        itemStyle: {
                                            color: '#FF8646',
                                            borderWidth: 1.5
                                        },
                                        symbol: 'none'
                                    }))
                                }
                            }
                        });
                        break;
                    case 1:
                        var seriesData = [];
                        this.lineDatas.map(v => {
                            if (v.isException == 1) {
                                seriesData.push(Object.assign(v, {
                                    itemStyle: {
                                        color: '#0BDB7E',
                                        borderWidth: 1.5
                                    }
                                }))
                            } else {
                                seriesData.push(Object.assign(v, {
                                    itemStyle: {
                                        color: '#FF8646',
                                        borderWidth: 1.5
                                    }
                                }))
                            }
                        });
                        break;
                }
                var option = {
                    xAxis: {
                        type: 'category',
                        data: xdata
                    },
                    yAxis: {
                        type: 'value',
                    },
                    series: [{
                        data: seriesData,
                        type: 'line',
                        smooth: true,
                        areaStyle: {
                            color: 'linear-gradient(180 deg, #0DDE7E 0%, rgba(4, 205, 124, 0) 100%)',
                            opacity: 0.2
                        },
                        lineStyle: {
                            color: '#0BDB7E'
                        }
                    }],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow',
                            shadowStyle: {
                                color: 'transparent'
                            }
                        },
                        extraCssText: `width:109px;height:55px;line-height:33rpx;background: no-repeat center/100% url(./static/images/consumeTrendbgm.png);

font-size:24rpx;font-family: PingFangSC-Medium, PingFang SC;font-weight: 500;

color: #FF8646;padding:13rpx 12rpx 30rpx 17rpx;`,
                        confine: true,
                        position: function(pt) {
                            return [pt[0] - 27, pt[1] - 73];
                        },
                        formatter: function(data) {
                            let desp = ['', '消费金额偏高', '消费金额偏低'][data[0].data.isException - 1]
                            return data[0].name + '消费' + data[0].value + '元' + '<br>' + desp;
                        }
                    },
                };
                option && myLineChart.setOption(option);
                window.addEventListener('resize', function() {
                    myLineChart.resize();
                })
            },

<style>

        #consumer-trend-line {
                        position: absolute;
                        top: 120rpx;
                        left: 10rpx;
                        z-index: 100;
       }

</style>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值