Echarts——vue+echarts 简单使用折线图

折线图

<div class="power-echart">
          <div id="stationEchart">
            <qz-charts style="width: 100%; height: 100%" :options="lineAll"></qz-charts>
          </div>
        </div>
import { lineAll} from './config.js';
data里面定义
  data() {
    return {	
      lineAll: lineAll(),
     		}
     },
mounted(){
  this.lineCharts()
},
methods:{
  lineCharts() {
    //静态数据
      let energyConsumption = [190, 70, 30, 70, 60, 50];
      let energyIntensity = [90, 70, 30, 70, 60, 50];
      let year = [90, 70, 30, 70, 60, 50];
      //掉接口获取数据.....
      this.lineAll = lineAll(energyConsumption, energyIntensity, year);
    },
}

//config.js文件


import * as echarts from 'echarts';
let $black = `rgba(0,0,0,.8)`;

export const lineAll = (energyConsumption = [], energyIntensity = [], year = []) => {
    return {
        tooltip: {
            trigger: 'axis',
        },
        grid: {
            left: 10,
            top: 30,
            right: 15,
            bottom: 40,
            containLabel: true,
        },
        legend: {
            icon: 'circle',
            top: 0,
            data: ['功率', '辐照'],
        },
        color: ['#62D196', '#3B68F6'],
        xAxis: {
            type: 'category',
            boundaryGap: false,
            axisLine: {
                show: false,
                textStyle: {
                    color: '#666666', //处理x轴的文字颜色
                },

            },
            data: year,
            splitLine: {
                show: false,
                lineStyle: {
                    width: 1,
                    color: '#E6E6E8',
                },
            },
            axisTick: { //取消坐标轴刻度线
                show: false,
            },
            axisLabel: {
                textStyle: {
                    fontSize: 8,
                },
            },
        },
        yAxis: [{
                type: 'value',
                name: '功率kW',
                nameTextStyle: {
                    fontSize: 8,
                    padding: [0, 0, 0, 0],
                    color: '#666666',
                },

                axisLabel: {
                    textStyle: {
                        color: '#666666',
                        fontSize: 8,
                    },
                },
                axisTick: {
                    //取消y轴 -
                    show: false,
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        opacity: 0, //将y轴刻度线的opacity属性设置为0,即为隐藏刻度线
                    },
                },
                show: true,
                splitLine: {
                    lineStyle: {
                        type: 'dashed',
                    },
                    show: true,
                },
            },
            {
                type: 'value',
                name: '辐照W/㎡',
                nameTextStyle: {
                    fontSize: 8,
                    padding: [0, 0, 0, 0],
                },
                axisLabel: {
                    textStyle: {
                        fontSize: 8,
                    },
                },
                axisLine: {
                    show: false,
                },
                show: true,
                splitLine: {
                    show: false,
                },
                axisTick: {
                    //取消 -
                    show: false,
                },

            },
        ],
        series: [{
                name: '功率',
                data: energyConsumption,
                type: 'line',
                barWidth: 10,
                showSymbol: false,
                smooth: true,

            },
            {
                name: '辐照',
                data: energyIntensity,
                type: 'line',
                yAxisIndex: 1,
                barWidth: 10,
                lineStyle: {
                    width: 2,
                },
                showSymbol: false,
                smooth: true,
            },
        ],
    };
};

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值