Template Displays

From dataZoa Wiki
Revision as of 08:17, 16 January 2020 by SNC (Talk | contribs)

Jump to: navigation, search
 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.


 Skills required for this technique:
  • HTML
  • Javascript
  • dataZoa Grouplists


Templates work with any display type, but in this discussion we will just refer to a dataZoa Table Display.

 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.
  • 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.

 Some Advantges:
  • 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


 Remember:
  • 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.