【无标题】

echart电量显示案例参考,销售预测折线图分段

以今天为结点,今天之前为实际历史销量,今天之后为预测销量

 draw_graph(){
                this.salesChart = this.$echarts.init(document.getElementById('recommend_graph'))
                let option = {
                title: {
                    text: `${this.cur_sellerSku}`,
                },
                dataZoom:[{
                    type:'slider',            
                    orient: 'horizontal',
                    rangeMode: "value",
                    backgroundColor: 'rgba(0,0,0,0)',       
                    dataBackgroundColor: '#eee',            
                    fillerColor: 'rgba(144,197,237,0.2)',   
                    handleColor: 'rgba(70,130,180,0.3)',
                    start:0,
                    end:100
                },{
                    type: 'inside',
                    realtime: true,
                }],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                    type: 'cross'
                    },
                    formatter:(params)=>{
                    var res = "<div style='width:100%;height:24px;line-height:24px;'>" + params[0].name + "</div>";
                    if(params[0].name<this.start_recommend_time){
                        res += `<div style="color: #fff;font-size: 14px; padding:0 12px;line-height: 24px">`+
                            `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${[params[0].color,]};"></span>
                            sales:
                            ${params[0].value}
                        </div>`;
                    }else{
                        res += `<div style="color: #fff;font-size: 14px; padding:0 12px;line-height: 24px">`+
                            `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${[params[0].color,]};"></span>
                            recommend:
                            ${params[0].value}
                        </div>`;
                    }
                    return res;
                    }
                },
                toolbox: {
                    feature: {
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true },
                    },
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data:[],
                },
                yAxis: {
                    type: 'value',
                    axisPointer:{
                    snap:true
                    }
                },
                visualMap: {
                    show: false,
                    dimension: 0,
                    pieces: []
                },
                series:[{
                    name: 'sales',
                    type: 'line',
                    smooth: true,
                    data:[],
                    markArea:{
                        itemStyle: {
                        color: 'rgba(255, 173, 177, 0.1)'
                        },
                        data:[
                        [{
                            name:'',
                            xAxis:'',
                        },{xAxis:''}]
                        ]
                    }
                }]
                };
                option.xAxis.data = this.date
                option.series[0].data = this.data
                option.visualMap.pieces[0] = {lte:this.last_sale_index,color:'#0f0'}
                option.visualMap.pieces[1] = {gt:this.last_sale_index,lte:this.data.length-1,color:'#f00'}
                option.series[0].markArea.data[0][0].name=`Recommend start time ${this.start_recommend_time} End time ${this.end_time}`
                option.series[0].markArea.data[0][0].xAxis=this.start_recommend_time
                option.series[0].markArea.data[0][1].xAxis=this.end_time
                option.dataZoom[0].startValue  = 0
                if(this.cur_range_type==1){
                    if(this.last_sale_index+30 < this.date.length){
                        option.dataZoom[0].endValue = this.last_sale_index+30
                    }else{
                        option.dataZoom[0].endValue = this.date.length-1
                    }
                }else if(this.cur_range_type==2) {
                    if(this.last_sale_index+90 < this.date.length){
                        option.dataZoom[0].endValue = this.last_sale_index+90
                    }else{
                        option.dataZoom[0].endValue = this.date.length-1
                    }
                }else if(this.cur_range_type==3){
                    if(this.last_sale_index+365 < this.date.length){
                        option.dataZoom[0].endValue = this.last_sale_index+365
                    }else{
                        option.dataZoom[0].endValue = this.date.length-1
                    }
                }else if(this.cur_range_type==4){
                    option.dataZoom[0].endValue = this.date.length-1
                }else {}
                this.salesChart.setOption(option,true)
                this.salesChart.resize()
            },

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值