首頁 > 軟體

Python視覺化神器pyecharts繪製水球圖

2022-07-06 18:02:57

水球圖

水球圖首先是動態的效果,像水流一樣波動,所以看起來比較的舒服,一般用於業務裡面的完成率,其實和之前的儀表盤有點類似,但是我個人絕對水球圖更加的好,因為看起來比較的炫酷。

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType

c = (
Liquid()
.add("完成", [0.7, 0.3], is_outline_show=False, shape=SymbolType.DIAMOND)
.set_global_opts(title_opts=opts.TitleOpts(title="業務完成率"))
.render("菱形水球圖.html")
)

雙水球圖顯示

from pyecharts import options as opts
from pyecharts.charts import Grid, Liquid
from pyecharts.commons.utils import JsCode
l1 = (
Liquid()
.add("lq", [0.6, 0.7], center=["60%", "50%"])
.set_global_opts(title_opts=opts.TitleOpts(title="標題"))
)
l2 = Liquid().add(
"lq",
[0.3],
center=["25%", "50%"],
label_opts=opts.LabelOpts(
font_size=50,
formatter=JsCode(
"""function (param) {
return (Math.floor(param.value * 10000) / 100) + '%';
}"""
),
position="inside",
),
)
grid = Grid().add(l1, grid_opts=opts.GridOpts()).add(l2, grid_opts=opts.GridOpts())
grid.render("雙水球圖顯示.html")

正方形水球圖

其實只需要變動一下引數即可,和最開始的那個差不多。

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
Liquid()
.add("lq", [0.7, 0.7], is_outline_show=False, shape=SymbolType.RECT)
.set_global_opts(title_opts=opts.TitleOpts(title="標題"))
.render("正方形.html")
)

圓球水球圖

from pyecharts import options as opts
from pyecharts.charts import Liquid
c = (
Liquid()
.add("lq", [0.7, 0.7])
.set_global_opts(title_opts=opts.TitleOpts(title="圓球"))
.render("圓球.html")
)

 資料精度水球圖

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.commons.utils import JsCode

c = (
Liquid()
.add(
"lq",
[0.3254],
label_opts=opts.LabelOpts(
font_size=50,
formatter=JsCode(
"""function (param) {
return (Math.floor(param.value * 10000) / 100) + '%';
}"""
),
position="inside",
),
)
.set_global_opts(title_opts=opts.TitleOpts(title="標題"))
.render("資料精度水球圖.html")
)

炫酷水球超級好看

感覺這個顏色搭配還是不錯的

from pyecharts import options as opts
from pyecharts.charts import Liquid
c = (
Liquid()
.add("lq", [0.6, 0.7, 0.8], is_outline_show=False)
.set_global_opts(title_opts=opts.TitleOpts(title="標題"))
.render("無邊框水球圖.html")
)

到此這篇關於Python視覺化神器pyecharts繪製水球圖的文章就介紹到這了,更多相關 Python繪製水球圖內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com