lv_chart.h
API reference for lv_chart.h
Functions
lv_chart_set_type
Set a new type for a chart
void lv_chart_set_type(lv_obj_t *obj, lv_chart_type_t type)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
type | lv_chart_type_t | new type of the chart (from 'lv_chart_type_t' enum) |
lv_chart_set_point_count
Set the number of points on a data line on a chart
void lv_chart_set_point_count(lv_obj_t *obj, uint32_t cnt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
cnt | uint32_t | new number of points on the data lines |
lv_chart_set_axis_range
Set the minimal and maximal y values on an axis
void lv_chart_set_axis_range(lv_obj_t *obj, lv_chart_axis_t axis, int32_t min, int32_t max)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
axis | lv_chart_axis_t | LV_CHART_AXIS_PRIMARY_Y or LV_CHART_AXIS_SECONDARY_Y |
min | int32_t | minimum value of the y axis |
max | int32_t | maximum value of the y axis |
lv_chart_set_axis_min_value
Set the minimal values on an axis
void lv_chart_set_axis_min_value(lv_obj_t *obj, lv_chart_axis_t axis, int32_t min)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
axis | lv_chart_axis_t | LV_CHART_AXIS_PRIMARY_Y or LV_CHART_AXIS_SECONDARY_Y |
min | int32_t | minimal value of the y axis |
lv_chart_set_axis_max_value
Set the maximal y values on an axis
void lv_chart_set_axis_max_value(lv_obj_t *obj, lv_chart_axis_t axis, int32_t max)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
axis | lv_chart_axis_t | LV_CHART_AXIS_PRIMARY_Y or LV_CHART_AXIS_SECONDARY_Y |
max | int32_t | maximum value of the y axis |
lv_chart_set_update_mode
Set update mode of the chart object. Affects
void lv_chart_set_update_mode(lv_obj_t *obj, lv_chart_update_mode_t update_mode)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
update_mode | lv_chart_update_mode_t | the update mode |
lv_chart_set_div_line_count
Set the number of horizontal and vertical division lines
void lv_chart_set_div_line_count(lv_obj_t *obj, uint32_t hdiv, uint32_t vdiv)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
hdiv | uint32_t | number of horizontal division lines |
vdiv | uint32_t | number of vertical division lines |
lv_chart_set_hor_div_line_count
Set the number of horizontal division lines
void lv_chart_set_hor_div_line_count(lv_obj_t *obj, uint32_t cnt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
cnt | uint32_t | number of horizontal division lines |
lv_chart_set_ver_div_line_count
Set the number of vertical division lines
void lv_chart_set_ver_div_line_count(lv_obj_t *obj, uint32_t cnt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
cnt | uint32_t | number of vertical division lines |
lv_chart_set_series_color
Change the color of a series
void lv_chart_set_series_color(lv_obj_t *chart, lv_chart_series_t *series, lv_color_t color)| Name | Type | Description |
|---|---|---|
chart | lv_obj_t * | pointer to a chart object. |
series | lv_chart_series_t * | pointer to a series object |
color | lv_color_t | the new color of the series |
lv_chart_set_x_start_point
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.
void lv_chart_set_x_start_point(lv_obj_t *obj, lv_chart_series_t *ser, uint32_t id)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
id | uint32_t | the index of the x point in the data array |
lv_chart_set_cursor_pos
Set the coordinate of the cursor with respect to the paddings
void lv_chart_set_cursor_pos(lv_obj_t *chart, lv_chart_cursor_t *cursor, lv_point_t *pos)| Name | Type | Description |
|---|---|---|
chart | lv_obj_t * | pointer to a chart object |
cursor | lv_chart_cursor_t * | pointer to the cursor |
pos | lv_point_t * | the new coordinate of cursor relative to the chart |
lv_chart_set_cursor_pos_x
Set the X coordinate of the cursor with respect to the paddings
void lv_chart_set_cursor_pos_x(lv_obj_t *chart, lv_chart_cursor_t *cursor, int32_t x)| Name | Type | Description |
|---|---|---|
chart | lv_obj_t * | pointer to a chart object |
cursor | lv_chart_cursor_t * | pointer to the cursor |
x | int32_t | the new X coordinate of cursor relative to the chart |
lv_chart_set_cursor_pos_y
Set the coordinate of the cursor with respect to the paddings
void lv_chart_set_cursor_pos_y(lv_obj_t *chart, lv_chart_cursor_t *cursor, int32_t y)| Name | Type | Description |
|---|---|---|
chart | lv_obj_t * | pointer to a chart object |
cursor | lv_chart_cursor_t * | pointer to the cursor |
y | int32_t | the new Y coordinate of cursor relative to the chart |
lv_chart_set_cursor_point
Stick the cursor to a point
void lv_chart_set_cursor_point(lv_obj_t *chart, lv_chart_cursor_t *cursor, lv_chart_series_t *ser, uint32_t point_id)| Name | Type | Description |
|---|---|---|
chart | lv_obj_t * | pointer to a chart object |
cursor | lv_chart_cursor_t * | pointer to the cursor |
ser | lv_chart_series_t * | pointer to a series |
point_id | uint32_t | the point's index or LV_CHART_POINT_NONE to not assign to any points. |
lv_chart_set_all_values
Initialize all data points of a series with a value
void lv_chart_set_all_values(lv_obj_t *obj, lv_chart_series_t *ser, int32_t value)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
value | int32_t | the new value for all points. LV_CHART_POINT_NONE can be used to hide the points. |
lv_chart_set_next_value
Set the next point's Y value according to the update mode policy.
void lv_chart_set_next_value(lv_obj_t *obj, lv_chart_series_t *ser, int32_t value)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
value | int32_t | the new value of the next data |
lv_chart_set_next_value2
Set the next point's X and Y value according to the update mode policy.
void lv_chart_set_next_value2(lv_obj_t *obj, lv_chart_series_t *ser, int32_t x_value, int32_t y_value)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
x_value | int32_t | the new X value of the next data |
y_value | int32_t | the new Y value of the next data |
lv_chart_set_series_values
Same as lv_chart_set_next_value but set the values from an array
void lv_chart_set_series_values(lv_obj_t *obj, lv_chart_series_t *ser, const int32_t values[], size_t values_cnt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
values | const int32_t | the new values to set |
values_cnt | size_t | number of items in values |
lv_chart_set_series_values2
Same as lv_chart_set_next_value2 but set the values from an array
void lv_chart_set_series_values2(lv_obj_t *obj, lv_chart_series_t *ser, const int32_t x_values[], const int32_t y_values[], size_t values_cnt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
x_values | const int32_t | the new values to set on the X axis |
y_values | const int32_t | the new values to set o nthe Y axis |
values_cnt | size_t | number of items in x_values and y_values |
lv_chart_set_series_value_by_id
Set an individual point's y value of a chart's series directly based on its index
void lv_chart_set_series_value_by_id(lv_obj_t *obj, lv_chart_series_t *ser, uint32_t id, int32_t value)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
id | uint32_t | the index of the x point in the array |
value | int32_t | value to assign to array point |
lv_chart_set_series_value_by_id2
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.
void lv_chart_set_series_value_by_id2(lv_obj_t *obj, lv_chart_series_t *ser, uint32_t id, int32_t x_value, int32_t y_value)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
id | uint32_t | the index of the x point in the array |
x_value | int32_t | the new X value of the next data |
y_value | int32_t | the new Y value of the next data |
lv_chart_set_series_ext_y_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.
void lv_chart_set_series_ext_y_array(lv_obj_t *obj, lv_chart_series_t *ser, int32_t array[])| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
array | int32_t | external array of points for chart |
lv_chart_set_series_ext_x_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.
void lv_chart_set_series_ext_x_array(lv_obj_t *obj, lv_chart_series_t *ser, int32_t array[])| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a chart object |
ser | lv_chart_series_t * | pointer to a data series on 'chart' |
array | int32_t | external array of points for chart |
Enums
lv_chart_type_t
Chart types
| Name | Description |
|---|---|
LV_CHART_TYPE_NONE | Don't draw the series |
LV_CHART_TYPE_LINE | Connect the points with lines |
LV_CHART_TYPE_CURVE | Connect the points with curves |
LV_CHART_TYPE_BAR | Draw bars for each series |
LV_CHART_TYPE_STACKED | Draw a single stacked bar for each data point. Supports only positive values |
LV_CHART_TYPE_SCATTER | Draw points and lines in 2D (x,y coordinates) |
Used by 1 function
lv_chart_set_type— paramtype
lv_chart_update_mode_t
Chart update mode for lv_chart_set_next
| Name | Description |
|---|---|
LV_CHART_UPDATE_MODE_SHIFT | Shift old data to the left and add the new one the right |
LV_CHART_UPDATE_MODE_CIRCULAR | Add the new data in a circular way |
Used by 1 function
lv_chart_set_update_mode— paramupdate_mode
lv_chart_axis_t
Enumeration of the axis'
| Name | Value |
|---|---|
LV_CHART_AXIS_PRIMARY_Y | 0x00 |
LV_CHART_AXIS_SECONDARY_Y | 0x01 |
LV_CHART_AXIS_PRIMARY_X | 0x02 |
LV_CHART_AXIS_SECONDARY_X | 0x04 |
LV_CHART_AXIS_LAST |
Used by 4 functions
lv_chart_set_axis_range— paramaxislv_chart_set_axis_min_value— paramaxislv_chart_set_axis_max_value— paramaxislv_chart_add_series— paramaxis
_lv_property_chart_id_t
| Name | Value |
|---|---|
LV_PROPERTY_CHART_TYPE | (LV_PROPERTY_CHART_START + ((int) 0 )) | (( 1 ) << 28 ) |
LV_PROPERTY_CHART_POINT_COUNT | (LV_PROPERTY_CHART_START + ((int) 1 )) | (( 1 ) << 28 ) |
LV_PROPERTY_CHART_UPDATE_MODE | (LV_PROPERTY_CHART_START + ((int) 2 )) | (( 1 ) << 28 ) |
LV_PROPERTY_CHART_HOR_DIV_LINE_COUNT | (LV_PROPERTY_CHART_START + ((int) 3 )) | (( 1 ) << 28 ) |
LV_PROPERTY_CHART_VER_DIV_LINE_COUNT | (LV_PROPERTY_CHART_START + ((int) 4 )) | (( 1 ) << 28 ) |
LV_PROPERTY_CHART_END |
Macros
LV_CHART_POINT_NONE
#define LV_CHART_POINT_NONE (INT32_MAX)Default value of points. Can be used to not draw a point
Variables
lv_chart_class
const lv_obj_class_t lv_chart_classDependencies
Indirect dependencies
lv_anim.hlv_area.hlv_array.hlv_assert.hlv_bidi.hlv_color.hlv_color_op.hlv_conf_kconfig.hlv_display.hlv_draw.hlv_draw_arc.hlv_draw_blur.hlv_draw_buf.hlv_draw_image.hlv_draw_label.hlv_draw_line.hlv_draw_rect.hlv_draw_triangle.hlv_event.hlv_ext_data.hlv_flex.hlv_font.hlv_fs.hlv_grad.hlv_grid.hlv_group.hlv_image_decoder.hlv_image_dsc.hlv_indev.hlv_layout.hlv_ll.hlv_log.hlv_math.hlv_matrix.hlv_mem.hlv_obj_class.hlv_obj_draw.hlv_obj_event.hlv_obj_pos.hlv_obj_property.hlv_obj_property_names.hlv_obj_scroll.hlv_obj_style.hlv_obj_style_gen.hlv_obj_tree.hlv_palette.hlv_profiler.hlv_profiler_builtin.hlv_sprintf.hlv_string.hlv_style.hlv_style_gen.hlv_style_properties.hlv_symbol_def.hlv_text.hlv_tick.hlv_timer.hlv_types.h
How is this guide?
Last updated on