Line, bar and pie charts

Basic types of chart, single or in a grid

Updated 5 years ago to v9.0.2 by Flourish team

How to use this template

How to get started

Upload data with one column containing “labels” (category names, years, etc) and one or more numerical columns of “values” (each of which becomes a line on a line chart, a series of bars on a bar chart, etc). Here's what your data might look like.

Year London Paris Berlin
2010 1 4 3
2020 0 3 6

Making a grid of charts

You can use the “Grid of charts” option to display each series in your data on its own mini chart – a visualisation technique called “small multiples”. Data can also be divided into mini charts by specifying a “Charts grid” column. In this case, there will be one chart for each unique value in the selected column. This is useful if your data is arranged in this way, or if you want to create a grid with multiple series on each chart.

FAQ

How do I change the colour of some of the bars, but not all of them? First, make sure you’re using a “bar” or "column" chart. Then, under "Chart styles", choose "Shade by row". Finally, specify the colours you want for each row under "Custom colours". (If you'd like to have all the bars the same colour except for one or two, a shortcut is first to customise the palette so that there's only one colour.)

Tips

  • You can use custom colours by typing them as a comma-separated list in to the “Colour scheme or custom colours” menu. You can use any named CSS colour or hexcode.
  • With a grid of line or bar charts, you can choose whether to have the same y axis for all the charts (good for comparing absolute numbers) or to have each chart set its own y-axis based on the data it contains (best for comparing the shape of each series).
  • If you make different views of your data and save them as separate visualisations, you can animate between the charts in the Flourish story editor.

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/line-bar-pie

version: 9

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/line-bar-pie",
    version: "9",
    bindings: {
        data: {
            label: 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/line-bar-pie",
    version: "9",
    bindings: {
        data: {
            label: 0, // index of a column in your data
            value: [1, 2, ...], // index(es) of column(s) in your data
            facet: 3, // 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/line-bar-pie",
    version: "9",
    bindings: {
        data: {
            label: "DataHeader1",
        }
    },
    data: {
        data: [
            { "DataHeader1": ..., "DataHeader2": ..., ... },
            { "DataHeader1": ..., "DataHeader2": ..., ... },
            { "DataHeader1": ..., "DataHeader2": ..., ... },
            ...
        ]
    }
}

All possible bindings that you can supply are shown in this example:

{
    template: "@flourish/line-bar-pie",
    version: "9",
    bindings: {
        data: {
            label: "DataHeader1",
            value: ["DataHeader2", "DataHeader3", ...],
            facet: "DataHeader4",
        }
    },
    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/line-bar-pie",
    version: "9",
    data: {
    data: [
        {
            label: ...,
            value: [...]
        },
        ...
    ]
},
    ...
}

And the full list of all possible properties is as follows:

{
    template: "@flourish/line-bar-pie",
    version: "9",
    data: {
    data: [
        {
            label: ...,
            value: [...],
            facet: ...
        },
        ...
    ]
},
    ...
}

Meanings of the template data keys:

  • data.label: A column of names or times
  • data.value: One or more columns of numbers
  • data.facet: If specified and “Grid of charts” view is on, creates a separate mini chart for each value found in the column.

Template settings

Options for opts.state.

Chart type

chart_type string

Allowed values:

  • line (Line chart)
  • area_stacked (Area chart (stacked))
  • area_prop (Area chart (stacked %))
  • area (Area chart (unstacked))
  • column_grouped (Column chart (grouped))
  • column_stacked (Column chart (stacked))
  • column_stacked_prop (Column chart (stacked %))
  • bar_grouped (Bar chart (grouped))
  • bar_stacked (Bar chart (stacked))
  • bar_stacked_prop (Bar chart (stacked %))
  • donut (Pie chart)

facet_layout string

Grid mode. “Grid of charts” creates a mini chart for each series (or each value in your ”Charts grid” column, if specified)

Allowed values:

  • single (Single chart)
  • facets (Grid of charts)

height_mode string

Height mode. In “Fill space” mode the graphic will fill the container (which by default will be the the standard Flourish responsive chart size). In “Aspect ratio” mode you set the aspect ratio of the plot and the container will be updated to acommodate it (not supported when embedded in a simple fixed-height iframe). "Auto" uses fill space but switches to "Aspect ratio" if there are too many charts for the space.

Allowed values:

  • auto (Auto)
  • fill_space (Fill space)
  • aspect (Aspect ratio)

facet_aspect number

Chart height, % of width.

facet_fixed_cols boolean

Fixed number of columns in grid.

facet_min_w number

Min chart width. Determines how many columns of charts there should be in the grid. Ignored if you specify a fixed number of columns.

facet_cols number

Number of columns in grid.

Min: 1

facet_gutter_w number

Horizontal.

facet_gutter_h number

Vertical.

facet_header_font_size number

Text size.

facet_title_align string

Alignment.

Allowed values:

  • auto (Auto)
  • left (fa-align-left)
  • center (fa-align-center)

facet_header_color_mode string

Colour mode.

Allowed values:

  • auto (Auto)
  • fixed (Fixed)

facet_header_color color

Colour.

margin_top number

Top.

margin_right number

Right.

margin_bottom number

Bottom.

margin_left number

Left.

Chart styles

bg_color_style string

Background colour.

Allowed values:

  • none (None)
  • chart (Chart)

bg_color color

Colour.

color_mode string

Colour mode.

Allowed values:

  • column (By column)
  • row (By row)

color.palette colors

Palette.

color.extend boolean

Auto-extend. Automatically generate additional colours when needed to avoid the palette colours being used more than once. Added colours are based on the average lightness and chroma values of the palette. This works best if the palette’s colours do not have very high or low saturation.

color.advanced boolean

Fine tune. Fine tune how additional colours are added to the palette.

color.hue_rotation_angle number

Hue rotation for added colours. Angle, in degrees in HCL colourspace, between one generated colour and the next. The default value, ~360/(Golden ratio), ensures adjacent hues are not too similar.

Max: 360

color.custom_palette text

Custom overrides. Type the name of the entity whose colour you want to set, a colon and then a colour (using a name, hex-code or rgb declaration). Multiple colours can be set using multiple lines. For example:


Party 1: red
Party 2: #4455AA
Party 3: rgb(30,168,26)

line_width number

Width.

line_opacity number

Opacity.

Max: 1

line_curve string

Line curve.

Allowed values:

  • curveLinear (Straight)
  • curveMonotoneX (Curve (X))
  • curveNatural (Curve (Natural))
  • curveStep (Step)
  • curveStepBefore (Step Before)
  • curveStepAfter (Step After)

line_end_labels boolean

Line labels.

line_end_labels_width number

Line label width. The margin added to the right of each chart for the line labels

area_opacity number

Opacity.

Max: 1

dot_opacity number

Opacity.

Max: 1

dot_radius number

Radius.

Max: 25

dot_radius_last number

Final radius. Scales the final dot in the series. Useful for highlighting the final point on a line chart. Leave blank to have the last dot the same size as the others.

column_padding_outer number

Space at edges. As a % of the width of a whole bar stack or group

Max: 100

column_padding_inner number

Space between bar stacks or groups. As a % of the width of a whole bar stack or group

Max: 100

column_padding_in_group number

Space between bars in groups. As a % of the width of a single bar in the group. Ignored if only a single series is selected.

Max: 100

column_opacity number

Bar opacity.

Min: 0.1

Max: 1

donut_inner_radius number

Doughnut hole (%).

Max: 99

donut_corner_radius number

Corner curve (pixels).

donut_pad_angle number

Segment padding (degrees).

Max: 10

donut_auto_scale boolean

Scale pies based on data. Scale each pie chart in the grid so that the area of each segment reflect its value

Legend

legend_position string

Legend position.

Allowed values:

  • above (Above)
  • below (Below)
  • off (Off)

legend_text_color color

Text.

text_legend string

Allowed values:

  • auto (Auto)
  • custom (Custom)
  • off (Off)

text_legend_title boolean

Title.

text_legend_subtitle boolean

Subtitle.

text_legend_bold boolean

Bold. If checked, always use bold for coloured items

Series filtering

series_filter_enabled boolean

Show series filter.

series_filter_text string

Placeholder text.

series_filter_none_text string

No more results text.

max_series number

Max number of series to show.

Data labels

labels boolean

Show labels on each data point.

labels_dot_center boolean

Position labels on center of dot.

label_bar_align string

Allowed values:

  • left (fa-align-left)
  • center (fa-align-center)
  • right (fa-align-right)

labels_color_mode string

Text colour.

Allowed values:

  • auto (Auto)
  • series (By series)
  • fixed (Fixed)

labels_fixed_color color

Colour.

labels_responsive boolean

Mode.

Allowed values:

  • true (Auto)
  • false (Fixed)

labels_font_size_min number

Min.

labels_font_size_max number

Max.

labels_font_size number

Text size.

labels_bg_mode string

Background. Adds a background to the text, matching the background colour of the chart

Allowed values:

  • auto (Auto)
  • on (On)
  • off (Off)

labels_bg_size number

Size. Size of the background, as % of text size

Max: 100

labels_show_value string

Show value.

Allowed values:

  • auto (Auto)
  • always (Always)
  • never (Never)

labels_show_label string

Show label.

Allowed values:

  • auto (Auto)
  • always (Always)
  • never (Never)

X axis

x_axis_label string

X label.

x_axis_label_font_size number

Text size.

Min: 1

x_axis_tick_h number

Height. Vertical size of the axis in pixels (excludes label)

x_axis_min number

X min. Ignored if axis is showing categories rather than numbers

x_axis_max number

X max. Ignored if axis is showing categories rather than numbers

x_axis_last_row_only boolean

Only show X axis on last grid row.

x_axis_tick_style string

Allowed values:

  • ticks (Ticks)
  • gridlines (Gridlines)
  • none (None)

x_axis_num_ticks number

Number. Approximate number of tick marks or gridlines. The actual number will depend on the range of values, chart size, etc.

x_axis_tick_dashed number

Dashes. Zero for a solid line, bigger numbers for bigger dashes

x_axis_tick_color color

Lines.

x_axis_color color

Labels.

x_axis_tick_angle string

Text angle.

Allowed values:

  • 0 (0°)
  • 30 (30°)
  • 45 (45°)
  • 60 (60°)
  • 90 (90°)

x_axis_tick_font_size number

Text size.

x_axis_ticks_inline boolean

Labels on gridlines.

Y axis

y_axis_label string

Y label.

y_axis_label_font_size number

Text size.

Min: 1

y_axis_tick_w number

Width. Horizontal size of the axis in pixels (excludes label)

y_axis_min number

Y min.

y_axis_max number

Y max.

y_axis_log boolean

Log scale.

y_axis_matching boolean

Matching y axis across grid of charts.

y_axis_first_col_only boolean

Only show Y axis on first column of grid.

y_axis_tick_style string

Allowed values:

  • ticks (Ticks)
  • gridlines (Gridlines)
  • none (None)

y_axis_bar_label_position string

Allowed values:

  • left (Left)
  • above (Above bars)

y_axis_num_ticks number

Number. Approximate number of tick marks or gridlines. The actual number will depend on the range of values, chart size, etc.

y_axis_tick_dashed number

Dashes. Zero for a solid line, bigger numbers for bigger dashes

y_axis_tick_color color

Lines.

y_axis_color color

Labels.

y_axis_tick_font_size number

Text size.

y_axis_ticks_inline boolean

Labels above lines.

Popups

show_popups boolean

Show popups.

Text size.

Annotations

anno_x_enabled boolean

Show highlights on the x axis.

anno_x_lines text

One per line, in format “Thing :: 2012”.

anno_x_line_color color

Color.

anno_x_line_width number

Width.

anno_x_line_dash number

Dash.

anno_x_areas text

One per line, in format “Thing :: 2013 >> 2015”.

anno_x_fill_color color

Area.

anno_x_label_color color

Text.

anno_x_fill_opacity number

Area opacity.

anno_x_label_align string

Labels.

Allowed values:

  • left (fa-align-left)
  • middle (fa-align-center)
  • right (fa-align-right)

anno_x_stack string

Above or below data.

Allowed values:

  • above (Above)
  • below (Behind)

anno_y_enabled boolean

Show highlights on the y axis.

anno_y_lines text

One per line, in format “Thing :: 5000”.

anno_y_line_color color

Color.

anno_y_line_width number

Width.

anno_y_line_dash number

Dash.

anno_y_areas text

One per line, in format “Thing :: 2000 >> 8000”.

anno_y_fill_color color

Area.

anno_y_label_color color

Text.

anno_y_fill_opacity number

Area opacity.

anno_y_label_align string

Labels.

Allowed values:

  • left (fa-align-left)
  • middle (fa-align-center)
  • right (fa-align-right)

anno_y_stack string

Above or below data.

Allowed values:

  • above (Above)
  • below (Behind)

Animations

data_trans_duration number

Animation duration. The duration, in milliseconds, of transitions – for example between two slides in a story

animate_on_load boolean

Animate on load.

Number formatting

localization.input_decimal_separator string

Decimal separator in data sheet. Used for interpreting your data. Only change if data is not displaying on the chart as expected.

Allowed values:

  • . (.)
  • , (,)

localization.output_separators string

Number format to display. How the numbers should appear on chart labels

Allowed values:

  • ,. (12,235.67)
  • ., (12.345,67)
  • . (12235.67)
  • , (12345,67)
  • . (12 235.67)
  • , (12 345,67)

number_format.prefix string

Prefix. Text to place in front of number

number_format.suffix string

Suffix. Text to place after number

number_format.n_dec number

Decimal places. Use negative integers to round to positive powers of ten (eg -2 rounds to the nearest 100)

Min: -10

Max: 10

number_format.strip_zeros boolean

Remove trailing zeros.

number_format.strip_separator boolean

Hide thousands separator below 10,000. Turn off if you want four-digit numbers to include a separator, e.g. “1,234” rather than “1234”.

number_format.transform_labels boolean

Multiply/divide values.

number_format.transform string

Allowed values:

  • multiply (Multiply by)
  • divide (Divide by)
  • exponentiate (×10 to the power of)

number_format.multiply_divide_constant number

number_format.exponentiate_constant number

Layout

layout.body_font font

Font.

layout.max_width number

Maximum width. Leave blank to stretch to container width

Min: 50

layout.margin number

Margin.

layout.background_color_enabled boolean

Color.

Allowed values:

  • true (On)
  • false (Off)

layout.background_image_enabled boolean

Image.

Allowed values:

  • true (On)
  • false (Off)

layout.background_color color

Color.

layout.background_image_src url

Image URL.

layout.background_image_size string

Size.

Allowed values:

  • cover (Fill)
  • contain (Fit)
  • auto (Original)
  • 100% 100% (Stretch)

layout.background_image_position string

Position.

Allowed values:

  • top left (Top left)
  • top center (Top center)
  • top right (Top right)
  • center left (Center left)
  • center center (Center)
  • center right (Center right)
  • bottom left (Bottom left)
  • bottom center (Bottom center)
  • bottom right (Bottom right)

layout.layout_order string

Layout order.

Allowed values:

  • stack-default (data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAdCAYAAAHZdKxuAAAAAXNSR0IArs4c6QAAANhJREFUSA3tVNEOwiAM7Iy/p2/wkTz6g5gjOVZZEepcjMmWLBTau95ugIh6lpzzLcb4wNpFJaRk9MIahxAyXmD7mC7BC2RlFbliQjFMpJTujOdGs/ECwRoP3rlKoEzNJlz3+CwutK0NLRVt2QhjggA9n2IGEKANMxmt0VVsEfxgzfX7zL3ZiqbXLjcKc8vEORk5/75mMB/7u11uuIpdbtDCc5R3l/s+e+pmHt1foza7Nv6IXOeHiqGk9zWtSk1cN2cPrItnYjZzHZEZYtacxHTiuANSO/xN8AS4uW8Rw1Gu2AAAAABJRU5ErkJggg==)
  • stack-2 (data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAdCAYAAAHZdKxuAAAAAXNSR0IArs4c6QAAAMpJREFUSA3tVMsKwyAQNKW/l970Iz32Bw0jjKTrSLUY0oOBsO5rnOwYnTs9W0ppDyG8EcsOkw8uauu9T3jR2+75yJxBnnC4JxMxxlezg0V9VsJsIGz75TfKdlkpg3aPcT8TsPNRMJjZEIf5xaAAahUyE+RtfcZvtFLoFh95aFXxH4hCWpUoTCg7fxqUfB4yEcl/CJlNy5qbfuZA8m8CwJ77q2djSj50lnuAWbOAOQlXxCuRHxcUje2XzfgrYzBpHUXLkmxh181SpnEAB4Vg0DSGhHsAAAAASUVORK5CYII=)
  • stack-3 (data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAdCAYAAAHZdKxuAAAAAXNSR0IArs4c6QAAANFJREFUSA3tVEEOwyAMo9O+193gkRz3QSZHMmNRUkGp1guVqkCIHZMAITTfVkrZU0pv+B7NQpCV1vEdxxgLfmB9jEvwBBNzkjXn/HIRDOqzJs0GwS1eEmonAn52RITJaUYScd5KLl0fTQf58HVpIFlXMDPNBVMf2TDXPq7dZM2eelrMQ6uDucG50mlWzG/ooCWDvqENXldn1pcyhpgJWjYcPe5z5ZFrAgoe2LN0f2v1ZYq5UyofuiME99hFXKtUm1c9aoBmeEeRjVIQma6XpVblAwnpZjN/VjqsAAAAAElFTkSuQmCC)
  • stack-4 (data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAdCAYAAAHZdKxuAAAAAXNSR0IArs4c6QAAANtJREFUSA3tVNEOwjAI3Iy/p2/tR/bRH6zekmuA1glO45bYZAHKcdDCOk1izbXWC+0zlJzzDVJ5sNGW9qSUKj4QKY8yWvBDUWnoKKVcTzS2yWHiIfeMwm2yIbLbRL3DRJYubi+0bAPCkcvapO3AdFgZvuDuyJZR2i4wSpBBP9ZD7RsOLQ9gD/Y5ZmaA3EEHWY6r3SEwrzDEHLpnlvOXa4/7xttZfhNwyPdKcqLPaz6JlXpr9bNgCfbobw2ch5iY0CQzyCOPR9ya5zleBPNy3LxknAbiv1YxExxH3gEqBW7I4zw3PQAAAABJRU5ErkJggg==)

layout.space_between_sections string

Space between sections.

Allowed values:

  • 0 (▁)
  • 0.5 (▃)
  • 1 (▄)
  • custom (...)

layout.space_between_sections_custom number

Custom.

Max: 100

layout.header_align string

Alignment.

Allowed values:

  • left (fa-align-left)
  • center (fa-align-center)
  • right (fa-align-right)

layout.title string

layout.title_styling boolean

Change title styles.

layout.title_size string

Size.

Allowed values:

  • 1.4 (ᴀ)
  • 1.6 (A)
  • 2 (fa-font)
  • custom (...)

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:

  • bold (Bold)
  • normal (Regular)

layout.title_color color

Color.

layout.title_line_height number

Line height.

Max: 3

layout.subtitle string

layout.subtitle_styling boolean

Change subtitle styles.

layout.subtitle_size string

Size.

Allowed values:

  • 1.4 (ᴀ)
  • 1.6 (A)
  • 2 (fa-font)
  • custom (...)

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:

  • bold (Bold)
  • normal (Regular)

layout.subtitle_color color

Color.

layout.subtitle_line_height number

Line height.

Max: 3

layout.subtitle_space_above string

Space above.

Allowed values:

  • 0 (▁)
  • 0.5 (▃)
  • 1 (▄)
  • custom (...)

layout.subtitle_space_above_custom number

Custom.

Max: 100

layout.text string

layout.text_styling boolean

Change text styles.

layout.text_size string

Size.

Allowed values:

  • 1.2 (ᴀ)
  • 1.4 (A)
  • 1.6 (fa-font)
  • custom (...)

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:

  • bold (Bold)
  • normal (Regular)

layout.text_color color

Color.

layout.text_line_height number

Line height.

Max: 3

layout.text_space_above string

Space above.

Allowed values:

  • 0 (▁)
  • 0.5 (▃)
  • 1 (▄)
  • custom (...)

layout.text_space_above_custom number

Custom.

Max: 100

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.note string

Note.

layout.size number

Size.

layout.color color

Color.

layout.footer_align string

Alignment.

Allowed values:

  • left (fa-align-left)
  • center (fa-align-center)
  • right (fa-align-right)
  • justify (fa-align-justify)

layout.logo_url url

Image.

Link.

layout.logo_height number

Height.

layout.logo_margin number

Margin.

layout.logo_order string

Position.

Allowed values:

  • left (Left)
  • right (Right)

layout.footer_align_vertical string

V. align.

Allowed values:

  • flex-start (Top)
  • center (Center)
  • flex-end (Bottom)