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
    评论
Vue封装echarts饼图组件可以参考以下内容。 首先,需要引入echarts组件的使用参考,可以参考这篇博客文章来学习如何使用echarts组件进行饼图的封装。 其次,在Vue的页面中使用<chart>标签来放置echarts饼图组件。在data()方法中定义extraOption和seriesData,这两个参数用来配置echarts饼图的选项和数据。在echarts组件的初始化中,需要将extraOption和seriesData赋值为原始的配置选项和系列数据。 在js文件的default_option中,可以定义一些基本的配置内容,如标题、图例、提示框、坐标轴等。 最后,导出这些配置项供饼图组件使用。通过以上的步骤,就可以对Vue进行echarts饼图组件的封装了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vue实现 【echarts中 “9种” Pie饼图图例】的组件封装及调用](https://blog.csdn.net/weixin_50450473/article/details/122424201)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [vue中使用echarts进行封装使用,提高开发效率](https://blog.csdn.net/weixin_46002223/article/details/131274952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值