Sports race
Updated a month ago to v2.6.4 by Flourish team
How to use this template
What's it for?
Use this template to visualize competitions where participants race along a fixed track or course, for example a 100m sprint, or a slalom ski race.
How to get started
Add one row of data for each participant in the race – like a sprinter or a skier. Use the first column to populate with the participants’ names. The other columns are times taken at set points in the race. It could just be a single finishing time, for example:
name | Finishing time |
---|---|
Usain Bolt | 9.58 |
Tyson Gay | 9.69 |
It could refer to laps of a course:
name | Lap 1 | Lap 2 | Lap 3 | Lap 4 |
---|---|---|---|---|
Paul Biedermann | 0:24.23 | 0:50.12 | 1:16.30 | 1:42.00 |
Michael Phelps | 0:24.31 | 0:50.29 | 1:16.84 | 1:42.96 |
Or to times taken at particular checkpoints along the route:
name | Checkpoint 1 | Checkpoint 2 | Finish |
---|---|---|---|
Tadej Pogačar | 10:38.950 | 20:04.050 | 32:00.830 |
Stefan Küng | 10:49.330 | 20:21.090 | 32:19.100 |
Credits
Created by the Flourish team. Want to see additional features? Let us know at support@flourish.studio.
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: @flourish/sports-race
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: { data: [ [ "DataColumn1Value1", "DataColumn2Value1", [ "DataColumn1Value2", "DataColumn2Value2", [ "DataColumn1Value3", "DataColumn2Value3", ... ] } }
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: "@flourish/sports-race", version: "2", bindings: { data: { name: 0, // index of a column in your data } }, data: { data: [ [ "DataColumn1Value1", "DataColumn2Value1", [ "DataColumn1Value2", "DataColumn2Value2", [ "DataColumn1Value3", "DataColumn2Value3", ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "@flourish/sports-race", version: "2", bindings: { data: { name: 0, // index of a column in your data times: [1, 2, ...], // index(es) of column(s) in your data start_image: 3, // index of a column in your data race_image: 4, // index of a column in your data finish_image: 5, // index of a column in your data color_category: 6, // index of a column in your data } }, data: { data: [ [ "DataColumn1Value1", "DataColumn2Value1", [ "DataColumn1Value2", "DataColumn2Value2", [ "DataColumn1Value3", "DataColumn2Value3", ... ] } }
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:
{ data: [ { "DataHeader1": ..., "DataHeader2": ..., ... }, { "DataHeader1": ..., "DataHeader2": ..., ... }, { "DataHeader1": ..., "DataHeader2": ..., ... }, ... ] }
... 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: "@flourish/sports-race", version: "2", bindings: { data: { name: "DataHeader1", } }, data: { data: [ { "DataHeader1": ..., "DataHeader2": ..., ... }, { "DataHeader1": ..., "DataHeader2": ..., ... }, { "DataHeader1": ..., "DataHeader2": ..., ... }, ... ] } }
All possible bindings that you can supply are shown in this example:
{ template: "@flourish/sports-race", version: "2", bindings: { data: { name: "DataHeader1", times: ["DataHeader2", "DataHeader3", ...], start_image: "DataHeader4", race_image: "DataHeader5", finish_image: "DataHeader6", color_category: "DataHeader7", } }, data: { data: [ { "DataHeader1": ..., "DataHeader2": ..., ... }, { "DataHeader1": ..., "DataHeader2": ..., ... }, { "DataHeader1": ..., "DataHeader2": ..., ... }, ... ] } }
(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: "@flourish/sports-race", version: "2", data: { data: [ { name: ..., times: [...] }, ... ] }, ... }
And the full list of all possible properties is as follows:
{ template: "@flourish/sports-race", version: "2", data: { data: [ { name: ..., times: [...], start_image: ..., race_image: ..., finish_image: ..., color_category: ... }, ... ] }, ... }
Meanings of the template data keys:
- data.name: Name of competitor
- data.times: One or more columns of numbers, representing splits or laps, or a whole race
- data.start_image: The image to use at the start of the race. Add an image URL or right-click on a cell to upload an image.
- data.race_image: The image to use while a participant is racing. Add an image URL or right-click on a cell to upload an image.
- data.finish_image: The image to use when the participant has finished the race. Add an image URL or right-click on a cell to upload an image.
- data.color_category: Add a category to color participants by. If empty, the <b>name</b> column will be used for colors.
Template settings
Options for opts.state
.
Track & participants
preset_svg string
Allowed values:
- athletics (Athletics)
- swimming (Swimming)
- cycling (Cycling)
- custom (Custom)
custom_svg text
Custom SVG. Use a custom track using your own SVG
track_path_id string
Path ID. The ID of the element in the SVG which defines the center of the track
track_lane_width number
Lane width. The distance between each participant
track_back_and_forth boolean
Track type. Whether the track goes back and forth, like a swimming pool, or back to the start, like a race track Allowed values:
participant_icon_mode string
Icon type. Allowed values:
participant_size number
Size.
participant_stroke_width number
Line width.
participant_stroke_opacity number
Stroke opacity. Max: 1
participant_fill_opacity number
Fill opacity. Max: 1
preset_participant_image string
Default images. The images used if no image is included for the participant in the datasheet Allowed values:
custom_participant_start_image url
Custom start image. The image shown at the start of the race
custom_participant_race_image url
Custom racing image. The image shown while the participant is racing
custom_participant_finish_image url
Custom finish image. The image shown when the participant has finished the race
image_initial_rotation string
Rotate images. Allowed values:
image_initial_flip_x boolean
Flip horizontally.
image_initial_flip_y boolean
Flip vertically.
image_transform_mode string
Direction change. Change the direction of the image based on which way the participant is traveling. Allowed values:
participant_icon_recolor boolean
Recolor icons. Apply colors to differentiate the participants. Works best with greyscale images.
participant_color.categorical_palette colors
Palette.
participant_color.categorical_extend boolean
Extend. Automatically generate additional colours when needed to avoid the palette colours being used more than once
participant_color.categorical_custom_palette text
Custom overrides. Enter the label name for which you wish to set the color, followed by a colon and the desired color value.
Colors can be set using Hex, RGB, color names or RGBA, if you want to set the opacity. Multiple colors can be set using multiple lines. For example:
Party 1: red
Party 2: #4455AA
Party 3: rgb(30,168,26)
participant_color.numeric_type string
Scale type. Allowed values:
participant_color.binning boolean
In linear mode, the color scale will run as a smooth gradient between 2 colors. In binned mode, the gradient will be divided in smaller blocks. Allowed values:
participant_color.bin_mode string
Binning mode. Allowed values:
participant_color.bin_count number
Number of bins.
participant_color.bin_thresholds string
Custom thresholds. Enter your desired thresholds, separating them with a ";". For instance, "5;10;15".
Bins form as follows:
For "5;10;15", you'll get four bins based on your data's range.
participant_color.sequential_palette string
Palette. Allowed values:
participant_color.sequential_reverse boolean
Reverse.
participant_color.sequential_custom_min color
Minimum color.
participant_color.sequential_custom_max color
Maximum color.
participant_color.sequential_color_space string
Color space. Allowed values:
participant_color.sequential_custom_domain boolean
Domain. Allowed values:
participant_color.sequential_domain_min number
Min.
participant_color.sequential_domain_max number
Max.
participant_color.diverging_palette string
Palette. Allowed values:
participant_color.diverging_reverse boolean
Reverse.
participant_color.diverging_custom_min color
Minimum color.
participant_color.diverging_custom_mid color
Midpoint color.
participant_color.diverging_custom_max color
Maximum color.
participant_color.diverging_color_space string
Color space. Allowed values:
participant_color.diverging_custom_domain boolean
Domain. Allowed values:
participant_color.diverging_domain_min number
Min.
participant_color.diverging_domain_mid number
Mid.
participant_color.diverging_domain_max number
Max.
Camera
camera_mode string
Camera mode. Allowed values:
zoom number
Zoom level. How much to zoom in when playing Min: 1
Laps & splits
checkpoint_mode string
Checkpoint mode. Allowed values:
checkpoints text
Checkpoints. Enter the number of laps completed at each recorded checkpoint/column in the data. E.g. "0.5, 1, 1.5, 2" would mean that the times were taken every half a lap. Enter one checkpoint per line.
times_cumulative boolean
Times are cumulative. Switch on if the time columns represent the cumulative time taken at each checkpoint (e.g. 12, 25, 36).
Switch off if the times represent how long individual checkpoints took to complete (e.g. 12, 13, 11).
Labels
participant_label_mode string
Label mode. Determines which labels are drawn. Auto draws as many labels as possible whilst avoiding overlaps. Allowed values:
participant_label_custom text
Participants to label. Enter the names of the participants to label. These must exactly match the names in your data. Enter one name per line.
participant_label_position string
Label position. Allowed values:
participant_label_style boolean
Style.
participant_label_color color
Color.
participant_label_size number
Size. Min: 0.05
participant_label_stroke color
Outline.
participant_label_stroke_size number
Outline width. As a % of the font size
participant_label_weight string
Weight. Allowed values:
participant_highlight boolean
Highlight icons. Highlight the labeled participant(s)
participant_highlight_color color
Highlight color.
participant_highlight_width number
Highlight width.
label_position_enabled boolean
Whether to show the position of the participant in the label Allowed values:
label_position_time string
Show position. Set to At finish, to only show a participant's position when they've completed the race. Allowed values:
Set to During race, to only show a participant's position while they are still racing.
label_position_type string
Position to show. Whether to show a participant's current position in the race, or their finishing position Allowed values:
label_medal_enabled boolean
Allowed values:
- false (Disabled)
- true (Enabled)
label_medal_time string
Show medals. Set to At finish, to only show a participant's medal when they've completed the race. Allowed values:
Set to During race, to only show a participant's medal while they are still racing.
label_medal_type string
Medal to show. Whether to show the medal position for a participant at the current point in the race, or the medal they win at the end of the race Allowed values:
label_medal_replace_position boolean
Replace position. Turn on to replace a participant's position label with their medal if they are in a medal position
label_finishing_time_enabled boolean
Allowed values:
- false (Disabled)
- true (Enabled)
label_finishing_time_time string
Show finishing time. Allowed values:
participant_stacking string
Determines which participants obscure other participants when they overlap Allowed values:
Timeline & animation
timeline.enabled boolean
Allowed values:
- true (Enabled)
- false (Disabled)
timeline.style string
Style. Allowed values:
timeline.graph boolean
Show chart. Allowed values:
timeline.play_on_load boolean
Play on load.
timeline.loop boolean
Loop timeline. When turned on, the timeline will return to the beginning once complete. Otherwise, it will stop when it reaches the end.
timeline.duration number
Timeline duration. Total duration of the timeline during normal playback in seconds.
timeline.duration_tween number
Time jump duration. Duration of transitions between different points in time on the timeline.
This is the transition you see in the story player when switching between slides with a different time on the timeline (in seconds).
timeline.duration_wait_at_end number
Pause before loop.
timeline.axes_custom_enabled boolean
Axis settings.
timeline.color_axes color
Axes color.
timeline.axis_font_size number
Font size. Max: 3
timeline.date_format_display string
X axis date format. Predefined values:
timeline.axis_nice_x boolean
Clean X axis. Rounds out the X axis so that its start and end values are nice, round dates
timeline.axis_nice_y boolean
Clean Y axis. Rounds out the Y axis so that its start and end values are nice, round numbers
timeline.scrubber_snap boolean
Snap when scrubbing. When turned on, you can only jump to values that are supplied in the dataset and nothing in between
timeline.scrubber_snap_paused boolean
Snap when paused. Activate to snap the timeline to the closest interval when non animating. This is useful for ensuring the data visible in the visualization always reflects the data you have supplied.
timeline.layout_settings boolean
Layout settings.
timeline.margin.top number
Top.
timeline.margin.left number
Left.
timeline.margin.bottom number
Bottom.
timeline.margin.right number
Right.
timeline.playback_button.margin_right number
Space between button and timeline.
timeline.scrubber_height number
Scrubber height.
timeline.playback_button.margin_right_button number
Space between button and text.
timeline.graph_settings boolean
Chart settings.
timeline.color_background color
Background.
timeline.graph_height number
Height.
timeline.curve boolean
Curved lines.
timeline.playback_styling boolean
Play button settings.
timeline.playback_button.button_color color
Button color.
timeline.playback_button.button_size number
Button size. Max: 8
timeline.playback_button.icon_color color
Icon color.
timeline.playback_button.icon_size number
Icon size. Max: 8
timeline.playback_button.label_size number
Label size. Max: 8
Layout
layout.body_font font
Main font. This font will apply to the whole graphic by default. You can optionally change the font for the title, subtitle, footer, etc in the Header and Footer settings panels.
layout.font_color color
Text color. This color will apply to the whole graphic by default, You can optionally change the color for individual text elements, in other settings panels.
layout.background_color_enabled boolean
Color. Allowed values:
layout.background_image_enabled boolean
Image. Allowed values:
layout.background_color color
Background 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.max_width_target string
Maximum width. Apply a maximum width to just the main graphic or everything (main graphic plus header, footer, etc). Allowed values:
layout.max_width number
Maximum width. Leave blank to stretch to container width Min: 50
layout.max_width_align string
Align. 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.
layout.read_direction string
Read direction. This will change the reading direction of the main text elements on the page. It's not possible to adjust this on all elements, such as axes. Allowed values:
Note that when direction is set to right to left any alignment icons will be reversed.
layout.font_size_mobile_small number
layout.font_size_mobile_big number
layout.font_size_tablet number
layout.font_size_desktop number
layout.font_size_big_screen number
layout.breakpoint_mobile_small number
layout.breakpoint_mobile_big number
layout.breakpoint_tablet number
layout.breakpoint_desktop number
layout.breakpoint_big_screen number
Header
layout.header_align string
Alignment. Allowed values:
layout.title html
layout.title_styling boolean
Styling.
layout.title_font font
Title Font.
layout.title_size string
Size. Allowed values:
layout.title_size_custom number
Custom. Specify a custom responsive font size in rems. The 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 html
layout.subtitle_styling boolean
Styling.
layout.subtitle_font font
Subtitle Font.
layout.subtitle_size string
Size. Allowed values:
layout.subtitle_size_custom number
Custom. Specify a custom responsive font size in rems. The 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.header_text html
layout.header_text_styling boolean
Styling.
layout.header_text_size string
Size. Allowed values:
layout.header_text_size_custom number
Custom. Specify a custom responsive font size in rems. The best results will be with values between 1.2 and 3
layout.header_text_weight string
Weight. Allowed values:
layout.header_text_color color
Color.
layout.header_text_line_height number
Line height. Max: 3
layout.header_text_space_above string
Space above. Allowed values:
layout.header_text_space_above_custom number
Custom. Max: 100
layout.header_border string
Allowed values:
- top (Top)
- bottom (Bottom)
- top_and_bottom (Top & 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_border_space number
Space. Space between border and header text
layout.header_logo_enabled boolean
Allowed values:
- true (Enabled)
- false (Disabled)
layout.header_logo_src url
Image.
layout.header_logo_alt string
Alt text.
layout.header_logo_link_url string
Link.
layout.header_logo_height number
Height.
layout.header_logo_align string
Align. Align logo inside either the header or the main visualization 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.footer_align string
Alignment. Allowed values:
layout.footer_text_size number
Size.
layout.footer_text_color color
Color.
layout.footer_styling boolean
Advanced footer styles.
layout.footer_font font
Font.
layout.footer_text_weight string
Weight. Allowed values:
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 html
Note. To add the time/date stamp of when the data was last updated add {{data_last_updated}}. For example, "Last updated at {{data_last_updated}}". To customize the format, use the advanced options below.
layout.footer_note_secondary html
Note (secondary). The secondary note is placed below the source and primary note. To add the time/date stamp of when the data was last updated add {{data_last_updated}}. For example, "Last updated at {{data_last_updated}}". To customize the format, use the advanced options below.
layout.advanced_note_styling boolean
Advanced.
layout.footer_timestamp_format string
Time/date stamp formatting. To change the date/time format of your timestamp, choose from the below options or provide a custom date format in d3-time-format syntax Predefined values:
layout.footer_logo_enabled boolean
Image. Allowed values:
layout.footer_logo_src url
Image.
layout.footer_logo_src_light hidden
Image (light version). If provided this version will be used whenever the background color is dark
layout.footer_logo_alt string
Alt text.
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)
- top_and_bottom (Top & bottom)
- none (None)
layout.footer_border_width number
Width.
layout.footer_border_color color
Color.
layout.footer_border_style string
Style. Allowed values:
layout.footer_border_space number
Space. Space between border and footer text
Accessibility
layout.screenreader_text_primary text
Screenreader description. A text alternative to the visual content that will only be visible to screenreaders, e.g. “The line chart shows China consistently higher than the other countries since 1990”.
Do not replicate your title, since that will also be read by screenreaders.
layout.screenreader_label string
Screenreader label. A short text label given to the main Flourish embed wrapper to provide an accessible name that is only visible to screenreaders. Added in the form of an "aria-label".
layout.screenreader_hide_primary boolean
Screenreader mode for main visual container. Whether the main visual container is visible to screenreaders. (Text in the header and footer are always available to screenreaders.) Allowed values: