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

echarts 自定义标注样式自定义tooltip弹窗样式

在这里插入图片描述

文章目录

  • 1. 实现根据经纬度自定义标注图片样式
  • 2. 实现鼠标悬浮标注自定义弹窗样式内容

1. 实现根据经纬度自定义标注图片样式

  1. 设置 symbol 属性为 image://${require("@/assets/img/dataView/point.png")} 图片地址即可,注意前面跟 image:// 特有的写法
  2. baseData 是经纬度数据,这里不贴了
let option = {tooltip: {.... //省略},geo: {.... //省略},series: [{type: "map",.... //省略},{type: "scatter",coordinateSystem: "geo",itemStyle: {color: "#f00",},tooltip: {trigger: "item",backgroundColor: "transparent",formatter: function (params) {return formatHtml(params.data);},},symbol: `image://${require("@/assets/img/dataView/point.png")}`,symbolSize: [48, 58],symbolOffset: [0, 0],z: 9999,data: this.baseData,},],
};

2. 实现鼠标悬浮标注自定义弹窗样式内容

  1. 结合上面代码,设置 tooltip 为自定义的一个函数 formatHtml ,内容如下,主要是自定义css样式即可
let formatHtml = ({ name, computilityData }) => {return `<div class="tooltip-chart"><div class="item"><span>基地名称</span><span class="name">${name}</span></div><div class="item"><span>基地CPU服务器数量</span><span>${computilityData?.baseCpuserverNumber || 0}</span></div><div class="item"><span>基地CPU总核数</span><span>${computilityData?.baseCpuScores || 0}</span></div><div class="item"><span>基地空闲CPU核数</span><span>${computilityData?.baseIdlecpuScores || 0}</span></div><div class="item"><span>基地内存空间总容量</span><span>${computilityData?.baseMemoryCapacity || 0}</span></div><div class="item"><span>基地空闲内存空间容量</span><span>${computilityData?.baseIdlememoryCapacity || 0}</span></div><div class="item"><span>基地存储空间总容量</span><span>${computilityData?.baseStorageCapacity || 0}</span></div><div class="item"><span>基地空闲存储空间容量</span><span>${computilityData?.baseIdlestorageCapacity || 0}</span></div><div class="item"><span>基地上行网络带宽总量</span><span>${computilityData?.baseUploadBandwidthCapacity || 0}</span></div><div class="item"><span>基地空闲上行网络带宽</span><span>${computilityData?.baseIdleuploadBandwidthCapacity || 0}</span></div><div class="item"><span>基地下行网络带宽总量</span><span>${computilityData?.baseDownloadBandwidthCapacity || 0}</span></div><div class="item"><span>基地空闲下行网络带宽</span><span>${computilityData?.baseIdledownloadBandwidthCapacity || 0}</span></div><div class="item"><span>基地GPU服务器数量</span><span>${computilityData?.baseGpuserverNumber || 0}</span></div><div class="item"><span>基地GPU总核数</span><span>${computilityData?.baseGpuScores || 0}</span></div><div class="item"><span>基地空闲GPU核数</span><span>${computilityData?.baseIdlegpuScores || 0}</span></div><div class="item"><span>基地NPU服务器数量</span><span>${computilityData?.baseNpuServerNumber || 0}</span></div><div class="item"><span>基地NPU总核数</span><span>${computilityData?.baseNpuScores || 0}</span></div><div class="item"><span>基地空闲NPU核数</span><span>${computilityData?.baseIdlenpuScores || 0}</span></div><div class="item"><span>基地FP16总算力</span><span>${computilityData?.baseFp16Computility || 0}</span></div><div class="item"><span>基地空闲FP16算力</span><span>${computilityData?.baseIdlefp16Computility || 0}</span></div><div class="item"><span>基地FP32总算力</span><span>${computilityData?.baseFp32Computility || 0}</span></div><div class="item"><span>基地空闲FP32算力</span><span>${computilityData?.baseIdlefp32Computility || 0}</span></div><div class="item"><span>基地显存总量</span><span>${computilityData?.baseGraphicsMemoryCapacity || 0}</span></div><div class="item"><span>基地空闲显存</span><span>${computilityData?.baseIdlegraphicsMemoryCapacity || 0}</span></div></div>`;
};
<style scoped lang="less">
/deep/ .tooltip-chart {background-color: transparent;width: 520px;height: 334px;background: url("../../../../assets/img/dataView/tooltip_bg.webp") no-repeat;background-size: 100% 100%;background-position: center;padding: 16px 25px 16px 20px;grid-gap: 0 40px;overflow: auto;display: grid;grid-template-columns: repeat(2, 1fr);.item {font-weight: 500;font-size: 13px;color: #ffffff;line-height: 20px;display: flex;justify-content: space-between;align-items: center;span {&:first-child {position: relative;padding-left: 14px;&::after {content: "";position: absolute;top: 50%;left: 0;transform: translateY(-50%);width: 5px;height: 5px;border-radius: 50%;background: #fff;}}&:last-child {text-align: left;}}}
}
</style>

http://www.mrgr.cn/news/29013.html

相关文章:

  • 接口测试整体框架
  • 论文1—《基于卷积神经网络的手术机器人控制系统设计》文献阅读分析报告
  • 艾体宝方案丨制造业BI解决方案:推动智能生产和数字化转型
  • PostgreSQL序列:创建、管理与高效应用指南
  • 机器学习—softmax的改进实现
  • 【测试框架篇】单元测试框架pytest(1):环境安装和配置
  • Linux | 进程间通信:管道、消息队列、共享内存与信号量
  • 815. 公交路线(24.9.17)
  • Cesium绘制可编辑线
  • Zabbix的安装与基本使用(主机群组、应用集、监控项、触发器、动作、媒介)
  • 【Android】Handler用法及原理解析
  • 实时数仓3.0DWD层
  • Python 入门教程(3)基础知识 | 3.5、运算符
  • rhat Linux虚拟机桥接网络配置
  • 【Linux】理解和解释shell命令的工具
  • phpstudy 建站使用 php8版本打开 phpMyAdmin后台出现网页提示致命错误:(phpMyAdmin这是版本问题导致的)
  • Visual Studio 2019/2022 IntelliCode(AI辅助IntelliSense)功能介绍
  • MOE论文汇总2
  • java实现常见的密钥派生函数(KDF)
  • 传知代码-KAN卷积:医学图像分割新前沿
  • Typora安装,使用,图片加载全流程
  • 算法训练——day13哈希Map、Set、Bucket
  • vivado中选中bd文件后generate output product是什么用,create HDL wrapper是什么用
  • Apache Airflow
  • 枚举类题目练习心得
  • 介绍⼀下泛型擦除