echarts 单组件页面

<template>

  <div>

    <div id="chartLineBox" style="width: 100%; height: 100%"></div>

  </div>

</template>



<script>

import * as echarts from "echarts";

export default {

  name: "",

  components: {},

  props: {},

  data() {

    return {};

  },

  methods: {},

  computed: {},

  watch: {},

  created() {},

  mounted() {

    this.chartLine = echarts.init(document.getElementById("chartLineBox"));



    // 指定图表的配置项和数据

    var option = {

      tooltip: {

        //设置tip提示

        trigger: "axis",

      },



      legend: {

        //设置区分(哪条线属于什么)

        data: ["数据1", "数据2"],

        textStyle: {

          fontWeight: "normal",

          color: "rgb(255, 255, 255)", //legend颜色

          fontSize: "25",

        },

      },

      color: ["#8AE09F", "#5A56D1"], //设置区分(每条线是什么颜色,和 legend 一一对应)

      xAxis: [

        {

          type: "category",

          boundaryGap: false,

          data: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],

          //  改变x轴颜色

          axisLine: {

            lineStyle: {

              color: "rgb(255, 255, 255)",

            },

          },

          //  改变x轴字体颜色和大小

          axisLabel: {

            textStyle: {

              color: "rgb(255, 255, 255)",

              fontSize: "25",

            },

          },

        },

      ],

      yAxis: [

        {

          type: "value",

          //  改变y轴颜色

          axisLine: {

            lineStyle: {

              color: "rgb(255, 255, 255)",

            },

          },

          splitLine: {

            show: false, //去掉折线图中的横线

          },

          //  改变y轴字体颜色和大小

          axisLabel: {

            // formatter: '{value} m³ ', //  给y轴添加单位

            textStyle: {

              color: "rgb(255, 255, 255)",

              fontSize: "25",

            },

          },

        },

      ],

      series: [

        {

          name: "数据1",

          data: [220, 232, 201, 234, 290, 230, 220, 220, 220, 220, 220, 220],

          type: "line", // 类型为折线图

          lineStyle: {

            // 线条样式 => 必须使用normal属性

            normal: {

              color: "#8AE09F",

            },

          },

          smooth: true,

          areaStyle: {

            normal: {

              color: {

                x: 0,

                y: 0,

                x2: 0,

                y2: 1,

                colorStops: [

                  {

                    offset: 0,

                    color: "#0A3323", // 0% 处的颜色

                  },

                  {

                    offset: 0.7,

                    color: "#0A3323", // 100% 处的颜色

                  },

                ],

                globalCoord: false, // 缺省为 false

              },

            },

          },

        },

        {

          name: "数据2",

          data: [120, 200, 150, 80, 70, 110, 60, 60, 40, 100, 20, 20],

          type: "line",

          lineStyle: {

            normal: {

              color: "#5A56D1",

            },

          },

          smooth: true,

          areaStyle: {

            normal: {

              color: {

                x: 0,

                y: 0,

                x2: 0,

                y2: 1,

                colorStops: [

                  {

                    offset: 0,

                    color: "#191949", // 0% 处的颜色

                  },

                  {

                    offset: 0.7,

                    color: "#191949", // 100% 处的颜色

                  },

                ],

                globalCoord: false, // 缺省为 false

              },

            },

          },

        },

      ],

    };



    // 使用刚指定的配置项和数据显示图表。

    this.chartLine.setOption(option);

  },

};

</script>



<style scoped lang="scss">

</style>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值