Python Advanced Data Visualization Dash2

Source: Internet
Author: User

Python Dash Application Home page, is a K-line map to do Damo, but the data source used by Google, not to go. Of course, you can change Yahoo, but after all, the domestic is still more cordial.

The official demo with the Pandas_datareader to get data, first need to change a can get domestic data, looked at the next tushare very useful.

In addition, refer to flask, change host to 0.0.0.0, so it is not limited to 127.0.0.1来 access. Of course, the port can also be replaced if needed.

#-*-Coding:utf-8-*-"" "Created on Sun Mar one 10:16:43 2018@author:administrator" "" Import Dashfrom Dash.dependencies im Port Input, Outputimport dash_core_components as DCC import dash_html_components as Htmlfrom datetime import datetime as D T import tushare as TS app = Dash. Dash () App.layout = html. DIV ([HTML. H1 (' k-30 '), DCC. Dropdown (id= ' My-dropdown ', options=[{' label ': ' Ekodi ', ' value ': ' 600933 '}, {' label ': ' Gan            Feng li industry ', ' value ': ' 002460 '}, {' label ': ' China Shenhua ', ' value ': ' 601088 '}, {' label ': ' GAC group ', ' value ': ' 601238 '}, {' label ': ' Spring air ', ' value ': ' 601021 '},], value= ' 600933 '), DCC. Graph (id= ' my-graph ')]) @app. Callback (Output (' my-graph ', ' figure '), [Input (' My-dropdown ', ' value ')] def update_graph (selected_dropdown_value): # df = web. DataReader (# selected_dropdown_value, data_source= ' Yahoo ', # START=DT (2018, 1, 1), End=dt.now () #) d f = Ts.get_k_data (Selected_dropdown_value, ktype= ' 30') return {' data ': [{' X ': Df.index, ' y ':d f.close}]}if __name__ = = ' __main__ ': App.run_server (host= "0.0.0.0")

Python Advanced Data Visualization Dash2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.