Covid-19 Interactive Dashboard using Streamlit, Altair, and Heroku
By: Ben George
Tags: Altair, Python, Covid 19, Heroku, Streamlit

Introduction

The novel coronavirus scientifically termed with the name SARS-Cov-2 or COVID-19 has infected millions and millions of people worldwide.

Creator: Naeblys , Credit: Getty Images/iStockphoto

Many web and mobile applications are available to track the progress of the disease. The dashboards show the live updates of the daily cases, recoveries, deaths, active cases, the number of tests conducted, and so on. Most of the dashboards provide interactiveness only for the maps and not for other kinds of visualizations.

The main necessity to develop this application is to give more control to the user so that he can provide his input to visualize varieties of interactive charts and results. The application also allows the user even to view the very minute data points available in the chart by zooming, panning, and tooltip. The web application provides the answer to the users and also allows them to download every chart created.

Tools Used

The entire application was developed using open-source tools. The application was created using Python programming language along with the packages like Pandas, Altair, and Streamlit. The data required for the entire application was extracted from the Github repository.

Pandas Library

The Pandas library was used to read the data into a tabular format and to manipulate it. It is the most commonly used data science library for processing raw data. The data extracted from the source is cleaned, processed, and used to answer the questions related to the COVID-19 cases.

Altair Library

Altair is a Python interactive visualization open-source library, using which very beautiful and meaningful visualizations can be created with a few lines of code. The charts created using Altair are based on Vega and Vega-Lite grammar which allows describing in a JSON format. Altair is one of the very few libraries that follow the declarative visualization approach.

Streamlit Library

Streamlit is an open-source python library used to create interactive web applications and dashboards. The applications created using this library are highly interactive and informative. Streamlit library has a very pleasing and colorful user interface that can be used even by novice users.

Heroku

The implementation code along with the required files and the dataset is uploaded in Github. The application is deployed on the cloud using one of the famous cloud platform service called Heroku. It provides an easy way to deploy the web application just by directly linking it from the Github repository.

Application Description

The application is grouped into 3 categories visualizing country-wise cases, visualizing cases for multiple countries, and insights about COVID-19

Visualize Country-wise Daily New Cases, Deaths and Recoveries

The drop-down box will allow the user to select the country among the list of all countries. After selecting the country, the user can select the option to view the daily new cases or deaths or recoveries by date.

After selecting the options, the user can visualize the COVID-19 cases for the selected country in the form of an interactive line chart or scatter chart. The charts are interactive and can be zoomed to view the fine details of every data point in the chart.

Visualizing daily cases, deaths, and recoveries

Visualize Deaths, Confirmed vs Recoveries

The most interesting feature of this application is to visualize the deaths for the selected country as an interactive heat map. The number of deaths of the country is grouped based on day, day and month, date, date, and month. The user can get insights like which day or date or month had more COVID-19 deaths for the selected country.

The users can also visualize the cumulative confirmed and recovered cases over date as an area chart. These interactive charts will show the visual difference between the confirmed and recovered cases of the selected country. The charts can also be saved by clicking the … button near the chart.

Visualize Deaths, Confirmed vs Recoveries

Visualize Multiple Country COVID-19 Cases

The dashboard also allows the user to select multiple countries and visualize and compare the infections among the selected countries. The charts used for the comparison of the number of COVID-19 cases among countries are fireball chart, bar chart, and word-cloud. The chart also dynamically change whenever the selected countries are changed.

Visualize Multiple Country COVID-19 Cases

Insights Related to COVID-19 Cases

The application also provides the interface for the user to pick the date and to get the details of the country with more cases, deaths, recoveries on the selected date. The application also allows the user to know the country’s standings about the COVID-19 infections. Also, the users can see the actual dataset used for the entire analysis by selecting the month.

Insights Related to COVID-19 Cases

Implementation

The cleaned dataset is shown as a tabular format

Dataset

The user interface for the application was created using Streamlit. The code to create a very simple select box to choose the country using Streamlit is given below. This command shows a select box with a message “Select country” and by selecting all the 186 country names from the dataset.

country = st.selectbox(“Select country”,covid[“Country”][:186])

The below sample code is used to display the interactive scatter chart of daily cases for the selected country(from the select box) using the Altair library.

alt.Chart(covid[covid[“Country”]==country]).mark_circle().encode( x=”Date”, y=”New cases”, tooltip=[“Date”,”Country”,”New cases”] ).interactive()

Many of the Streamlit controls like radio button, sidebar, multi-select, etc were used. The complete code is available here.

Conclusion

The Covid-19 Interactive Dashboard application was designed for the users to visualize the COVID-19 infections in a simple and more interactive way. This application can be used for researchers to get more insights about the infections.

Links

Application Link: Covid-19 Interactive Dashboard

Github Repository: Github-Covid19

References

[1] https://covid19.who.int/

[2] https://ncov2019.live/

[3] https://coronavirus.jhu.edu/map.html

[4] https://towardsdatascience.com/covid-19-data-processing-58aaa3663f6

[5] https://raw.githubusercontent.com/CSSEGISandData/COVID-19