This data visulasition project is simple but complex enough to understand how to use ploylt and dash to build interactive web application. You can interact with the generated visulisation in this link.
Use the app: https://stock-price-dash.herokuapp.com/
By checking the code of this application, you can learn the following topics.
- How to use Dash
- How to incorporate plotly graph object in Dash
- How to make your graph interactive using a callback function
- Working with Pandas dataframe
- Converting a series into Pandas's datetime
- Creating new column in a dataframe
- Slicing a dataframe based on some conditions
- Basic styling your web application
It shows two different plots. The scatter plot presents historical stock price comparison of three companies, Apple, Amazon and Google. You can choose what price you want to see using the radio buttons above the plot.
The other plot shows the volume of sales in different years. Again, you can choose a year (between 2015 to 2019) to play around.
A little note on how I publish the Python code in Heroku. If you do not have an account, first create an account. I am using the free tyre to publish my project. Then, follow this guidline. It says want you need to do step-by-step. I use GitHub as the repository. You can do it when you create the project in the Heroku website.
- Create an virtual environment to install dash and plotly or any other python packages. For mine I need to install Pandas. If you use your base environment, a lot of unnecessary packages will be installed in the Heroku server, which may cause problems, at least for free use.
- I linked my GitHub repository with Heroku. Whenever you are done with some stable changes push those changes in the master branch of your git repository and then update the heroku too.
When you update your project, push it on the master branch of your git repository and then execute the following command in the command line (you need to download the Heroku Cli)
git push heroku master
It will rebuild the app in the Heroku server.
Enjoy!!!