hupili / python-for-data-and-media-communication-gitbook

An open source book on Python tailed for communication students with zero background
117 stars 62 forks source link

How to display a dynamic chart completely? [pyecharts render relative (percentage) width/ height] #136

Closed Jasmine-dudu closed 5 years ago

Jasmine-dudu commented 5 years ago

Troubleshooting

Describe your environment

Describe your question

We want to display a dynamic chart related to "Type top 10 apps" (the link: https://github.com/Jasmine-dudu/Big-Road/blob/master/Type%20top10%20Apps.html ) in the web page. However, we fail to show it completely like a static chart.

wechatimg338 wechatimg339

How to solve the problem?😣Great thx!🙇‍♀️

The web page can be found via the link: https://github.com/Jasmine-dudu/Big-Road/blob/master/index.html

hupili commented 5 years ago

@Jasmine-dudu , here is the solution:

https://nbviewer.jupyter.org/github/hupili/python-for-data-and-media-communication/blob/master/pyecharts-examples/pyecharts-resize.ipynb#Responsive-output-for-pyecharts

When you initialise the pyecharts object, give it a relative width/ height number, e.g.

chart = pyecharts.Bar(width='100%', height='90vh')

The HTML files rendered in this way can fit into Big Road responsive chart area easily.

ChicoXYC commented 5 years ago

Closed. Merged this issue into notes, you can refer here.