Fluent Commerce Logo
Docs

Line Chart Component

UI Component

Changed on:

19 Apr 2024

Overview

A line chart visually represents data points over a continuous interval, typically along a horizontal axis. It offers a clear depiction of trends, patterns, or fluctuations in the data by connecting points with lines, aiding in easy comprehension of the data's trajectory over time or across categories. The x-axis commonly denotes time or categories, while the y-axis represents the numerical values being measured, providing a quick snapshot of data relationships.
No alt text provided
Plugin NameCharts
Chart component for use within a Fluent OMX web app.
2023-12-15

v1.0.0

Charts UI

Alias

fc.chart.line

Detailed technical description

1[
2    { date: '2024-01-02', value: 100 },
3    { date: '2024-01-03', value: 30 },
4    { date: '2024-01-04', value: 90 },
5    { date: '2024-01-05', value: 50 },
6]
1{
2  "component": "fc.chart.line",
3  "props": {
4    "datasource": "path.to.GraphQL.data",
5    "chartContainerConfig": {
6      "height": 170,
7      "maxHeight": 170
8    },
9    "dataKey": "value",
10    "legend": true,
11    "tooltip": {
12      "formatter": "{{value}}"
13    },
14    "XAxis": {
15      "dataKey": "date",
16      "tick": false,
17      "label": "Date"
18    },
19    "YAxis": {
20      "label": "Value"
21    },
22    "lines": [{ "name": "Total Usage"}]
23  }
24}

Properties

NameTypeRequiredDefaultDescription
chartContainerChartContainerConfigNo`{`
 width: '100%',
 aspect: 1,
 maxHeight: 200,
 debounce: 1
}
The property allows to make charts adapt to the size of parent container. One of the props width and height should be a percentage string.
dataSourcestringYesnoneA string that defines a path to GraphQL data.
dataKeystringYesnoneThe property signifies the specific field in every object of dataSource array that will be presented on the chart.
tooltipTooltipNononeTooltip configuration visibility.
legendbooleanNononeEnables legend visibility.
XAxis Axis Yes none X-axis which is corresponding to the data.
 YAxis Axis No noneY-axis which is corresponding to the data.
titlestringNononeChart card title.
widthCardWidth ("quarter" / "third" / "half" / "two-thirds" / "full"/ number (1-12)) No ‘full’Define the width of the card on a 12-column grid. Can use the named widths for readability or numbers directly. On mobile devices all widths will automatically change to 12 for the best responsive experience. Default is "full" and will take up the full width of the containing component.
noCardbooleanNononeIf set to true, allows to use component without card background.
linesLineConfig []NononeAn array of lines' configurations.
 ChartContainerConfig
NameTypeRequiredDefaultDescription
widthstring / numberNo100%The percentage value of the chart's width or a fixed width.
aspectnumberNo1width / height. If specified, the height will be calculated by width / aspect.
maxHeightnumberNo200The maximum height of the container.
heightstring / numberNononeThe percentage value of the chart's width or a fixed height.Example:"100px" / 100
minWidthnumber / stringNononeThe minimum width of the container.Example:"100px" / 100
minHeightnumber / stringNononeThe minimum height of the container.Example:"100px" / 100
 Axis
NameTypeRequiredDefaultDescription
dataKeystringNononeThe key of data displayed in the axis.
tickbooleanNotrueIf set false, no ticks will be drawn.
ticks[string] / [number]NononeSet the values of axis ticks manually.
interval'preserveStart' | 'preserveEnd' | 'preserveStartEnd' | 'equidistantPreserveStart' | numberNo'preserveEnd'If set 0, all the ticks will be shown. If set ‘preserveStart’, ‘preserveEnd’ or "'preserveStartEnd', the ticks which is to be shown or hidden will be calculated automatically.
tickLinebooleanNotrueIf set false, no axis tick lines will be drawn.
axislinebooleanNotrueIf set false, no axis line will be drawn.
labelstringNononeThe property refers to the label of the axis.
tickFormatterstringNononeTemplate string to customize data displayed on a tick.
Tooltip
NameTypeRequiredDefaultDescription
tooltipFormatterstringNononeInitial value to be displayed.
Example:
`'{{value}}'`
tooltipLabelFormatterstringNononeInitial label to be displayed.
Example:
`'{{label}}'`
LineConfig
NameTypeRequiredDefaultDescription
namestringNononeLine name to be displayed in the tooltip or legend.

Configuration example

1{
2  "component": "fc.chart.line",
3  "props": {
4    "datasource": "path.to.GraphQL.data",
5    "chartContainerConfig": {
6      "height": 170,
7      "maxHeight": 170
8    },
9    "dataKey": "value",
10    "legend": true,
11    "tooltip": {
12      "formatter": "{{value}}"
13    },
14    "XAxis": {
15      "dataKey": "value",
16      "tick": false,
17      "label": "i18n:fc.inventory.sources.dashboard.line.chart.time"
18    },
19    "YAxis": {
20      "label": "i18n:fc.inventory.sources.dashboard.line.chart.updates",
21      "tickFormatter": "{{compactNumberFormat value}}"
22    }
23  }
24}

Version History

2024-02-13

v24.2.13

Line Chart description

Recommended Placement

None