Echarts 渐变折线图

24 篇文章 0 订阅
3 篇文章 0 订阅

图例:

代码:

<template>
  <div class="policPic">
    <div id="chart_example" ref="chart_example"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.drawLine();
    });
  },
  methods: {
    // 报警消息折线图

    drawLine() {
      let echarts = require("echarts");
      let myChart = echarts.init(chart_example);
      // let myChart = this.$echarts.init(chart_example);
      myChart.setOption({
        grid: {
          //距离外层box左右位置
          x: 60, //左
          y: 80, //上
          x2: 35, //右
          y2: 40, //下
          borderWidth: 1,
        },
        title: {
          text: "报警消息趋势图",
          textStyle: {
            fontSize: "20px",
            color: "#3A9CF9", //标题颜色
          },
          left: 15,
          top: 10,
        },
        xAxis: {
          name: "时",
          type: "category",
          boundaryGap: false,
          data: [
            "1:00",
            "2:00",
            "3:00",
            "4:00",
            "5:00",
            "6:00",
            "7:00",
            "8:00",
            "9:00",
            "10:00",
            "11:00",
            "12:00",
            "13:00",
            "14:00",
            "15:00",
            "16:00",
            "17:00",
            "18:00",
            "19:00",
            "20:00",
            "21:00",
            "22:00",
            "23:00",
            "24:00",
          ],
        },
        yAxis: {
          type: "value",
          name: "单位:次",
          left: -20,
          min: 0, // 设置y轴刻度的最小值
          //max:1800,  // 设置y轴刻度的最大值
          splitNumber: 9, // 设置y轴刻度间隔个数
        },
        series: [
          {
            data: [
              820,
              932,
              901,
              934,
              1290,
              1330,
              1320,
              158,
              356,
              405,
              509,
              610,
              700,
              810,
              500,
              560,
              816,
              660,
              718,
              569,
              257,
              1200,
              510,
              1300,
            ],
            type: "line",
            symbol: "none",
            areaStyle: {
              normal: {
                // 设置折线图颜色渐变
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  { offset: 1, color: "#F7F6F6" },
                  { offset: 0, color: "#84A6FF" },
                ]),
              },
            },
            lineStyle: {
              width: 1,
              color: "transparent",
            },
          },
        ],
      });
    },
  },
};
</script>

<style scoped>
.policPic {
  /* width: 1370px; */
  width: 87%;
  height: 635px;
  background: #ffffff;
  overflow: hidden;
}
#chart_example {
  width: 100%;
  height: 635px;
}
</style>

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值