Difference between revisions of "Template Displays"
From dataZoa Wiki
Line 7: | Line 7: | ||
<br> | <br> | ||
− | <div class="imgGlyph24 imgConcept"></div> | + | Templates work with any display type, but in this discussion we will just refer to a dataZoa Table Display. |
+ | <div class="imgGlyph24 imgConcept"></div> Templating of displays combines three concepts: | ||
* Make several dataZoa Grouplists that contain conceptually and structurally similar data that vary in one particular aspect. For example, you might make 10 Grouplists of the same 7 employment statistics for different MSAs. | * Make several dataZoa Grouplists that contain conceptually and structurally similar data that vary in one particular aspect. For example, you might make 10 Grouplists of the same 7 employment statistics for different MSAs. | ||
* Build a Table in the usual way using one the Grouplists. | * Build a Table in the usual way using one the Grouplists. | ||
Line 14: | Line 15: | ||
* Add the Javascript <i>UpdateFrame</i> function below to your webpage. | * Add the Javascript <i>UpdateFrame</i> function below to your webpage. | ||
* Add an "onchange" function to the <nowiki><select></nowiki> that will call UpdateFrame as described in its comments <br> | * Add an "onchange" function to the <nowiki><select></nowiki> that will call UpdateFrame as described in its comments <br> | ||
− | |||
<br> | <br> | ||
To begin, make a table specifically for your app which contains all the data needed and then use AJAX to fetch it. | To begin, make a table specifically for your app which contains all the data needed and then use AJAX to fetch it. |
Revision as of 08:17, 16 January 2020
Rather than making a set of Displays that are identical in except for the data they contain, you can implement a template mechanism to pop different data sets into the display dynamically (typically from a drop down list of data choices). For example, you might want to show the same 7 employment categories for 10 different MSAs, and rather than a different display for each MSA, a single template will let you select an MSA from a drop down list and see it swapped in.
- HTML
- Javascript
- dataZoa Grouplists
Templates work with any display type, but in this discussion we will just refer to a dataZoa Table Display.
- Make several dataZoa Grouplists that contain conceptually and structurally similar data that vary in one particular aspect. For example, you might make 10 Grouplists of the same 7 employment statistics for different MSAs.
- Build a Table in the usual way using one the Grouplists.
- Embed the Table on your webpage in the usual way.
- Implement an HTML <select> (aka "drop down") list with options for each of the geographies that have the corresponding Grouplist as their values.
- Add the Javascript UpdateFrame function below to your webpage.
- Add an "onchange" function to the <select> that will call UpdateFrame as described in its comments
To begin, make a table specifically for your app which contains all the data needed and then use AJAX to fetch it.
- You can mark the row (series) labels to easily identify their data
- Label knockouts are available
- Just one fetch for multiple series
- The displays are server-cached for speed
- A GroupList parameter (glname=... on a table gives access to multiple datasets
- A LatestValues display gives you current values, prior values and/or (%) changes
- Use jQuery (or similar library) to parse the structured classes in the display and get the data values
- There is a limit of 50 points of historical data per series for tables.