Nigeria States Basemap
Updated 4 years ago to v1.0.0 by Code for Africa
How to use this template
Host the contents of this zipfile at a URL of your choice. Then on the page where you would like to embed the visualisation, use one of the following embed codes, replacing {{URL}} with the real URL corresponding to the directory these unpacked files are in (see the notes below).
Preferred method: flourish.embed.js
Use the included flourish.embed.js file to embed (recommended; best for responsive). Target a container div where you want the visualisation to appear using the data-src attribute, as follows:
<div class="flourish-embed" data-src="{{URL}}/index.html"><script src="{{URL}}/flourish.embed.js"></script></div>
You only need to include the script once in your HTML page, even if you have multiple visualisations displayed (though there is no harm in including it multiple times; it will only run once).
Alternative method: iframe embed
You can also embed via a simple iframe (this is best if your CMS blocks scripts):
<iframe scrolling="no" src="{{URL}}"></iframe><div><a href="https://flourish.studio/?utm_source=embed" target='_top'><img alt="Made with Flourish" src="https://public.flourish.studio/resources/made_with_flourish.svg"></a></div>
Be sure to specify scrolling="no" to avoid problems on iOS.
Notes
- Your {{URL}} must be a full path, not a local file URL - in other words it should begin http:// or https://, not file://.
- If necessary, also update the height and width.
- You may not remove the Flourish credit unless you are an enterprise customer or have permission from Flourish HQ.
API information
This section documents API usage specific to this template, so for an introduction we suggest you refer to the generic API documentation instead.
template: @cfafrica/nigeria-states
version: 1
Template data
There are three different formats in which you can supply data to this template. The most convenient for you to use likely depends on the source of your data, as described below.
1. Array of arrays, and a bindings object
You can supply arrays of arrays to opts.data
, which might look
like:
{ data: { nigeria_states: [ [ "Nigeria_statesColumn1Value1", "Nigeria_statesColumn2Value1", [ "Nigeria_statesColumn1Value2", "Nigeria_statesColumn2Value2", [ "Nigeria_statesColumn1Value3", "Nigeria_statesColumn2Value3", ... ] } }
where each array of arrays represents the rows in a data sheet.
To tell the API how the values from each column should be
associated with the keys that the template is expecting, you must also supply
an object attached to opts.bindings
. (The meanings of the
keys in the bindings object are documented
below.) The minimal bindings you can
supply for this template are as shown in this example:
{ template: "@cfafrica/nigeria-states", version: "1", bindings: { nigeria_states: { geometry: 0, // index of a column in your data } }, data: { nigeria_states: [ [ "Nigeria_statesColumn1Value1", "Nigeria_statesColumn2Value1", [ "Nigeria_statesColumn1Value2", "Nigeria_statesColumn2Value2", [ "Nigeria_statesColumn1Value3", "Nigeria_statesColumn2Value3", ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "@cfafrica/nigeria-states", version: "1", bindings: { nigeria_states: { geometry: 0, // index of a column in your data male: 1, // index of a column in your data female: 2, // index of a column in your data state: 3, // index of a column in your data value: 4, // index of a column in your data } }, data: { nigeria_states: [ [ "Nigeria_statesColumn1Value1", "Nigeria_statesColumn2Value1", [ "Nigeria_statesColumn1Value2", "Nigeria_statesColumn2Value2", [ "Nigeria_statesColumn1Value3", "Nigeria_statesColumn2Value3", ... ] } }
2. Array of objects with arbitrary keys, and a bindings object
This format is most likely useful when you have data from an external source,
such as CSV data loaded from d3-dsv.
You should supply this attached to the opts.data
, which might look
like:
{ nigeria_states: [ { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, ... ] }
... but with the keys being the column headers from your
source data instead. You must also supply an object attached to
opts.bindings
. The minimal bindings you can
supply for this template are as shown in this example:
{ template: "@cfafrica/nigeria-states", version: "1", bindings: { nigeria_states: { geometry: "Nigeria_statesHeader1", } }, data: { nigeria_states: [ { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "@cfafrica/nigeria-states", version: "1", bindings: { nigeria_states: { geometry: "Nigeria_statesHeader1", male: "Nigeria_statesHeader2", female: "Nigeria_statesHeader3", state: "Nigeria_statesHeader4", value: "Nigeria_statesHeader5", } }, data: { nigeria_states: [ { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, { "Nigeria_statesHeader1": ..., "Nigeria_statesHeader2": ..., ... }, ... ] } }
(As before, the keys containing "Header" would be replaced by column names from your data source.)
3. Array of objects with template-defined keys
There is an alternative format you can use, which is likely to be easier to
use if your data is not from a spreadsheet source. With this alternative format
you supply your data to the template as
an array of objects, attached to opts.data
, where the keys must
be those used by the template, as documented below. In this case
there is no need to supply a bindings object, since the key names are already
those expected by the template. The required properties in the data
object are as follows (scroll down for a
description of what each property is):
{ template: "@cfafrica/nigeria-states", version: "1", data: { nigeria_states: [ { geometry: ... }, ... ] }, ... }
And the full list of all possible properties is as follows:
{ template: "@cfafrica/nigeria-states", version: "1", data: { nigeria_states: [ { geometry: ..., male: ..., female: ..., state: ..., value: ... }, ... ] }, ... }
Meanings of the template data keys:
- nigeria_states.geometry: geometry
- nigeria_states.male: male
- nigeria_states.female: female
- nigeria_states.state: state
- nigeria_states.value: value
Template settings
Options for opts.state
.
color color
Color. The color of the maps
opacity number
Opacity. The opacity of the maps Max: 1
Section title
example_state_property number
Example number setting. A setting for changing a number