mirror of
https://github.com/pyecharts/pyecharts.git
synced 2025-12-08 20:59:23 +00:00
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
# coding=utf-8
|
|
from example.commons import Collector
|
|
from pyecharts import options as opts
|
|
from pyecharts.charts import Page, WordCloud
|
|
from pyecharts.globals import SymbolType
|
|
|
|
C = Collector()
|
|
|
|
words = [
|
|
("Sam S Club", 10000),
|
|
("Macys", 6181),
|
|
("Amy Schumer", 4386),
|
|
("Jurassic World", 4055),
|
|
("Charter Communications", 2467),
|
|
("Chick Fil A", 2244),
|
|
("Planet Fitness", 1868),
|
|
("Pitch Perfect", 1484),
|
|
("Express", 1112),
|
|
("Home", 865),
|
|
("Johnny Depp", 847),
|
|
("Lena Dunham", 582),
|
|
("Lewis Hamilton", 555),
|
|
("KXAN", 550),
|
|
("Mary Ellen Mark", 462),
|
|
("Farrah Abraham", 366),
|
|
("Rita Ora", 360),
|
|
("Serena Williams", 282),
|
|
("NCAA baseball tournament", 273),
|
|
("Point Break", 265),
|
|
]
|
|
|
|
|
|
@C.funcs
|
|
def wordcloud_base() -> WordCloud:
|
|
c = (
|
|
WordCloud()
|
|
.add("", words, word_size_range=[20, 100])
|
|
.set_global_opts(title_opts=opts.TitleOpts(title="WordCloud-基本示例"))
|
|
)
|
|
return c
|
|
|
|
|
|
@C.funcs
|
|
def wordcloud_diamond() -> WordCloud:
|
|
c = (
|
|
WordCloud()
|
|
.add("", words, word_size_range=[20, 100], shape=SymbolType.DIAMOND)
|
|
.set_global_opts(title_opts=opts.TitleOpts(title="WordCloud-shape-diamond"))
|
|
)
|
|
return c
|
|
|
|
|
|
Page().add(*[fn() for fn, _ in C.charts]).render()
|