This repository has been archived by the owner on Oct 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Data Format
larson reever edited this page Jan 12, 2017
·
16 revisions
A small description of app/data/bern
. Below the examples contain JavaScript comments for explanation, your JSON files should not contain those comments (valid JS, invalid JSON).
"meta": {
"hierarchy": ["Direktion", "Dienststelle", "Produktegruppe", "Produkt"], // used for labels in table, determined by node depth in tree
"page_title": "Budget Bern...", // page title
"description": "", // meta description
"h1": "Stadt Bern", // sidebar h1
"h2": "Produktegruppen-Budget 2013", // sidebar h2
"data_link": "http://www.example.com/budget.pdf", // data source url
"data_title": "Offizielles Budget-PDF", // data source link text
"uservoice": "VsqIUopbNuYMz7cW5ucG1A", // uservoice id (optional)
"html_class": "blue", // html css class for theming (optional)
"gross_cost_label": "Bruttokosten", // label for costs (right side)
"revenue_label": "Erlöse", // label for revenue (right side)
"data_url": "/data/bern/data.json", // raw data source (used when cache_url is not specified or to generate cache)
"cache_url": "/data/bern/cache.json" // cached data (optional)
}
- absolute url
- JSON will be loaded from it directly by the browser
- needs CORS support (windows IE9 does not have it with D3.js)
- relative path
- /data/:id/(cache|data).json is served through a proxy backed by carrierwave (S3, filesystem & more)
- alternatively us another relative path and put your file in
public
[/* array of node data objects */]
{
/* this is node data */
"id": "1000",
"name": "Gemeinde und Beh\u00f6rden",
"acronym": "GuB", // acronym (optional, nice to have, currently not used)
"gross_cost": {
"budgets": { // budgets || accounts
"2013": 865673.21, // year
"2012": 909687.25 // year - 1
}
},
"revenue": {
"budgets": { // budgets || accounts
"2013": 0, // year
"2012": 0 // year - 1
}
}
"children": [/* array of node data objects */]
}
revenue
and gross_cost
is hard coded, budgets and the years can be changed in scripts/nodes.js:41
var valuesAccessorForNodeType = {
'revenue': valuesAccessor('revenue', 'budgets', '2013', '2012'),
'gross_cost': valuesAccessor('gross_cost', 'budgets', '2013', '2012')
};
For production you can create a cache with pre-processed values and without arbitrary data. Call OpenBudget.nodes.createCache()
via your browser console and save the output to your data directory as cache.json
. Cache is used whenever cache_url
is specified in meta.json
.
- clean up
- better docu