概念圖:使用Bokeh產生技術圖表

參考資料: Bokeh 探索頻道(2)~客製化技術圖表升級 在 Django 上使用数据可视化利器 Bokeh

![[bokeh指標views圖.png]]


參考老師的Blog文章,內附的程式碼就可以無痛升級美麗圖表,但是我架設在Django上,需要調整一下來顯示在Django頁面。

在Django的View.py 上收先引用:

from bokeh.embed import components

from bokeh.resources import CDN

在程式加入Blog內的function來產生資料跟已經畫好的圖表,使用components,產生javascript與 html區塊,最後在render頁面帶入參數 ![[bokeh指標views圖1.png]] ![[bokeh指標views圖2.png]]

在Django的templates頁面上,下圖是圖表的Html的Div區塊 ![[bokeh指標templates圖1.png]]


下圖是在script></script> 區塊中,先引用bokeh的js,我直接下載到我的本機,避免版本到時候又變了壞掉,最後使用bokeh產生的的javascript語法。 ![[bokeh指標templates圖2.png]]

就可以產生美美的圖了 ![[bokeh指標總圖.png]]

Comments

comments powered by Disqus

Related Posts


Published

Category

後端程式

Tags

Contact