This is the source code for the landing page of the COVID-19 India Data Project. The goal of the landing page is to make the data quickly accessible, in its most basic form, for researchers to explore. Findings from the data will also be added to the landing page over time. Contributions are welcome! 🤗
frontend:~$ yarn
frontend:~$ yarn start
- The default sampling rate at which to display the graphs on the landing page: this setting will ensure that
graphs show data every
sampling_rate
days. This setting is in place to save downloading large amoutns of data for the viewer as well as to speed up the plotting on the browser.
"sampling_rate": 10
- List of states to display:
Each state in the configuration is key-ed by its short_name
which is the same as that used by the state
in its entry in the database (and is used for all calls to fetch data from it).
The full name is used for display purposes only.
The short_name
is also visible in the table schemas,
the raw link to this image from the wiki
is also provided in the config. You can mark your state as incomplete if the data extraction is not
complete yet.
"DL": {
"name" : "Delhi",
"short_name" : "DL",
"is_complete": true,
"link_to_db_schema" : "https://raw.githubusercontent.com/IBM/covid19-india-data/main/docs/images/DL_tables.png"
}
If you are running the DB locally for testing:
- Bring up the DB server here.
- Add link to the local server in the configuration file.
"data_server": "http://localhost:3456"
The frontend houses individual pages for each state that let's you explore the data for that state in detail, through time-series plots, tables, API queries, and so on.
Each state-level page on our landing page has some standard elements. These are all generated automatically from the configuration file and the DB schema. The data is primarily grouped into 3 tabs.
-
Visualization: This tab (open by default) allows you to visualize any data from a state's bulletin as a time-series or on a particular date. Each plot element is realized as a
BasicElement
described below. -
Schema View: This tab shows the Database schema for a particular state. You can also access all the schemas on this repository's Wiki page here or through the API.
-
API View: This tab allows you to inspect all the avaliable API access points available for a state, allowing you to fetch data for individual tables, or specific columns inside those tables, through
GET
requests. You can, of course, construct more complex queries, as detailed in the API documentation.
Furthermore, each state-level page also contains a series of "Highlights" that talk about some interesting features of the data.
These are also autogenerated from a list of queries using the HighlightsElement
described below.
Other than the state-level pages, we also have dedicated Analysis and Anomalies pages which document comparitive numbers between states and data anomalies if any. We encourage you to contribute to these once the state-level data builds up for a large number of Indian states.
All the default elements in all the pages are constructed from two basic kinds of time series plots, one for individual display, and the other for comparative display.
BasicElement: This element is used to draw individual time series plots. By default, each state-level page invokes one instances of this element for all columns of all its tables, and plots them as and when they are selected for visualization by the user. The plots produced by these are currently standalone and independent of each other, and hence not suitable for comparison.
HighlightsElement This element can be used to produced targeted plots for very specific queries and comparisions acroos multiple data elements across the time axis. As input it takes in a query with the following elements:
{
"subject": "TITLE OF THE PLOT",
"description": "DESCRIPTION OF THE PLOT",
"legend": "LIST OF LEGENDS FOR EACH PLOT ELEMENT",
"query": "SQL QUERY"
}
You can find examples of the HighlightsElement being used across the state-level pages, and in the analysis and anomalies pages, under the header "Highlights". Internally, this generates a call to the API serving SQL queries to the COVID-19 India DB, and returns timeseries data where each tuple on the timeseries starts with the date and then the data per item requested as indexed by the list of lengeds above. See here for some example queries.
You can contribute to the frontend in several forms, either as part of the existing infrastructure or as completely new elements. Contributors will require familiarity with React and the Carbon Design System.
- Make a copy of the NewStatePage template inside the
content
directory. - Replace "NewStatePage" with the name of your state. See Delhi or West Bengal for examples.
- Add your state to the static nav Header
- Add custom styles for your page in app.scss:
@import './content/WestBengal/new-state.scss';
- Add your entry in the list of states to display in config.json as seen above. Note that the short_name corresponds to the entry of the state in the DB. See here for an example: "DL" for Delhi.
Once you add information in, the page for your state will be autogenerated with all the entries as described above.
Instead of entire state-level pages, you can also add individual elements to the existing pages, either by using the existing frontend artifacts or by making up completely new ones as you wish.
You can use the HighlightsElement
to add to the existing analysis and anomalies sections. This is done
automatically, if you augment your results to the corresponding query files being used by the automated generator
for the landing page.
- A new query to the state-level highlights e.g. for Delhi here.
- A new query to the anomalies page here.
- A new query to the analysis page here.
In any of these pages, you can add in your own elements. By default, each page contains a Basic section
and a Highlights section, as seen here for example in the state template.
If you want to add new analysis
elements for a state that cannot be built using the BasicElement
or the HighlightsElement
objects, you can
directly extend the state-level page with your new elements in the code, following right after the default elements.