網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
關(guān)于echarts各項(xiàng)內(nèi)容(包括圖表面積區(qū)域)設(shè)為漸變色已在上篇文章里全部闡述: echarts折線圖與柱狀圖等繪成漸變色的方法
單獨(dú)將tooltip拉出來(lái)再寫(xiě)一篇,是因?yàn)橛胒ormatter配合超文本的形式在echarts的配置項(xiàng)中,于自定義樣式方面很適合各類(lèi)加工以應(yīng)付UI和產(chǎn)品那邊提出的各種花里胡哨的設(shè)計(jì)
實(shí)現(xiàn)效果:
開(kāi)發(fā)頁(yè)面過(guò)程中寫(xiě)該模塊樣式時(shí)還原出的效果:
實(shí)現(xiàn)方法:
1、tooltip的shadow
在tooltip
的shadowStyle
里進(jìn)行配置:
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
shadowStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{ offset: 0, color: 'rgba(255, 255, 255, 0)' },
{ offset: 1, color: 'rgba(37, 107, 230, 0.18)' }
]
),
}
},
},
2、tooltip的文本框:
這部分沒(méi)有特供的配置屬性,直接用formatter
配合超文本的形式進(jìn)行樣式加工:
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
shadowStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{ offset: 0, color: 'rgba(255, 255, 255, 0)' },
{ offset: 1, color: 'rgba(37, 107, 230, 0.18)' }
]
),
}
},
backgroundColor: 'rgba(50,50,50,0)', // tooltip默認(rèn)背景為白色,手動(dòng)置為透明
borderWidth: 0,
formatter: function (params) {
let html = '';
html += `<div style="color: #fff;font-size: 16px;height: 125px;padding: 16px;
background: linear-gradient(180deg, rgba(37,108,233,0.44) 0%, rgba(23,80,169,0.1) 22%, rgba(20,64,137,0) 46%, rgba(16,51,111,0.28) 77%, rgba(30,101,213,0.4) 100%);
border-radius: 2px;border: 1px solid;border-image: radial-gradient(circle, rgba(111, 185, 242, 0.86), rgba(0, 0, 0, 0.2)) 1 1;
backdrop-filter: blur(10px);">
<div>
<div style="margin-bottom: 16px">${params[0].name}</div>
<div style="margin-bottom: 12px">
<span style="display:inline-block;margin-right:4px;border:1px solid #fff;border-radius:10px;width:10px;height:10px;background-color:#0CC8E6;"></span>
<span style="font-size: 14px;">${params[0].seriesName}</span>
<span style="margin-left: 16px;color: #0CC8E6;">${params[0].value}</span>
</div>
<div>
<span style="display:inline-block;margin-right:4px;border:1px solid #fff;border-radius:10px;width:10px;height:10px;background-color:#08BA57;"></span>
<span style="font-size: 14px;">${params[1].seriesName}</span>
<span style="margin-left: 16px;color: #08BA57;font-weight: bold;">${params[1].value}</span>
</div>
</div>
</div>`;
return html
},
},
其中,tooltip的marker圖例可以在formatter的參數(shù)中直接拿到:
可以直接拿來(lái)用也可以自己寫(xiě),復(fù)制粘貼后記得去掉兩個(gè)斜杠\
,案例中我是在原有的基礎(chǔ)上加了個(gè)白色邊框:
這邊值得一提的是CSS中的backdrop-filter這個(gè)屬性,在案例中實(shí)現(xiàn)了一個(gè)模糊濾鏡的效果
該屬性的各項(xiàng)配置效果具體可參考該文章:css的backdrop-filter
未來(lái)有時(shí)間再好好研究下這個(gè)屬性并將經(jīng)驗(yàn)輸出成文章分享給大家~
THX!
原文鏈接:https://blog.csdn.net/vvv3171071/article/details/128102631
- 上一篇:沒(méi)有了
- 下一篇:沒(méi)有了
相關(guān)推薦
- 2022-08-25 .net?core中高效的動(dòng)態(tài)內(nèi)存管理方案_實(shí)用技巧
- 2022-05-16 .NET中的HashSet及原理解析_實(shí)用技巧
- 2022-10-19 Android項(xiàng)目中引入aar包的正確方法介紹_Android
- 2022-09-16 Numpy中的shape、reshape函數(shù)的區(qū)別_python
- 2022-02-27 Web server failed to start. Port 8989 was already
- 2022-06-21 解決Git?Bash中文亂碼的問(wèn)題_其它綜合
- 2022-05-06 pyecharts的Tab和Legend布局詳情_(kāi)python
- 2022-07-14 Android檢測(cè)手機(jī)多點(diǎn)觸摸點(diǎn)數(shù)的方法_Android
- 欄目分類(lèi)
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支