Chart (lv_chart)

Visualizes data series as lines, bars or scatter points with axes.

Overview

The Chart visualizes one or more data series as lines, bars or scatter points. It supports division lines, up to four axes, a configurable point count, and runtime add/remove of series and points.

Learn more in the LVGL Open documentation.

Enumerations

lv_chart_type — How the chart draws its data series

ValueDescription
noneDraw nothing
lineDraw data points as connected lines
barDraw data points as bars
stackedDraw series as stacked bars on top of each other
scatterDraw data points as unconnected dots

lv_chart_update_mode — How the chart handles new data points

ValueDescription
shiftShift old data to the left when new points are added
circularOverwrite the oldest data in a circular buffer style

lv_chart_axis — Which axis a series belongs to

ValueDescription
primary_xUse the primary X axis
primary_yUse the primary Y axis
secondary_xUse the secondary X axis
secondary_yUse the secondary Y axis

Properties

Parts

Style parts of the widget with local style (e.g. style_bg_color-knob="0xff0000") or with style sheets (e.g. <style name="style_knob" selector="knob">). See Styles to learn more.

PartDescription
mainThe background and the division lines: background properties, plus the line properties (line_color/width/dash) for the division lines. pad_column sets the space between BAR column groups.
itemsThe data series body. For LINE charts the connecting lines use the line properties (line_color, line_width, line_dash, line_rounded). For BAR charts the bars use the background properties (bg_color, radius, border). pad_column sets the gap between bars on the same X.
indicatorThe point markers drawn at each value on LINE and SCATTER charts: width/height set the marker size, bg_color its fill and radius its roundness; border, outline, and shadow properties also apply.
cursorThe cursors: the line properties draw the crosshair lines and the marker at the cursor point uses width together with bg_color/radius.
scrollbarThe scrollbar shown when the chart is zoomed/scrolled: width (thickness), background properties and padding.

Properties below are the widget's XML <api>; see API for how properties, parameters and elements work.

PropertyTypeDescription
typeenum:lv_chart_typeChoose how the chart should draw its data
point_countintSet how many data points each series stores
update_modeenum:lv_chart_update_modeChoose how the chart updates when adding new points
hor_div_line_countintShow this many horizontal division lines
ver_div_line_countintShow this many vertical division lines

<lv_chart-series>

Add a data series to the chart

access add · returns lv_chart_series

NameKindTypeDescription
colorargcolorSet the color of the series
axisargenum:lv_chart_axis+Choose which axis the series belongs to (default: primary_y)
valuespropint[count]Provide the data values of the series

<lv_chart-cursor>

Add a cursor indicator to the chart

access add · returns lv_chart_cursor

NameKindTypeDescription
colorargcolorSet the color of the cursor
dirargenum:lv_dirChoose the direction of the cursor
pos_xpropintSet the X position of the cursor
pos_ypropintSet the Y position of the cursor

<lv_chart-axis>

Configure the range of a chart axis

access set

NameKindTypeDescription
axisargenum:lv_chart_axisChoose which axis to configure
min_valuepropintSet the minimum value of the axis
max_valuepropintSet the maximum value of the axis

Last updated on

On this page