Skip to content

SimonbJohnson/hxlbites.js

Repository files navigation

hxlbites.js

hxlbites.js is a library to automate the generation of relevant and context aware data structures for charts, maps, tables and text of humanitarian data with HXL hastags.

HXL data -> hxlbites.js -> Data charts, maps plus relevant text

HXL Bites Checker

A tool visual for checking what bites are generated by the library link

With example dataset of Ebola Treatment centres

If a chart/map/table is missing that you want then please create an issue for it

Usage

Data should be an array of arrays - first line = headers, second line = hxl hashtags, third line onwards = data

var hb = hxbites.data(data)

To get mapping bites

hxlBitesMap.js needs to be included

hb.getMapBites();

return array of bites with following structure:

{  
  bite: array [...data for chart...],  
  geom_attribute: string "...field name in geometry file to join data by...",  
  geom_url: array [...URLs to download matchin geometry file],  
  id: string "...chart bite ID...",  
  priority: number,  
  subtype: string "...bite subtype - choropleth...",  
  title: string "...title of bite...",  
  type: string "...bite type...",  
  uniqueID: string "...unique ID combining bite and data structure...",  
}

To get chart bites

hxlBitesChart.js needs to be included

hb.getChartBites();

return array of bites with following structure:

{  
  bite: array [...data for chart...],  
  id: string "...chart bite ID...",  
  priority: number,  
  subtype: string "...bite subtype - row, pie...",  
  title: string "...title of bite...",  
  type: string "...bite type...",  
  uniqueID: string "...unique ID combining bite and data structure",  
}  

To get table bites

hxlBitesTable.js needs to be included

hb.getTableBites();

To get crosstable bites

hxlBitesCrossTable.js needs to be included

hb.getCrossTableBites();

To get text bites

hxlBitesText.js needs to be included

hb.getTextBites();
{
  bite: string "...generate text string...",  
  id: string "...chart bite ID...",  
  priority: number,  
  subtype: string "...bite subtype - main, headline figure...",  
  title: undefined,  
  type: string "...bite type...",  
  uniqueID: string "...unique ID combining bite and data structure",  
}

To get a bite for a unique ID.

This enables storing of just the ID and return the bite at a later date.

hb.reverse(uniqueID)

Return single bite related to unique ID. Data does not have to be the same and makes best attempt to recreate bite with new numbers.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published