lv_chart.h
Defines
-
LV_CHART_POINT_NONE
Default value of points. Can be used to not draw a point
Typedefs
-
typedef _lv_chart_type_t lv_chart_type_t
-
typedef _lv_chart_update_mode_t lv_chart_update_mode_t
-
typedef _lv_chart_axis_t lv_chart_axis_t
Enums
-
enum _lv_chart_type_t
Chart types
Values:
-
enumerator LV_CHART_TYPE_NONE
Don't draw the series
-
enumerator LV_CHART_TYPE_LINE
Connect the points with lines
-
enumerator LV_CHART_TYPE_BAR
Draw columns
-
enumerator LV_CHART_TYPE_SCATTER
Draw points and lines in 2D (x,y coordinates)
-
enumerator LV_CHART_TYPE_NONE
-
enum _lv_chart_update_mode_t
Chart update mode for
lv_chart_set_next
Values:
-
enumerator LV_CHART_UPDATE_MODE_SHIFT
Shift old data to the left and add the new one the right
-
enumerator LV_CHART_UPDATE_MODE_CIRCULAR
Add the new data in a circular way
-
enumerator LV_CHART_UPDATE_MODE_SHIFT
-
enum _lv_chart_axis_t
Enumeration of the axis'
Values:
-
enumerator LV_CHART_AXIS_PRIMARY_Y
-
enumerator LV_CHART_AXIS_SECONDARY_Y
-
enumerator LV_CHART_AXIS_PRIMARY_X
-
enumerator LV_CHART_AXIS_SECONDARY_X
-
enumerator _LV_CHART_AXIS_LAST
-
enumerator LV_CHART_AXIS_PRIMARY_Y
-
enum lv_chart_draw_part_type_t
type
field inlv_obj_draw_part_dsc_t
ifclass_p = lv_chart_class
Used inLV_EVENT_DRAW_PART_BEGIN
andLV_EVENT_DRAW_PART_END
Values:
-
enumerator LV_CHART_DRAW_PART_DIV_LINE_INIT
Used before/after drawn the div lines
-
enumerator LV_CHART_DRAW_PART_DIV_LINE_HOR
Used for each horizontal division lines
-
enumerator LV_CHART_DRAW_PART_DIV_LINE_VER
Used for each vertical division lines
-
enumerator LV_CHART_DRAW_PART_LINE_AND_POINT
Used on line and scatter charts for lines and points
-
enumerator LV_CHART_DRAW_PART_BAR
Used on bar charts for the rectangles
-
enumerator LV_CHART_DRAW_PART_CURSOR
Used on cursor lines and points
-
enumerator LV_CHART_DRAW_PART_TICK_LABEL
Used on tick lines and labels
-
enumerator LV_CHART_DRAW_PART_DIV_LINE_INIT
Functions
-
lv_obj_t *lv_chart_create(lv_obj_t *parent)
Create a chart object
- Parameters:
parent -- pointer to an object, it will be the parent of the new chart
- Returns:
pointer to the created chart
-
void lv_chart_set_type(lv_obj_t *obj, lv_chart_type_t type)
Set a new type for a chart
- Parameters:
obj -- pointer to a chart object
type -- new type of the chart (from 'lv_chart_type_t' enum)
-
void lv_chart_set_point_count(lv_obj_t *obj, uint16_t cnt)
Set the number of points on a data line on a chart
- Parameters:
obj -- pointer to a chart object
cnt -- new number of points on the data lines
-
void lv_chart_set_range(lv_obj_t *obj, lv_chart_axis_t axis, lv_coord_t min, lv_coord_t max)
Set the minimal and maximal y values on an axis
- Parameters:
obj -- pointer to a chart object
axis --
LV_CHART_AXIS_PRIMARY_Y
orLV_CHART_AXIS_SECONDARY_Y
min -- minimum value of the y axis
max -- maximum value of the y axis
-
void lv_chart_set_update_mode(lv_obj_t *obj, lv_chart_update_mode_t update_mode)
Set update mode of the chart object. Affects
- Parameters:
obj -- pointer to a chart object
update_mode -- the update mode
-
void lv_chart_set_div_line_count(lv_obj_t *obj, uint8_t hdiv, uint8_t vdiv)
Set the number of horizontal and vertical division lines
- Parameters:
obj -- pointer to a chart object
hdiv -- number of horizontal division lines
vdiv -- number of vertical division lines
-
void lv_chart_set_zoom_x(lv_obj_t *obj, uint16_t zoom_x)
Zoom into the chart in X direction
- Parameters:
obj -- pointer to a chart object
zoom_x -- zoom in x direction. LV_ZOOM_NONE or 256 for no zoom, 512 double zoom
-
void lv_chart_set_zoom_y(lv_obj_t *obj, uint16_t zoom_y)
Zoom into the chart in Y direction
- Parameters:
obj -- pointer to a chart object
zoom_y -- zoom in y direction. LV_ZOOM_NONE or 256 for no zoom, 512 double zoom
-
uint16_t lv_chart_get_zoom_x(const lv_obj_t *obj)
Get X zoom of a chart
- Parameters:
obj -- pointer to a chart object
- Returns:
the X zoom value
-
uint16_t lv_chart_get_zoom_y(const lv_obj_t *obj)
Get Y zoom of a chart
- Parameters:
obj -- pointer to a chart object
- Returns:
the Y zoom value
-
void lv_chart_set_axis_tick(lv_obj_t *obj, lv_chart_axis_t axis, lv_coord_t major_len, lv_coord_t minor_len, lv_coord_t major_cnt, lv_coord_t minor_cnt, bool label_en, lv_coord_t draw_size)
Set the number of tick lines on an axis
- Parameters:
obj -- pointer to a chart object
axis -- an axis which ticks count should be set
major_len -- length of major ticks
minor_len -- length of minor ticks
major_cnt -- number of major ticks on the axis
minor_cnt -- number of minor ticks between two major ticks
label_en -- true: enable label drawing on major ticks
draw_size -- extra size required to draw the tick and labels (start with 20 px and increase if the ticks/labels are clipped)
-
lv_chart_type_t lv_chart_get_type(const lv_obj_t *obj)
Get the type of a chart
- Parameters:
obj -- pointer to chart object
- Returns:
type of the chart (from 'lv_chart_t' enum)
-
uint16_t lv_chart_get_point_count(const lv_obj_t *obj)
Get the data point number per data line on chart
- Parameters:
obj -- pointer to chart object
- Returns:
point number on each data line
-
uint16_t lv_chart_get_x_start_point(const lv_obj_t *obj, lv_chart_series_t *ser)
Get the current index of the x-axis start point in the data array
- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
- Returns:
the index of the current x start point in the data array
-
void lv_chart_get_point_pos_by_id(lv_obj_t *obj, lv_chart_series_t *ser, uint16_t id, lv_point_t *p_out)
Get the position of a point to the chart.
- Parameters:
obj -- pointer to a chart object
ser -- pointer to series
id -- the index.
p_out -- store the result position here
-
void lv_chart_refresh(lv_obj_t *obj)
Refresh a chart if its data line has changed
- Parameters:
obj -- pointer to chart object
-
lv_chart_series_t *lv_chart_add_series(lv_obj_t *obj, lv_color_t color, lv_chart_axis_t axis)
Allocate and add a data series to the chart
- Parameters:
obj -- pointer to a chart object
color -- color of the data series
axis -- the y axis to which the series should be attached (::LV_CHART_AXIS_PRIMARY_Y or ::LV_CHART_AXIS_SECONDARY_Y)
- Returns:
pointer to the allocated data series or NULL on failure
-
void lv_chart_remove_series(lv_obj_t *obj, lv_chart_series_t *series)
Deallocate and remove a data series from a chart
- Parameters:
obj -- pointer to a chart object
series -- pointer to a data series on 'chart'
-
void lv_chart_hide_series(lv_obj_t *chart, lv_chart_series_t *series, bool hide)
Hide/Unhide a single series of a chart.
- Parameters:
chart -- pointer to a chart object.
series -- pointer to a series object
hide -- true: hide the series
-
void lv_chart_set_series_color(lv_obj_t *chart, lv_chart_series_t *series, lv_color_t color)
Change the color of a series
- Parameters:
chart -- pointer to a chart object.
series -- pointer to a series object
color -- the new color of the series
-
void lv_chart_set_x_start_point(lv_obj_t *obj, lv_chart_series_t *ser, uint16_t id)
Set the index of the x-axis start point in the data array. This point will be considers the first (left) point and the other points will be drawn after it.
- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
id -- the index of the x point in the data array
-
lv_chart_series_t *lv_chart_get_series_next(const lv_obj_t *chart, const lv_chart_series_t *ser)
Get the next series.
- Parameters:
chart -- pointer to a chart
ser -- the previous series or NULL to get the first
- Returns:
the next series or NULL if there is no more.
-
lv_chart_cursor_t *lv_chart_add_cursor(lv_obj_t *obj, lv_color_t color, lv_dir_t dir)
Add a cursor with a given color
- Parameters:
obj -- pointer to chart object
color -- color of the cursor
dir -- direction of the cursor.
LV_DIR_RIGHT/LEFT/TOP/DOWN/HOR/VER/ALL
. OR-ed values are possible
- Returns:
pointer to the created cursor
-
void lv_chart_set_cursor_pos(lv_obj_t *chart, lv_chart_cursor_t *cursor, lv_point_t *pos)
Set the coordinate of the cursor with respect to the paddings
- Parameters:
chart -- pointer to a chart object
cursor -- pointer to the cursor
pos -- the new coordinate of cursor relative to the chart
-
void lv_chart_set_cursor_point(lv_obj_t *chart, lv_chart_cursor_t *cursor, lv_chart_series_t *ser, uint16_t point_id)
Stick the cursor to a point
- Parameters:
chart -- pointer to a chart object
cursor -- pointer to the cursor
ser -- pointer to a series
point_id -- the point's index or
LV_CHART_POINT_NONE
to not assign to any points.
-
lv_point_t lv_chart_get_cursor_point(lv_obj_t *chart, lv_chart_cursor_t *cursor)
Get the coordinate of the cursor with respect to the paddings
- Parameters:
chart -- pointer to a chart object
cursor -- pointer to cursor
- Returns:
coordinate of the cursor as lv_point_t
-
void lv_chart_set_all_value(lv_obj_t *obj, lv_chart_series_t *ser, lv_coord_t value)
Initialize all data points of a series with a value
- Parameters:
obj -- pointer to chart object
ser -- pointer to a data series on 'chart'
value -- the new value for all points.
LV_CHART_POINT_NONE
can be used to hide the points.
-
void lv_chart_set_next_value(lv_obj_t *obj, lv_chart_series_t *ser, lv_coord_t value)
Set the next point's Y value according to the update mode policy.
- Parameters:
obj -- pointer to chart object
ser -- pointer to a data series on 'chart'
value -- the new value of the next data
-
void lv_chart_set_next_value2(lv_obj_t *obj, lv_chart_series_t *ser, lv_coord_t x_value, lv_coord_t y_value)
Set the next point's X and Y value according to the update mode policy.
- Parameters:
obj -- pointer to chart object
ser -- pointer to a data series on 'chart'
x_value -- the new X value of the next data
y_value -- the new Y value of the next data
-
void lv_chart_set_value_by_id(lv_obj_t *obj, lv_chart_series_t *ser, uint16_t id, lv_coord_t value)
Set an individual point's y value of a chart's series directly based on its index
- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
id -- the index of the x point in the array
value -- value to assign to array point
-
void lv_chart_set_value_by_id2(lv_obj_t *obj, lv_chart_series_t *ser, uint16_t id, lv_coord_t x_value, lv_coord_t y_value)
Set an individual point's x and y value of a chart's series directly based on its index Can be used only with
LV_CHART_TYPE_SCATTER
.- Parameters:
obj -- pointer to chart object
ser -- pointer to a data series on 'chart'
id -- the index of the x point in the array
x_value -- the new X value of the next data
y_value -- the new Y value of the next data
-
void lv_chart_set_ext_y_array(lv_obj_t *obj, lv_chart_series_t *ser, lv_coord_t array[])
Set an external array for the y data points to use for the chart NOTE: It is the users responsibility to make sure the
point_cnt
matches the external array size.- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
array -- external array of points for chart
-
void lv_chart_set_ext_x_array(lv_obj_t *obj, lv_chart_series_t *ser, lv_coord_t array[])
Set an external array for the x data points to use for the chart NOTE: It is the users responsibility to make sure the
point_cnt
matches the external array size.- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
array -- external array of points for chart
-
lv_coord_t *lv_chart_get_y_array(const lv_obj_t *obj, lv_chart_series_t *ser)
Get the array of y values of a series
- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
- Returns:
the array of values with 'point_count' elements
-
lv_coord_t *lv_chart_get_x_array(const lv_obj_t *obj, lv_chart_series_t *ser)
Get the array of x values of a series
- Parameters:
obj -- pointer to a chart object
ser -- pointer to a data series on 'chart'
- Returns:
the array of values with 'point_count' elements
Variables
-
const lv_obj_class_t lv_chart_class
-
struct lv_chart_series_t
- #include <lv_chart.h>
Descriptor a chart series
Public Members
-
lv_coord_t *x_points
-
lv_coord_t *y_points
-
lv_color_t color
-
uint16_t start_point
-
uint8_t x_ext_buf_assigned
-
uint8_t y_ext_buf_assigned
-
uint8_t x_axis_sec
-
uint8_t y_axis_sec
-
lv_coord_t *x_points
-
struct lv_chart_cursor_t
Public Members
-
lv_point_t pos
-
lv_coord_t point_id
-
lv_color_t color
-
lv_chart_series_t *ser
-
uint8_t pos_set
-
lv_point_t pos
-
struct lv_chart_tick_dsc_t
Public Members
-
lv_coord_t major_len
-
lv_coord_t minor_len
-
lv_coord_t draw_size
-
uint32_t minor_cnt
-
uint32_t major_cnt
-
uint32_t label_en
-
lv_coord_t major_len
-
struct lv_chart_t
Public Members
-
lv_ll_t series_ll
Linked list for the series (stores lv_chart_series_t)
-
lv_ll_t cursor_ll
Linked list for the cursors (stores lv_chart_cursor_t)
-
lv_chart_tick_dsc_t tick[4]
-
lv_coord_t ymin[2]
-
lv_coord_t ymax[2]
-
lv_coord_t xmin[2]
-
lv_coord_t xmax[2]
-
lv_coord_t pressed_point_id
-
uint16_t hdiv_cnt
Number of horizontal division lines
-
uint16_t vdiv_cnt
Number of vertical division lines
-
uint16_t point_cnt
Point number in a data line
-
uint16_t zoom_x
-
uint16_t zoom_y
-
lv_chart_type_t type
Line or column chart
-
lv_chart_update_mode_t update_mode
-
lv_ll_t series_ll