diff --git a/src/widgets/chart/lv_chart.c b/src/widgets/chart/lv_chart.c index 5788a56177..d4bcd71c06 100644 --- a/src/widgets/chart/lv_chart.c +++ b/src/widgets/chart/lv_chart.c @@ -548,6 +548,16 @@ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_di return cursor; } +void lv_chart_remove_cursor(lv_obj_t * obj, lv_chart_cursor_t * cursor) +{ + LV_ASSERT_OBJ(obj, MY_CLASS); + LV_ASSERT_NULL(cursor); + + lv_chart_t * chart = (lv_chart_t *)obj; + lv_ll_remove(&chart->cursor_ll, cursor); + lv_free(cursor); +} + void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * pos) { LV_ASSERT_NULL(cursor); diff --git a/src/widgets/chart/lv_chart.h b/src/widgets/chart/lv_chart.h index 34903cfb43..64b9ea5f43 100644 --- a/src/widgets/chart/lv_chart.h +++ b/src/widgets/chart/lv_chart.h @@ -252,6 +252,13 @@ lv_chart_series_t * lv_chart_get_series_next(const lv_obj_t * chart, const lv_ch */ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_dir_t dir); +/** + * Remove a cursor + * @param obj pointer to chart object + * @param cursor pointer to the cursor + */ +void lv_chart_remove_cursor(lv_obj_t * obj, lv_chart_cursor_t * cursor); + /** * Set the coordinate of the cursor with respect to the paddings * @param chart pointer to a chart object