Snippets

From CHG-Wiki
Revision as of 17:39, 30 March 2016 by Libby (talk | contribs) (Created Snippets documentation page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Example

Below is an example of a Snippet that was generated using the EWX Map Snippet Configurator.

<script src="http://ewx.chg.ucsb.edu/ewx-snippets/ewxmap/ewxmap.js"></script>
<div id="ewx-map-00pz63b0tc"></div>
<script>
new EwxMap ({  
ewxUrl: 'http://ewx.chg.ucsb.edu:8080/EWX',  
id: 'ewx-map-00pz63b0tc',  
dataset: 'chirps',  
region: 'africa',  
periodicity: '1-dekad',  
period: { year: 2016, month: 2, dekad: 3 },  
showDekadControl: true, 
showYearControl: true,  
units: 'mm',  
statistic: 'data',  
width: 427,  
height: 455,  
zoom: 3,  
center: [1.5, 17],
});
</script>

Snippets Parameters

ewxUrl

Currently, the only supported parameter is 'http://ewx.chg.ucsb.edu:8080/EWX'. However, other options are forthcoming.

id

This parameter can either be arbitrarily set by the user or, using the EWX Map Snippet Configurator, an id of 'ewx-map-[random]' will be generated for each configuration, where [random] is a randomly assigned collection of letters and numbers.

dataset

The dataset parameter defines which dataset the Snippet map will draw from. Certain other parameters may be available or unavailable depending on the data within the dataset. EWX Map Snippet Configurator adjusts to reflect this during configuration.

Data are automatically updated based on what is available through EWX. Currently, the available datasets include:

  • b1irtmax
  • chirp
  • chirps
  • chirpsclim
  • chirpsdecorr
  • chirpsprelim
  • cpcirtmax
  • eancmet
  • eancml1soilm
  • eancmrunoff
  • eancmrunoff001
  • eancmta
  • eanrget
  • eanrgl1soilm
  • eanrgrunoff
  • eanrgta
  • eavcmet
  • eavcml1soilm
  • eavcmrunoff
  • eavcmta
  • gpccdi
  • lst
  • rchecksstns
  • rfe2
  • trmm
  • wrsilongmaize
  • wrsishortmaize

region

"regionName": "Western Africa"
"regionId": "westernafrica"
"bounds": [5.0, -17.25], [18.0, 25.25]

"regionName": "Eastern Africa"
"regionId": "easternafrica"
"bounds": [-12.0, 21.75], [23.25, 51.25]

"regionName": "Western Hemisphere"
"regionId": "whem"
"bounds": [-50.0, -130.0], [50.0, -30.0]

"regionName": "Southern Africa"
"regionId": "southernafrica"
"bounds": [-34.75, 5.75], [7.0, 51.25]

"regionName": "Global"
"regionId": "global"
"bounds": [-90.0, -180.0], [90.0, 180.0]

"regionName": "Asia"
"regionId": "asia"
"bounds": [5.0, 40.0], [57.0, 147.0]

"regionName": "Africa"
"regionId": "africa"
"bounds": [-40.0, -20.0], [40.0, 55.0]

"regionName": "United States"
"regionId": "usa"
"bounds": [23.0, -130.0], [50.0, -63.0]

periodicity

More are forthcoming, but for now the available parameters are below:

  • '1-dekad'
  • '1-month'
  • '2-month'
  • '3-month'

period

  • { year: yyyy, month: m, dekad: 3 } = Full year, numerical month (1-12), with a default dekad of 3 (based on monthly, not yearly dekad, if dekad info is available)
  • latest = Latest check box is checked (this parameter will display the latest data for the indicated dataset)

showDekadControl

A simple boolean parameter - true if the Dekad box is checked, false if not

showYearControl

A simple boolean parameter - true if Year box is checked, false if not

units

  • 'mm'
  • 'c-deg'
  • 'none'

statistic

  • anomaly
  • data
  • z-score

width

Width defaults to 427 and is based on pixels. Width can be adjusted either by resizing the window in the configurator or by manually entering the desired value.

height

Height defaults to 455 and is based on pixels. Width can be adjusted either by resizing the window in the configurator or by manually entering the desired value.

zoom

Zoom defaults to a value of 3. Zoom can be adjusted by using the +/- buttons on your keyboard or your mouse wheel while your mouse cursor is over the snippet map, or by manually setting the value in the javascript snippet.

center

The center value defaults to [1.5, 17] and can be adjusted either by clicking and dragging within the window in the configurator or by manually entering the desired value.