Mixed-Type Charts
The easiest way to create mixed-type charts is setting up a secondary y-axis in LineChart
or a secondary axis in BarChart
You can combine multiple chart types inside a single <Chart>
tag to create mixed-type charts.
Examples
Mixed-Type Chart
This example uses multiple y columns and multiple series types (bar and line)
<Chart data={fda_recalls}>
<Bar y=voluntary_recalls/>
<Line y=fda_recalls/>
</Chart>
Because x is the first column in the dataset, an explicit x
prop is not required.
This structure also gives you control over the individual series on your chart. For example, if you have a single series running through a component, you can override props specifically for that series. Since the FDA acronym was not fully capitalized above, you can rename that specific series inside the <Line>
primitive:
<Chart data={fda_recalls}>
<Bar y=voluntary_recalls/>
<Line y=fda_recalls name="FDA Recalls"/>
</Chart>
Chart <Chart>
<Chart data={query_name}>
Insert primitives here
</Chart>
Data
Query name, wrapped in curly braces
- Options:
- query name
Column to use for the x-axis of the chart
- Options:
- column name
Column(s) to use for the y-axis of the chart
- Options:
- column name | array of column names
Column to use as the series (groups) in a multi-series chart
- Options:
- column name
Format to use for x column (see available formats)
- Options:
- Excel-style format | built-in format name | custom format name
Format to use for y column (see available formats)
- Options:
- Excel-style format | built-in format name | custom format name
Base to use when log scale is enabled
- Options:
- number
- Default:
- 10
Sets behaviour for empty datasets. Can throw an error, a warning, or allow empty. When set to 'error', empty datasets will block builds in build:strict. Note this only applies to initial page load - empty datasets caused by input component changes (dropdowns, etc.) are allowed.
- Default:
- error
Text to display when an empty dataset is received - only applies when emptySet is 'warn' or 'pass', or when the empty dataset is a result of an input component change (dropdowns, etc.).
- Options:
- string
- Default:
- No records
Chart
Chart title. Appears at top left of chart.
- Options:
- string
Chart subtitle. Appears just under title.
- Options:
- string
Minimum height of the chart area (excl. header and footer) in pixels. Adjusting the height affects all viewport sizes and may impact the mobile UX.
- Options:
- number
- Default:
- 180
Starting value for the y-axis
- Options:
- number
Maximum value for the y-axis
- Options:
- number
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Array of custom colours to use for the chart. E.g., {['#cf0d06','#eb5752','#e88a87']}
- Options:
- array of color strings (CSS name | hexademical | RGB | HSL)
- Default:
- built-in color palette
Apply a specific color to each series in your chart. Unspecified series will receive colors from the built-in palette as normal. Note the double curly braces required in the syntax seriesColors={{"Canada": "red", "US": "blue"}}
- Options:
- object with series names and assigned colors
- Default:
- colors applied by order of series in data
Which chart renderer type (canvas or SVG) to use. See ECharts' documentation on renderers.
- Default:
- canvas
Line <Line/>
<Chart data={query_name}>
<Line/>
</Chart>
Options
Column(s) to use for the y-axis of the chart. Can be different than the y supplied to Chart
- Options:
- column name | array of column names
- Default:
- y supplied to Chart
Column to use as the series (groups) in a multi-series chart. Can be different than the series supplied to Chart
- Options:
- column name
- Default:
- series supplied to Chart
Name to show in legend for a single series (to override column name)
- Options:
- string
Color to override default series color. Only accepts a single color.
- Options:
- CSS name | hexademical | RGB | HSL
% of the full color that should be rendered, with remainder being transparent
- Options:
- number (0 to 1)
- Default:
- 1
Thickness of line (in pixels)
- Options:
- number
- Default:
- 2
Size of each shape (in pixels)
- Options:
- number
- Default:
- 8
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Area <Area/>
<Chart data={query_name}>
<Area/>
</Chart>
Options
Column(s) to use for the y-axis of the chart. Can be different than the y supplied to Chart
- Options:
- column name | array of column names
- Default:
- y supplied to Chart
Column to use as the series (groups) in a multi-series chart. Can be different than the series supplied to Chart
- Options:
- column name
- Default:
- series supplied to Chart
Name to show in legend for a single series (to override column name)
- Options:
- string
Color to override default series color. Only accepts a single color.
- Options:
- CSS name | hexademical | RGB | HSL
% of the full color that should be rendered, with remainder being transparent
- Options:
- number (0 to 1)
- Default:
- 0.7
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Bar <Bar/>
<Chart data={query_name}>
<Bar/>
</Chart>
Options
Column to use for the y-axis of the chart
- Options:
- column name
Name to show in legend for a single series (to override column name)
- Options:
- string
Name for an individual stack. If separate Bar components are used with different stackNames, the chart will show multiple stacks
- Options:
- string
Color to override default series color. Only accepts a single color.
- Options:
- CSS name | hexademical | RGB | HSL
% of the full color that should be rendered, with remainder being transparent
- Options:
- number (0 to 1)
- Default:
- 1
Width of line surrounding each bar
- Options:
- number
- Default:
- 0
Color to use for outline if outlineWidth > 0
- Options:
- CSS name | hexademical | RGB | HSL
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Scatter <Scatter/>
<Chart data={query_name}>
<Scatter/>
</Chart>
Options
Column to use for the y-axis of the chart
- Options:
- column name
Name to show in legend for a single series (to override column name)
- Options:
- string
Change size of all points on the chart
- Options:
- number
- Default:
- 10
% of the full color that should be rendered, with remainder being transparent
- Options:
- number (0 to 1)
- Default:
- 0.7
Color to override default series color. Only accepts a single color.
- Options:
- CSS name | hexademical | RGB | HSL
Width of line surrounding each shape
- Options:
- number
- Default:
- 0
Color to use for outline if outlineWidth > 0
- Options:
- CSS name | hexademical | RGB | HSL
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Bubble <Bubble/>
<Chart data={query_name}>
<Bubble/>
</Chart>
Options
Column to use for the y-axis of the chart
- Options:
- column name
Column to use to scale the size of the bubbles
- Options:
- column name
Name to show in legend for a single series (to override column name)
- Options:
- string
Minimum bubble size
- Options:
- number
- Default:
- 200
Maximum bubble size
- Options:
- number
- Default:
- 400
% of the full color that should be rendered, with remainder being transparent
- Options:
- number (0 to 1)
- Default:
- 0.7
Color to override default series color. Only accepts a single color.
- Options:
- CSS name | hexademical | RGB | HSL
Width of line surrounding each shape
- Options:
- number
- Default:
- 0
Color to use for outline if outlineWidth > 0
- Options:
- CSS name | hexademical | RGB | HSL
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Hist <Hist/>
<Chart data={query_name}>
<Hist/>
</Chart>
Options
Column which contains the data you want to summarize
- Options:
- column name
Color to override default series color
- Options:
- CSS name | hexademical | RGB | HSL
% of the full color that should be rendered, with remainder being transparent
- Options:
- number (0 to 1)
- Default:
- 1
JavaScript object to add or override chart configuration settings (see Custom Charts page)
- Options:
- object
Interactivity
Group name to connect this chart to other charts for synchronized tooltip hovering. Charts with the same connectGroup
name will become connected
Annotations
Mixed type charts can include annotations using the ReferenceLine
and ReferenceArea
components. These components are used within a chart component like so:
<Chart data={sales_data} x=date y=sales>
<Line y=sales/>
<ReferenceLine data={target_data} y=target label=name/>
<ReferenceArea xMin='2020-03-14' xMax='2020-05-01'/>
</Chart>