Connections globe v1
Updated 7 years ago by Template retirement home
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: _149
version: _2
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: { values: [ [ "ValuesColumn1Value1", "ValuesColumn2Value1", [ "ValuesColumn1Value2", "ValuesColumn2Value2", [ "ValuesColumn1Value3", "ValuesColumn2Value3", ... ], locations: [ [ "LocationsColumn1Value1", "LocationsColumn2Value1", [ "LocationsColumn1Value2", "LocationsColumn2Value2", [ "LocationsColumn1Value3", "LocationsColumn2Value3", ... ] } }
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: "_149", version: "_2", bindings: { values: { src: 0, // index of a column in your data dst: 1, // index of a column in your data }, locations: { code: 0, // index of a column in your data name: 1, // index of a column in your data latitude: 2, // index of a column in your data longitude: 3, // index of a column in your data } }, data: { values: [ [ "ValuesColumn1Value1", "ValuesColumn2Value1", [ "ValuesColumn1Value2", "ValuesColumn2Value2", [ "ValuesColumn1Value3", "ValuesColumn2Value3", ... ], locations: [ [ "LocationsColumn1Value1", "LocationsColumn2Value1", [ "LocationsColumn1Value2", "LocationsColumn2Value2", [ "LocationsColumn1Value3", "LocationsColumn2Value3", ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "_149", version: "_2", bindings: { values: { src: 0, // index of a column in your data dst: 1, // index of a column in your data scores: [2, 3, ...], // index(es) of column(s) in your data }, locations: { code: 0, // index of a column in your data name: 1, // index of a column in your data latitude: 2, // index of a column in your data longitude: 3, // index of a column in your data } }, data: { values: [ [ "ValuesColumn1Value1", "ValuesColumn2Value1", [ "ValuesColumn1Value2", "ValuesColumn2Value2", [ "ValuesColumn1Value3", "ValuesColumn2Value3", ... ], locations: [ [ "LocationsColumn1Value1", "LocationsColumn2Value1", [ "LocationsColumn1Value2", "LocationsColumn2Value2", [ "LocationsColumn1Value3", "LocationsColumn2Value3", ... ] } }
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:
{ values: [ { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, ... ], locations: [ { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, ... ] }
... 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: "_149", version: "_2", bindings: { values: { src: "ValuesHeader1", dst: "ValuesHeader2", }, locations: { code: "LocationsHeader1", name: "LocationsHeader2", latitude: "LocationsHeader3", longitude: "LocationsHeader4", } }, data: { values: [ { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, ... ], locations: [ { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "_149", version: "_2", bindings: { values: { src: "ValuesHeader1", dst: "ValuesHeader2", scores: ["ValuesHeader3", "ValuesHeader4", ...], }, locations: { code: "LocationsHeader1", name: "LocationsHeader2", latitude: "LocationsHeader3", longitude: "LocationsHeader4", } }, data: { values: [ { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, { "ValuesHeader1": ..., "ValuesHeader2": ..., ... }, ... ], locations: [ { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, { "LocationsHeader1": ..., "LocationsHeader2": ..., ... }, ... ] } }
(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: "_149", version: "_2", data: { values: [ { src: ..., dst: ..., scores: [...] }, ... ], locations: [ { code: ..., name: ..., latitude: ..., longitude: ... }, ... ] }, ... }
And the full list of all possible properties is as follows:
{ template: "_149", version: "_2", data: { values: [ { src: ..., dst: ..., scores: [...] }, ... ], locations: [ { code: ..., name: ..., latitude: ..., longitude: ... }, ... ] }, ... }
Meanings of the template data keys:
- values.src: The column containing the name of the source country
- values.dst: The column containing the name of the destination country
- values.scores: One or more columns; will create a slider or menu if multiple columns are specified
- locations.code: The column containing the location code
- locations.name: The column containing the location name
- locations.latitude: The column containing the latitude for the arrow to point
- locations.longitude: The column containing the longitude for the arrow to point
Template settings
Options for opts.state
.
Title & subtitle
title string
Title. Optional title
subtitle string
Subtitle. Optional subtitle
Globe & arrows
globe_skin string
The image file for the global surface. Choose form [[world_blue.jpg]], [[world_brown.jpg]] or [[world_blue_white.jpg]], or provide a URL of jpg (4096×2048 pixels)
num_arrows number
Number of arrows. Sets a limit on the number of arrows to draw to improve animation performance
reverse_arrows boolean
Reverse arrows. Animate arrows from rather than to the selected country
arrow_color color
Arrow colour. The colour of the arrows
arrow_highlight_color color
Selected arrow colour. The colour of the selected arrow
arrow_scale number
Arrow scale. Multiplier to increase or decrease the width of the arrows
County menu
text_above_search string
Text above country menu. Optional text above country menu
text_below_search string
Text below country menu. Optional text below country menu
destinations string
Destination countries. The codes of the target countries to appear in the dropdown, separated by commas. Leave blank to include everything in the destination column. Use double hashes to add menu subheadings (e.g. ##Americas##, US, ##Europe##, GB, FR)
search_head string
Text before location. Optional text after the location in the country menu
search_tail string
Text after location. Optional text after the location in the country menu
Leaderboard
num_results number
Maximum number of results. How many countries to show in the results list
show_scores boolean
Show scores. Show the data value for each country in the results
decimal_places number
Decimal places. Number of decimal places to show in the leaderboard and mouseover popups
score_prefix string
Symbol or text before score.
score_suffix string
Symbol or text after score.
leaderboard_highlight_color color
Selected text colour. Text colour for the selected country
Page design
background_color color
Background colour. Background colour of the page
grad boolean
Show gradient shade.
highlight_color color
Highlight colour. Colour for the numbers and slider handle
logo_url string
Logo URL (https). The URL of the logo to add to the graphic; should be on a secure (https) server
css text
Custom CSS styles. Custom CSS definitions to override the defaults
Controls
hide_nav boolean
Hide all text and controls.
button_nav boolean
Button nav. If checked, will switch the time slider for a button nav for switching between values in different columns
Initial view
country string
Default destination country. The country code of the destination country shown on initial load. Leave blank to choose from the first row of data.
distance number
Initial zoom. The distance from the earth, from 350 (closest) to 1000 (farthest away) Min: 350 Max: 1000