首页 > 其他分享 >双Y轴曲线阴影 折线图

双Y轴曲线阴影 折线图

时间:2023-05-17 15:50:05浏览次数:28  
标签:WidthAdaptive show color 曲线 阴影 rgba 折线图 true 255

效果如下

 

代码:

<template>
  <div style="width: 406px; height: 190px" id="it_r_two"></div>
</template>

<script>
export default {
  name: "it_r_two",
  data() {
    return {};
  },
  mounted() {
    this.drawLine();
  },
  methods: {
    // 自适应字体大小变化
    WidthAdaptive(res) {
      var windth = window.innerWidth;
      let fontSize = windth / 1920;
      return fontSize * res;
    },
    drawLine() {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("it_r_two"));
      let xLabel = [
        "08/02",
        "08/03",
        "08/04",
        "08/05",
        "08/06",
        "08/07",
        "08/08",
      ];
      let goOutSchool = ["3", "1", "6", "3", "1", "6", "3"];
      let goOutSchool2 = ["2", "5", "1", "4", "3", "6", "9"];

      let option = {
        backgroundColor: "transparent",
        legend: {
          icon: "rect",
          itemWidth: this.WidthAdaptive(14),
          itemHeight: this.WidthAdaptive(4),
          itemGap: this.WidthAdaptive(14),
          padding: this.WidthAdaptive(2),
          textStyle: {
            color: "rgba(201, 229, 255, 1)",
            fontSize: this.WidthAdaptive(12),
            padding: [3, 0, 0, 0],
          },
        },
        grid: {
          top: "18%",
          left: "10%",
          right: "10%",
          bottom: "12%",
          // containLabel: true
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisLine: {
              //坐标轴轴线相关设置。数学上的x轴
              show: true,
              lineStyle: {
                color: "#8C9493",
              },
            },
            axisLabel: {
              //坐标轴刻度标签的相关设置
              textStyle: {
                color: "rgba(201, 229, 255, .8)",
                fontSize: this.WidthAdaptive(12),
                padding: this.WidthAdaptive(2),
              },
              formatter: function(data) {
                return data;
              },
            },
            splitLine: {
              show: false,
              lineStyle: {
                color: "#192a44",
              },
            },
            axisTick: {
              show: false,
            },
            data: xLabel,
          },
        ],
        yAxis: [
          {
            name: "单位:MW",
            nameTextStyle: {
              color: "rgba(201, 229, 255, .8)",
              fontSize: this.WidthAdaptive(12),
            },
            splitLine: {
              lineStyle: {
                type: "dashed",
                color: "rgba(112,112,112,0.5)",
              },
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#8C9493",
              },
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: "rgba(201, 229, 255, .8)",
                fontSize: this.WidthAdaptive(12),
                padding: this.WidthAdaptive(3),
              },
            },
            axisTick: {
              show: false,
            },
          },
          {
            name: "单位:水/t",
            nameTextStyle: {
              color: "rgba(201, 229, 255, .8)",
              fontSize: this.WidthAdaptive(12),
            },
            splitLine: {
              lineStyle: {
                type: "dashed",
                color: "rgba(112,112,112,0.5)",
              },
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#8C9493",
              },
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: "rgba(201, 229, 255, .8)",
                fontSize: this.WidthAdaptive(12),
                padding: this.WidthAdaptive(3),
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "电耗趋势",
            type: "line",
            symbol: "circle", // 默认是空心圆(中间是白色的),改成实心圆
            showAllSymbol: true,
            symbolSize: 0,
            smooth: true,
            lineStyle: {
              normal: {
                width: this.WidthAdaptive(2),
                color: "rgba(59, 157, 255, 1)", // 线条颜色
              },
              borderColor: "rgba(0,0,0,.4)",
            },
            itemStyle: {
              color: "rgba(59, 157, 255, 1)",
              borderColor: "#646ace",
              borderWidth: this.WidthAdaptive(20),
            },
            tooltip: {
              show: true,
            },
            areaStyle: {
              //区域填充样式
              normal: {
                //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(59, 157, 255, .5)",
                    },
                    {
                      offset: 1,
                      color: "rgba(59, 157, 255, 0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(10,219,250, 0.5)", //阴影颜色
                shadowBlur: this.WidthAdaptive(20), //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
              },
            },
            data: goOutSchool,
          },
          {
            name: "水耗趋势",
            type: "line",
            symbol: "circle", // 默认是空心圆(中间是白色的),改成实心圆
            showAllSymbol: true,
            symbolSize: 0,
            yAxisIndex: 1,
            smooth: true,
            lineStyle: {
              normal: {
                width: this.WidthAdaptive(2),
                color: "rgba(255, 173, 14, 1)", // 线条颜色
              },
              borderColor: "rgba(0,0,0,.4)",
            },
            itemStyle: {
              color: "rgba(255, 173, 14, 1)",
              borderColor: "#646ace",
              borderWidth: this.WidthAdaptive(20),
            },
            tooltip: {
              show: true,
            },
            areaStyle: {
              //区域填充样式
              normal: {
                //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(255, 173, 14, .5)",
                    },
                    {
                      offset: 1,
                      color: "rgba(255, 173, 14, 0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(10,219,250, 0.5)", //阴影颜色
                shadowBlur: this.WidthAdaptive(20), //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
              },
            },
            data: goOutSchool2,
          },
        ],
      };
      window.onresize = function() {
        myChart.resize();
      };
      myChart.setOption(option);
    },
  },
};
</script>

<style scoped></style>

 

标签:WidthAdaptive,show,color,曲线,阴影,rgba,折线图,true,255
From: https://www.cnblogs.com/a973692898/p/17408933.html

相关文章

  • 【Echarts】柱状图折线图改变XY轴刻度标签的现实结果
    axisLabel:{show:true,//重点在这⬇️⬇️⬇️formatter:(value)=>{console.log(value,"=======>")return(value==0?`${value}`:`${value}%`)},//⬆️⬆️⬆......
  • 【Echarts】 柱状图折线图X轴随鼠标滑动延伸
    dataZoom属性://做自适应的时候精良不要使用Echarts的interVal属性 dataZoom:[{id:'dataZoom',type:'inside',xAxisIndex:[0],filterMode:'none',start:xAxis.length>100?100-(60*100/xAxis):0.//从哪个位置开始,自适应位置变化end:100//百分比,100的意思......
  • TMP的阴影性能如何
    1)TMP的阴影性能如何​2)CommandBuffer.DrawMeshInstanced无法画阴影问题3)Unity编辑器在Require大量加载Lua文件时,经常报出notenoughmemory4)场景制作的时候,2D资源受后处理调色影响比较大这是第335篇UWA技术知识分享的推送,精选了UWA社区的热门话题,涵盖了UWA问答、社区帖子等技术......
  • LOTO示波器如何测试阻抗的频响曲线
    LOTO示波器如何测试阻抗的频响曲线模块的输入输出端口,在电路分析上,一般简单表征为电阻来进行计算和分析。但多数情况下,这些端口并不是纯电阻的特性,更精确一些,它可能是电阻电容以及电感的组合,表现为非线性。我们称之为阻抗,比如输入阻抗,输出阻抗。随着通过的信号的频率变化,阻抗也会......
  • 使用C++实现贝塞尔曲线算法平滑多边形
    定义一个函数来计算贝塞尔曲线的坐标,并使用循环来更新坐标。把坐标连接起来,就可以得到一个平滑的多边形。例如:可以使用贝塞尔曲线或B样条曲线来实现曲线平滑。这两种曲线都是由一组控制点构成的,并且可以通过调整控制点来调整曲线形状。贝塞尔曲线是一种由多个点组成的曲线,其中每......
  • Matlab利用蒙特卡洛模拟,将电动汽车EV分为一充二充三充三种类型,仿真电动汽车负荷曲线。
    Matlab利用蒙特卡洛模拟,将电动汽车EV分为一充二充三充三种类型,仿真电动汽车负荷曲线。蒙特卡洛模拟次数、电动汽车参数等易于修改。YID:5220643491185262......
  • C#上位机源代码,采集西门子200smart温度数据并显示波形曲线,温度到达上限值或下限值进行
    C#上位机源代码,采集西门子200smart温度数据并显示波形曲线,温度到达上限值或下限值进行报警提示。采集的数据每天生成一个excel报表,全套源代码YID:5331639981902747......
  • Qt_c++上位机2套串口实时曲线带平滑 1,设置串口. 2,串
    Qt_c++上位机2套串口实时曲线带平滑1,设置串口.2,串口收发数据。3,数据模拟。4,接收数据形成曲线。5,曲线控件的各种外观设置。6,可以设置平滑曲线。参数如下:-----------------------------1)编程语言:C++(11或以上);-----------------------------2)编程环境:QT5.14;-----------------......
  • C# MVP架构力位移曲线监控源码! 1,完整工程,完整应。 2,现
    C#MVP架构力位移曲线监控源码!1,完整工程,完整应。2,现场实战项目,vs2015开发。3,用到dev控件,我会赠送。4,完整yuan代码可编译,可修改,可debug。5,这是一个工业应用上位机,下位机为plc。6,设备启动后上下位机通信完成全自动动作。7,tcpip扫码,监控曲线,存数据,导数据。YID:79396267090793......
  • 常用制冷剂饱和蒸汽 压力-温度 曲线的 多项式拟合
    制冷剂饱和蒸汽的压力-温度曲线为一单调连续曲线.调试时常常提到的蒸发压力-蒸发温度,冷凝压力-冷凝温度,过热度,过冷度等常用参数,均和该曲线有关.现在,可以用制冷剂的状态方程来计算.但目前,这些方程要么参数非常多,或者带一些非初等函数,比如指数函数,对数函数等,这些对于......