Skip to content

Commit 06d3bed

Browse files
authored
Merge pull request #300 from brookwander/doc-for-mpcontrib-app
Initial documentation for MPApp
2 parents d75b4dc + ac1407f commit 06d3bed

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

docs_rst/mp_app.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
11
=======================
22
A Materials Project App
33
=======================
4+
5+
MP App Intro
6+
~~~~~~~~~~~~
7+
8+
If you have already made a custom app using ``MPComponent``, it should be fairly straightforward to convert it to a website-ready app. To aid in this process, this documentation walks through the components of the catalysis app as an example (crystal_toolkit/apps/examples/mpcontribs). If you have not already made an app using `MPComponent`, you should also take a look at the documentation provided for it. This documentation also points out some useful helper functions and the location where all helper functions may be found. At a high-level, the most important difference is rather than establishing a subclass of `MPComponent`, you should establish a subclass of `MPApp`. `MPApp` is a subclass of `MPComponent`
9+
10+
Details of the Catalysis App
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
The catalysis app has two primary tabs:
13+
1. The search tab
14+
2. The binary visualization tab
15+
For ease of understanding and modularity, each tab has a function defined to get the layout: ``get_search_layout`` and ``get_visualization_layout``. There is a third function called ``get_layout``, which is actually called to establish the layout for the app and calls the two other functions.
16+
17+
The app queries the OC20 dataset from MPContribs. An example of this is within ``get_plot_data`` for the binary visualization.
18+
19+
To support interactivity with the binary visualization, the app uses two different callbacks, which are contained within the ``generate_callbacks`` function. The first, ``update_figure``, handles the querying of data presentation of it in the plot. The second, ``display_click_data`` updates a supplementary table of information when the user clicks on a grid point. ``generate_callbacks`` is a good example of how to establish callbacks, how to use the decorator for callbacks (``@app.callback()``), and how to establish data caching with the ``@cache.memoize()`` decorator when it is advantageous to do so.
20+
21+
22+
Useful helper functions to consider
23+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
All helper functions may be found in ``crystaltoolkit.helpers.utils``. Some particularly useful ones are highlighted below, but take a look to see if there is anything you can leverage!
25+
26+
Helpful tooltips
27+
^^^^^^^^^^^^^^^^
28+
There is a convenient helper function to add tooltips to text called ``get_box_title``. Help strings are stored in a yaml file which is shared for all apps on the website called ``help.yaml``. To add a tooltip, simply add your tip to the yaml file following the format:
29+
::
30+
use_point:
31+
title:
32+
help: “string that helps the user”
33+
label: “String of text to appear, which when hovered over will show the help str”
34+
link: “optional link - otherwise null”
35+
36+
37+
Then call the helper function where desired. This is done with this line in the catalysis app:
38+
::
39+
additional_data = get_box_title(use_point="CatalysisApp", title="catapp-add-data")
40+
41+
Well formatted tables
42+
^^^^^^^^^^^^^^^^^^^^^
43+
There is a convenient helper function, ``get_data_table`` which takes as input a dataframe and returns a website-ready formatted table
44+
45+
Well formatted matrices
46+
^^^^^^^^^^^^^^^^^^^^^^^
47+
There is a convenient helper function, ``get_matrix_string``, to convert arrays into a string for use in ``mpc.Markdown()`` so they are website-ready.

0 commit comments

Comments
 (0)