当前位置: 首页 > ds >正文

【Echarts】象形图

目录

  • 效果
  • 代码

效果

在这里插入图片描述

代码

<!-- 业务类型 -->
<template><div class="ywlx" :style="{ '--height': height }"><div class="header_count count_linear_bg"><div>当月业务总量<span class="common_count text_shadow">{{ countInfo.ywzl | thousandthFilter }}</span></div><div>当月预警率<span class="common_count lightblue1">{{ countInfo.yjv }}%</span></div></div><div class="echarts" :id="domId" /></div>
</template><script>
import { queryYwfxMonthByParam } from '@/api/screen-zhidu.js'export default {name: 'Ywlx',components: {},props: {height: {type: String,default: '100%'},echartsStyle: {type: Object,default: () => {return {xAxisColor: '#fff',yAxisColor: '#a3bfed',legendTextColor: '#88a5cb',xAxis: {axisLabel: { color: '#fff' },axisLine: { show: false },axisTick: { show: false }},toolTip: {backgroundColor: '#000000c2',borderColor: '#00000052',textStyle: { color: '#a3bfed' }}}}}},data() {return {Echarts: null,domId: 'YwlxEcharts',dataList: [],countInfo: {}}},computed: {options() {let xAxisData = ['', ''] // X轴左右要空出一部分,所以第一个和最后一个都为空let topData = [] // 峰值datathis.dataList.forEach((item, index) => {xAxisData.splice(index + 1, 0, this.$common.filter_dic('dp_lszx_zd_ywlx', item.zb_code))topData.push(item.value1)})return {tooltip: {show: false,trigger: 'axis',...this.echartsStyle.toolTip,formatter: (params) => {var info = params.find((item) => !!item.data && item.data !== '-')let html = '<span></span>'if (info) {html = `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:#1283ff"></span>${info.name}:${info.data}<br>`}return html}},xAxis: [{type: 'category',data: xAxisData,...this.echartsStyle.xAxis,axisLabel: {interval: 0,rotate: -45,textStyle: {color: '#fff'}}}],grid: {top: '30',left: '50',right: '20',bottom: '60'},yAxis: [{type: 'value',axisLabel: {color: this.echartsStyle.yAxisColor},splitLine: {lineStyle: {type: 'dashed',color: this.echartsStyle.yAxisColor},show: true}}],series: [{type: 'pictorialBar',barCategoryGap: '-60%', // 要有交叉的感觉,每个柱子宽度设置负数,就是100%+60%symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z', // 象形图形label: {show: true,formatter: '{c}',position: 'top',color: '#178dfa'},itemStyle: {borderColor: '#0acaff',borderWidth: 4,color: new this.$echarts.graphic.LinearGradient(1, 0, 0, 0, [{ offset: 0, color: '#1378e8' },{ offset: 1, color: '#06399ade' }])},data: ['-', ...topData, '-'] // X轴左右要空出一部分,所以第一个和最后一个都为空}]}}},watch: {},created() {},mounted() {window.addEventListener('resize', this.resizeFun)this.fetchData()},destroyed() {if (this.Echarts) {this.Echarts.dispose()window.removeEventListener('resize', this.resizeFun)}},methods: {resizeFun() {if (document.getElementById(this.domId)) {this.Echarts = this.$echarts.init(document.getElementById(this.domId))this.Echarts.resize()}},fetchData() {queryYwfxMonthByParam().then((res) => {this.$common.CheckCode(res, null, () => {res = {code: 200,msg: '',data: {yjv: 0.01,ywlxList: [{month_id: '202503',entry_code: '030104',zb_code: 'JYYW',value1: 100,value2: 0,value3: 0},{month_id: '202503',entry_code: '030104',zb_code: 'KSYW',value1: 200,value2: 0,value3: 0},{month_id: '202503',entry_code: '030104',zb_code: 'JSZYW',value1: 150,value2: 0,value3: 0},{month_id: '202503',entry_code: '030104',zb_code: 'JDCYW',value1: 300,value2: 0,value3: 0}],ywzl: 97049},timestamp: 1740998003314}const { ywlxList, ...info } = res.data || {}this.countInfo = infothis.dataList = (ywlxList || []).filter((item) => !!item.value1)this.init()})})},init() {if (this.Echarts) {this.Echarts.dispose()}const dom = document.getElementById(this.domId)this.Echarts = this.$echarts.init(dom)this.Echarts.setOption(this.options)}}
}
</script><style lang='scss' scoped>
@import '../index.scss';.ywlx {height: var(--height);display: flex;flex-direction: column;.echarts {flex: 1;}
}
</style>
http://www.xdnf.cn/news/9689.html

相关文章:

  • : influxdb + grafana+JMeter
  • 自回归建模模型(AR)
  • C++进阶--C++11(03)
  • 一种字典树的Python实现
  • 什么是数字化转型,如何系统性重构业务逻辑
  • Android 构建系统中常见的 .mk 文件及其作用
  • 涨薪技术|0到1学会性能测试第88课-Web_service_call函数
  • Spring AI Alibaba 发布企业级 MCP 分布式部署方案
  • LeetCode 169:多数元素 - 摩尔投票法的精妙解法
  • 【freertos-kernel】queue(发送)
  • # Python 语音助手本地的ollama实现
  • nt!MmMapViewInSystemCache函数分析PointerPte的填充
  • AD/DA HAL库API
  • 内容中台的构建基础是什么?
  • King3399(ubuntu文件系统)iic(i2c)功能测试
  • MP4视频文件播放Demo(附源码)
  • 头歌之动手学人工智能-Pytorch 之autograd
  • 算法 Arrays.sort()函数自定义排序(Comparator 接口)
  • [网页五子棋][匹配模块]服务器开发、用户管理器(创建匹配请求/响应对象、处理连接成功、处理下线)
  • 根据jvm源码剖析类加载机制
  • Python爬虫实战:研究Tornado框架相关技术
  • [Vue组件]半环进度显示器
  • 小猴子摆玩具
  • 计算机网络第一章计算机网络概述(竟成)
  • 小白成长之路-Linux操作系统-进程管理
  • 【机器人编程基础】python中的常用数据类型
  • ElasticSearch查询指定时间内出现的次数/2秒内出现的次数
  • 我们来学mysql -- 输出一份“数据备份还原”sh脚本
  • 手写字魔法消除1:数据集说明(含下载链接)
  • Kruskal算法剖析与py/cpp/Java语言实现