Bubble Network
Updated 5 years ago to v1.0.0 by Code for Africa
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/bubble-network-cfa
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: { bubbles: [ [ "BubblesColumn1Value1", "BubblesColumn2Value1", [ "BubblesColumn1Value2", "BubblesColumn2Value2", [ "BubblesColumn1Value3", "BubblesColumn2Value3", ... ] } }
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/bubble-network-cfa", version: "1", bindings: { bubbles: { from: 0, // index of a column in your data to: 1, // index of a column in your data total: 2, // index of a column in your data } }, data: { bubbles: [ [ "BubblesColumn1Value1", "BubblesColumn2Value1", [ "BubblesColumn1Value2", "BubblesColumn2Value2", [ "BubblesColumn1Value3", "BubblesColumn2Value3", ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "@cfafrica/bubble-network-cfa", version: "1", bindings: { bubbles: { from: 0, // index of a column in your data to: 1, // index of a column in your data total: 2, // index of a column in your data } }, data: { bubbles: [ [ "BubblesColumn1Value1", "BubblesColumn2Value1", [ "BubblesColumn1Value2", "BubblesColumn2Value2", [ "BubblesColumn1Value3", "BubblesColumn2Value3", ... ] } }
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:
{ bubbles: [ { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, ... ] }
... 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/bubble-network-cfa", version: "1", bindings: { bubbles: { from: "BubblesHeader1", to: "BubblesHeader2", total: "BubblesHeader3", } }, data: { bubbles: [ { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "@cfafrica/bubble-network-cfa", version: "1", bindings: { bubbles: { from: "BubblesHeader1", to: "BubblesHeader2", total: "BubblesHeader3", } }, data: { bubbles: [ { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, { "BubblesHeader1": ..., "BubblesHeader2": ..., ... }, ... ] } }
(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/bubble-network-cfa", version: "1", data: { bubbles: [ { from: ..., to: ..., total: ... }, ... ] }, ... }
And the full list of all possible properties is as follows:
{ template: "@cfafrica/bubble-network-cfa", version: "1", data: { bubbles: [ { from: ..., to: ..., total: ... }, ... ] }, ... }
Meanings of the template data keys:
- bubbles.from: from
- bubbles.to: to
- bubbles.total: total
Template settings
Options for opts.state
.
Colors
key_colors.color_1 color
Primary. Used for "sending" nodes
key_colors_selected.color_1 color
Hover.
key_colors.color_2 color
Secondary. Used for "receiving" nodes
key_colors_selected.color_2 color
Hover. Second Key Color on hover (legend and bubbles) (hex)
line_color color
Line color.
line_color_selected color
Hover.
Text & translation
key_labels.label_1 string
Sending. label for the first key
key_labels.label_2 string
Receiving. label for the second key
instruction string
Instruction. Choose the main call to action
main_bubble_text.one string
Entity name (singular). What are these bubbles representing?
main_bubble_text.many string
Entity name (plural). What are these bubbles representing?
text_after_total.tat_1 string
Detail description (towards). Description label of the detail node (towards)
text_after_total.tat_2 string
Detail description (from). Description label of the detail node (from).
Layout
Layout
layout.body_font font
Font.
layout.max_width number
Maximum width. Leave blank to stretch to container width Min: 50
layout.background_color_enabled boolean
Color. Allowed values:
layout.background_image_enabled boolean
Image. Allowed values:
layout.background_color color
Color.
layout.background_image_src url
Image URL.
layout.background_image_size string
Size. Allowed values:
layout.background_image_position string
Position. Allowed values:
layout.layout_order string
Layout order. Allowed values:
layout.space_between_sections string
Space between sections. Allowed values:
layout.space_between_sections_custom number
Custom. Max: 100
layout.margin_top number
Top.
layout.margin_right number
Right.
layout.margin_bottom number
Bottom.
layout.margin_left number
Left.
layout.border.enabled boolean
Show borders around visualisation.
layout.border.top.width number
Top.
layout.border.top.style string
Style. Allowed values:
layout.border.top.color color
Color.
layout.border.right.width number
Right.
layout.border.right.style string
Style. Allowed values:
layout.border.right.color color
Color.
layout.border.bottom.width number
Bottom.
layout.border.bottom.style string
Style. Allowed values:
layout.border.bottom.color color
Color.
layout.border.left.width number
Left.
layout.border.left.style string
Style. Allowed values:
layout.border.left.color color
Color.
Header
layout.header_align string
Alignment. Allowed values:
layout.title string
layout.title_styling boolean
Styling.
layout.title_size string
Size. Allowed values:
layout.title_size_custom number
Custom. Specify a custom responsive font size. Best results will be with values between 1.2 and 3
layout.title_weight string
Weight. Allowed values:
layout.title_color color
Color.
layout.title_line_height number
Line height. Max: 3
layout.title_space_above string
Space above. Allowed values:
layout.title_space_above_custom number
Custom. Max: 100
layout.subtitle string
layout.subtitle_styling boolean
Styling.
layout.subtitle_size string
Size. Allowed values:
layout.subtitle_size_custom number
Custom. Specify a custom responsive font size. Best results will be with values between 1.2 and 3
layout.subtitle_weight string
Weight. Allowed values:
layout.subtitle_color color
Color.
layout.subtitle_line_height number
Line height. Max: 3
layout.subtitle_space_above string
Space above. Allowed values:
layout.subtitle_space_above_custom number
Custom. Max: 100
layout.text string
layout.text_styling boolean
Styling.
layout.text_size string
Size. Allowed values:
layout.text_size_custom number
Custom. Specify a custom responsive font size. Best results will be with values between 1.2 and 3
layout.text_weight string
Weight. Allowed values:
layout.text_color color
Color.
layout.text_line_height number
Line height. Max: 3
layout.text_space_above string
Space above. Allowed values:
layout.text_space_above_custom number
Custom. Max: 100
layout.header_border string
Allowed values:
- top (Top)
- bottom (Bottom)
- none (None)
layout.header_border_width number
Width.
layout.header_border_color color
Color.
layout.header_border_style string
Style. Allowed values:
layout.header_logo_enabled boolean
Allowed values:
- true (Enabled)
- false (Disabled)
layout.header_logo_src url
URL.
layout.header_logo_height number
Height.
layout.header_logo_align string
Align. Align logo inside header or outer visualisation container Allowed values:
layout.header_logo_position_inside string
Position. Allowed values:
layout.header_logo_position_outside string
Position. Allowed values:
layout.header_logo_margin_top number
Top.
layout.header_logo_margin_right number
Right.
layout.header_logo_margin_bottom number
Bottom.
layout.header_logo_margin_left number
Left.
Footer
layout.source_name string
Source name.
layout.source_url string
Source url.
layout.multiple_sources boolean
Multiple sources.
layout.source_name_2 string
Source name.
layout.source_url_2 string
Source url.
layout.source_name_3 string
Source name.
layout.source_url_3 string
Source url.
layout.source_label string
Source label.
layout.footer_note string
Note.
layout.footer_text_size number
Size.
layout.footer_text_color color
Color.
layout.footer_align string
Alignment. Allowed values:
layout.footer_logo_enabled boolean
Allowed values:
- true (Enabled)
- false (Disabled)
layout.footer_logo_src url
Image.
layout.footer_logo_link_url string
Link.
layout.footer_logo_height number
Height.
layout.footer_logo_margin number
Margin.
layout.footer_logo_order string
Position. Allowed values:
layout.footer_align_vertical string
V. align. Allowed values:
layout.footer_border string
Allowed values:
- top (Top)
- bottom (Bottom)
- none (None)
layout.footer_border_width number
Width.
layout.footer_border_color color
Color.
layout.footer_border_style string
Style. Allowed values: