首页 > 其他分享 >Echart基本案例

Echart基本案例

时间:2023-06-30 22:45:12浏览次数:42  
标签:基本 echart value name 案例 10px border echarts Echart

一、静态效果图

 二,前期需要

2.1、vue3项目,Echart引入

2.2、原理解释略

案例代码1:

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

<script setup>
import * as echarts from 'echarts';
import { onMounted } from 'vue';
onMounted(() => initChart());
// 在这个初识化一个方法,包裹起来配置
const initChart = () => {  
  const RadarChartDom = document.getElementById('radarChart');
  const myChart = echarts.init(RadarChartDom);
// 开始配置
  const option = {
 
  legend: {
    data: ['Allocated Budget', 'Actual Spending']
  },
  radar: {
    // shape: 'circle',
    indicator: [
      { name: 'Sales', max: 6500 },
      { name: 'Administration', max: 16000 },
      { name: 'Information Technology', max: 30000 },
      { name: 'Customer Support', max: 38000 },
      { name: 'Development', max: 52000 },
      { name: 'Marketing', max: 25000 }
    ]
  },
  series: [
    {
      name: 'Budget vs spending',
      type: 'radar',
      data: [
        {
          value: [4200, 3000, 20000, 35000, 50000, 18000],
          name: 'Allocated Budget'
        },
        {
          value: [5000, 14000, 28000, 26000, 42000, 21000],
          name: 'Actual Spending'
        }
      ]
    }
  ]
  };

  myChart.setOption(option);
  window.onresize = () => {
    myChart.resize();
  };
};


</script>
View Code

代码案例2:

<template>
  <div class="echarts-box">
    <div id="pieCenterChart" style="width: 100%;height: 100%; min-height: 300px;"></div>
  </div>
</template>
<script setup>
import * as echarts from "echarts";

    /// 声明定义一下echart
    let echart = echarts;
    onMounted(() => {
      initChart();
    });
    onUnmounted(() => {
      echart.dispose;
    });
    
    // 基础配置一下Echarts
    function initChart() {
      let chart = echart.init(document.getElementById("pieCenterChart"));
      // 把配置和数据放这里
      chart.setOption({
   
        tooltip: {
      trigger: "item",
     
    },
    series: [
      {
        name: "Access From",
        type: "pie",
        radius: ["40%", "70%"],
        data: [
          { value: 1048, name: "苹果" },
          { value: 735, name: "葡萄" },
          { value: 580, name: "荔枝" },
          { value: 300, name: "AVids" },
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
      },
    ],
        
      });
      
      window.onresize = function() {
        //自适应大小
        chart.resize();
      };
    }


</script>
View Code

代码案例3:

<template>
  <div class="echarts-box">
    <div id="pieCenterChart" style="width: 100%;height: 100%; min-height: 300px;"></div>
  </div>
</template>
<script setup>
import * as echarts from "echarts";

    /// 声明定义一下echart
    let echart = echarts;
    onMounted(() => {
      initChart();
    });
    onUnmounted(() => {
      echart.dispose;
    });
    
    // 基础配置一下Echarts
    function initChart() {
      let chart = echart.init(document.getElementById("pieCenterChart"));
      // 把配置和数据放这里
      chart.setOption({
   
        tooltip: {
      trigger: "item",
     
    },
    series: [
      {
        name: "Access From",
        type: "pie",
        radius: ["40%", "70%"],
        data: [
          { value: 1048, name: "苹果" },
          { value: 735, name: "葡萄" },
          { value: 580, name: "荔枝" },
          { value: 300, name: "AVids" },
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
      },
    ],
        
      });
      
      window.onresize = function() {
        //自适应大小
        chart.resize();
      };
    }


</script>
View Code

代码案例4:

<template>
  <div class="echarts-box">
    <div id="pieRightChart" style="width: 100%;height: 100%; min-height: 300px;"></div>
  </div>
</template>
<script setup>
import * as echarts from "echarts";

    /// 声明定义一下echart
    let echart = echarts;
    onMounted(() => {
      initChart();
    });
    onUnmounted(() => {
      echart.dispose;
    });
    
    // 基础配置一下Echarts
    function initChart() {
      let chart = echart.init(document.getElementById("pieRightChart"));
      // 把配置和数据放这里
      chart.setOption({
   
        tooltip: {
          trigger: 'item'
        },
       
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: ['40%', '70%'],
            data: [
              { value: 1048, name: 'Search Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              // { value: 484, name: 'Union Ads' },
              // { value: 300, name: 'Video Ads' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      });
      window.onresize = function() {
        //自适应大小
        chart.resize();
      };
    }


</script>
View Code

代码案例5:

<template>
  <div class="echarts-box">
    <div id="pieRightChart" style="width: 100%;height: 100%; min-height: 300px;"></div>
  </div>
</template>
<script setup>
import * as echarts from "echarts";

    /// 声明定义一下echart
    let echart = echarts;
    onMounted(() => {
      initChart();
    });
    onUnmounted(() => {
      echart.dispose;
    });
    
    // 基础配置一下Echarts
    function initChart() {
      let chart = echart.init(document.getElementById("pieRightChart"));
      // 把配置和数据放这里
      chart.setOption({
   
        tooltip: {
          trigger: 'item'
        },
       
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: ['40%', '70%'],
            data: [
              { value: 1048, name: 'Search Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              // { value: 484, name: 'Union Ads' },
              // { value: 300, name: 'Video Ads' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      });
      window.onresize = function() {
        //自适应大小
        chart.resize();
      };
    }


</script>
View Code

首页:

<template>
    <div>
        <div>
            <a-row>
                <a-col :span="20" style="text-align: center; font-size: 20px;font-weight: bold;color: #343536;">
                <p><span>2027年</span> 柏旷科技有限公司 <span>碳排放记录结果分析</span></p>
                </a-col>
                <a-col :span="4" style="text-align: right;">
                    <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
</a-col>
            </a-row>
        </div>    
        <!-- 四个小卡片 -->
        <div style="height: 200px; margin: 15px;"  class="fist">
            
            <div class="item">
                <a-card class="bigbox">
                    <a-row>
                        <a-col :span="12" style="display: flex; align-items: flex-end">
                            <div class="text">总co排放量</div>
                        </a-col>
                        <a-col :span="12" style="text-align: right">
                            <div>
                                <img
                                    style="width: 50px; height: 50px; border-radius: 5px"
                                    src="https://img0.baidu.com/it/u=582752653,3386538207&fm=253&fmt=auto&app=138&f=GIF?w=500&h=500"
                                    alt=""
                                />
                            </div>
                        </a-col>
                    </a-row>
                    <div style="margin-top: 20px">
                        <a-row>
                            <a-col :span="20" style="display: flex; align-items: flex-end">
                                <div class="text2">0.02 <span class="span">万吨</span></div>
                            </a-col>
                            <a-col :span="2" style="text-align: right"> </a-col>
                        </a-row>
                        <a-divider style="height: 2px; background-color: #f1f1f0; margin-top: 3px" />
                        <a-row style="margin-top: -20px">
                            <a-col :span="12">
                                <div class="text3"><span>低于同行</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right">
                                <span class="text3">100%</span>
                            </a-col>
                        </a-row>
                    </div>
                </a-card>
            </div>            
            <div class="item">
                <a-card class="box">
                    <a-row>
                        <a-col :span="12" style="display: flex; align-items: flex-end">
                            <div class="text4">总co排放量</div>
                        </a-col>
                        <a-col :span="12" style="text-align: right">
                            <div>
                                <img
                                    style="width: 50px; height: 50px; border-radius: 5px"
                                    src="https://img0.baidu.com/it/u=582752653,3386538207&fm=253&fmt=auto&app=138&f=GIF?w=500&h=500"
                                    alt=""
                                />
                            </div>
                        </a-col>
                    </a-row>
                    <div style="margin-top: 5px">
                        <a-row>
                            <a-col :span="12" style="display: flex; align-items: flex-end">
                                <div class="text5">0.02 <span class="span">万吨</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right"> </a-col>
                        </a-row>
                        <a-divider style="height: 2px; background-color: #f1f1f0; margin-top: 0px" />
                        <a-row style="margin-top: -20px">
                            <a-col :span="12">
                                <div><span>低于同行</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right">
                                <span>100%</span>
                            </a-col>
                        </a-row>
                    </div>
                </a-card>
            </div>
            <div class="item">
                <a-card class="box">
                    <a-row>
                        <a-col :span="12" style="display: flex; align-items: flex-end">
                            <div class="text4">总co排放量</div>
                        </a-col>
                        <a-col :span="12" style="text-align: right">
                            <div>
                                <img
                                    style="width: 50px; height: 50px; border-radius: 5px"
                                    src="https://img0.baidu.com/it/u=582752653,3386538207&fm=253&fmt=auto&app=138&f=GIF?w=500&h=500"
                                    alt=""
                                />
                            </div>
                        </a-col>
                    </a-row>
                    <div style="margin-top: 5px">
                        <a-row>
                            <a-col :span="12" style="display: flex; align-items: flex-end">
                                <div class="text5">0.02 <span class="span">万吨</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right"> </a-col>
                        </a-row>
                        <a-divider style="height: 2px; background-color: #f1f1f0; margin-top: 0px" />
                        <a-row style="margin-top: -20px">
                            <a-col :span="12">
                                <div><span>低于同行</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right">
                                <span>100%</span>
                            </a-col>
                        </a-row>
                    </div>
                </a-card>
            </div>
            <div class="item">
                <a-card class="box">
                    <a-row>
                        <a-col :span="12" style="display: flex; align-items: flex-end">
                            <div class="text4">总co排放量</div>
                        </a-col>
                        <a-col :span="12" style="text-align: right">
                            <div>
                                <img
                                    style="width: 50px; height: 50px; border-radius: 5px"
                                    src="https://img0.baidu.com/it/u=582752653,3386538207&fm=253&fmt=auto&app=138&f=GIF?w=500&h=500"
                                    alt=""
                                />
                            </div>
                        </a-col>
                    </a-row>
                    <div style="margin-top: 5px">
                        <a-row>
                            <a-col :span="12" style="display: flex; align-items: flex-end">
                                <div class="text5">0.02 <span class="span">万吨</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right"> </a-col>
                        </a-row>
                        <a-divider style="height: 2px; background-color: #f1f1f0; margin-top: 0px" />
                        <a-row style="margin-top: -20px">
                            <a-col :span="12">
                                <div><span>低于同行</span></div>
                            </a-col>
                            <a-col :span="12" style="text-align: right">
                                <span>100%</span>
                            </a-col>
                        </a-row>
                    </div>
                </a-card>
            </div>

        </div>
        <!-- 2个组件  -->
        <a-card class="card3">
        <div class="second">            
                <div class="left">
                
                    <p style="margin-top: -5vh;" class="long">碳排放结果分析</p>
                    <left-radar-chart style="width: 100%;height: 100%;"></left-radar-chart>
                </div>
                
            <div class="right">
                <p style="margin-top: -5vh;" class="long">碳排放汇总</p><right-bar-chart></right-bar-chart></div>    
        
        </div>
    </a-card>
        <!-- 三个饼图 3个组件 -->
        <div class="third">
            <a-card class="card2">
                <div class="card-pie">
                    <div class="pie">
                        <div class="title">范围一排放</div>
                        <div style="border-bottom: 1px solid #ccc"></div>
                        <div style="margin-top: 2rem;">
                            <pie-left-chart style="width: 100%; height: 100%"></pie-left-chart>

                        </div>
                    </div>
                    <div class="pie">
                        <div class="title">范围二排放</div>
                        <div style="border-bottom: 1px solid #ccc"></div>
                        <div style="margin-top: 2rem;">
                    <pie-center-chart style="width: 100%; height: 100%"></pie-center-chart>
                        </div>
                    </div>
                    <div class="pie"><div class="title">范围三排放</div><div style="border-bottom: 1px solid #ccc;"></div>
                    <div style="margin-top: 2rem;">
                            <pie-right-chart style="width: 100%; height: 100%"></pie-right-chart>
                        </div>
            </div>
                </div>
            </a-card>
        </div>
    </div>
</template>
<script setup>
    import PieRightChart from './component/pieRightChart.vue'
    import PieCenterChart from './component/pieCenterChart.vue'
    import PieLeftChart from './component/pieLeftChart.vue'
    import RightBarChart from './component/rightBarChart.vue'
    import LeftRadarChart from './component/leftRadarChart.vue'
    const emit = defineEmits({ change: null })
     const onClose = () => {
                emit('change')
     } 
</script>

<style>
    .long {
        display: inline-block;
        padding-left: 10px;
        border-left: 5px solid #028c3f;
        font-size: 18px;
        /* font-size: 20px; */
    }
    .title {
        margin: 10px;
    }
    .card-pie {
        display: flex;
        justify-content: center;
        height: 50vh;
    }
    .pie {
        background-color: #f5f5f5;
        flex: 1;
        width: 30%;
        height: 45vh;
        border: 1px solid #ccc;
        border-radius: 5px;
        margin: 0 20px 10px 0;
    }
    .card2 {
        margin: 15px;
        width: 98%;
        height: 50vh;
        border-radius: 10px;
    }
    .card3 {
        margin: 15px;
        width: 98%;
        height: 55vh;
        border-radius: 10px;
    }

    .second {
        margin: 15px;
        display: flex;
        flex-direction: row;
    }

    .left {
        flex: 1;
        width: 50%;
        /* border: 1px solid #ccc; */
        height: 45vh;
        margin: 10px 10px 10px 0;
        border-radius: 5px;
        /* box-shadow: 0px 0px 2px 2px  #f5ecec; */
    }

    .right {
        flex: 1;
        width: 50%;
        /* border: 1px solid #ccc; */
        height: 45vh;
        margin: 10px 10px 10px 0;
    }
    .text5 {
        font-size: 24px;
        font-weight: bold;
    }
    .text4 {
        font-size: 18px;
    }
    .box {
        border: 2px solid #41a877;
        height: 150px;
        width: 80%;
        border-radius: 10px;
    }
    .text3 {
        color: white;
    }
    .text2 {
        font-weight: bold;
        font-size: 24px;
        color: white;
    }
    .span {
        font-size: 12px;
        font-weight: 100;
    }
    .text {
        font-size: 18px;
        color: rgb(231, 227, 227);
    }
    .bigbox {
        align-self: center;
        width: 90%;
        background: #efa64a;
        height: 180px;
        border-radius: 10px;
    }
    .fist {
        display: flex;
        background-color: #fff;
        border-radius: 10px;
    }
    .item {
        flex: 1;
        /* border: 1px solid #ccc; */
        margin: 5px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
</style>
View Code

 

标签:基本,echart,value,name,案例,10px,border,echarts,Echart
From: https://www.cnblogs.com/ischengzi/p/17512032.html

相关文章

  • python基本数据类型
    基本数据类型1、整型intage=182、浮点型floatsalary=1.53、字符串strname="mary"4、列表list   [ ],支持任意类型  [1,'jason',[1,2,3,4]]5、字典dic {"k":"v"} {'username':'mary','password':123}6、集合......
  • 【三】MySQL数据库之MySQL软件基本管理
    【三】MySQL数据库之MySQL软件基本管理关于Linux版本的基本管理与破解密码详情:【1】登录,设置密码(1)初始状态下,管理员root,密码为空,默认只允许从本机登录localhost(2)设置密码[root@egon~]#mysqladmin-urootpassword"123"(3)设置初始密码由于原密码为空,因此-p可以......
  • boost asio相关的使用-基本概念
    1端点boostasio的endpoint的使用,可以将ip和端口合并成一个端点(endpoint),端点是使用某个端口连接到的一个地址。不同类型的socket有它自己的endpoint类,比如ip::tcp::endpoint、ip::udp::endpoint和ip::icmp::endpoint如果想连接到本机的80端口,你可以这样做:ip::tcp::endpoint......
  • 1688阿里巴巴接口中国站按关键字搜索商品API接口采集宝贝详情数据演示案例
     按关键字搜索商品API接口的作用是通过输入关键字来搜索相关的商品信息。这个API接口允许开发者和商家根据用户输入的关键字进行商品搜索,以便展示相关的商品结果给用户。使用按关键字搜索商品API接口,可以实现以下功能:商品搜索:根据用户输入的关键字,通过API接口向电商平台发送搜索请......
  • linux 系统mount的基本格式及用法
    1、https://help.aliyun.com/knowledge_detail/72719.html?spm=5176.10695662.1996646101.searchclickresult.748f3ea1mxowC42、mount的基本格式为mount[-tvfstype][-ooptions]devicedir。“-tvfstype”指定文件系统的类型,一般文件格式有以下几种。光盘或光盘镜像:iso9660。......
  • 1688阿里巴巴接口中国站按关键字搜索商品API接口采集宝贝详情数据演示案例
    ​ 按关键字搜索商品API接口的作用是通过输入关键字来搜索相关的商品信息。这个API接口允许开发者和商家根据用户输入的关键字进行商品搜索,以便展示相关的商品结果给用户。使用按关键字搜索商品API接口,可以实现以下功能:商品搜索:根据用户输入的关键字,通过API接口向电商平台发......
  • DataSecurity Plus金融行业案例
    摘要:DataSecurityPlus是一款强大的数据安全解决方案,为金融机构提供全面的数据保护和合规性监控。本文将介绍DataSecurityPlus在金融行业的使用案例,包括文件审计、数据分类和合规性报告等功能的应用。DataSecurityPlus文件审计:金融机构处理大量的客户数据和财务信息,因此对文件的......
  • 云享·案例丨打造数智物流底座,华为云DTSE助力物联云仓解锁物流新“速度”
    摘要:华为云凭借领先的技术和快速响应的开发者支持服务,助力物联亿达实现云上资源高可用、提升系统安全性与稳定性,为物联亿达提供了扎实的数字化基础。本文分享自华为云社区《云享·案例丨打造数智物流底座,华为云DTSE助力物联云仓解锁物流新“速度”》,作者:华为云社区精选。数字化......
  • 硬件电路设计的基本流程、作用和注意事项
    硬件电路设计是一种设计电子设备硬件电路的过程,涉及多种电子元件的选型、连接方式、布局设计等工作。电子产品的功能都是靠硬件电路来实现的,硬件电路设计是电子产品设计的核心环节之一,也是电子工程师必备的一个技能。硬件问题越少对产品的影响就越小,这就体现出硬件电路设计的重要性......
  • 案例-修改-回显数据
     packagecom.itheima.mapper;importcom.itheima.pojo.Brand;importorg.apache.ibatis.annotations.Insert;importorg.apache.ibatis.annotations.ResultMap;importorg.apache.ibatis.annotations.Select;importjava.util.List;publicinterfaceBrandMapper......