From 8106c2f348c96b44a4f7676c05244b39797023ae Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 16 Mar 2021 12:29:21 +0100 Subject: [PATCH] feat(chart): add lv_chart_set_series_color --- src/lv_widgets/lv_chart.c | 10 ++++++++++ src/lv_widgets/lv_chart.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index c9213ca07..660126097 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -390,6 +390,16 @@ void lv_chart_hide_series(lv_obj_t * chart, lv_chart_series_t * series, bool hid lv_chart_refresh(chart); } + +void lv_chart_set_series_color(lv_obj_t * chart, lv_chart_series_t * series, lv_color_t color) +{ + LV_ASSERT_OBJ(chart, MY_CLASS); + LV_ASSERT_NULL(series); + + series->color = color; + lv_chart_refresh(chart); +} + void lv_chart_set_x_start_point(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id) { LV_ASSERT_OBJ(obj, MY_CLASS); diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index bd1b22ac8..0d165955a 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -265,6 +265,14 @@ void lv_chart_remove_series(lv_obj_t * obj, lv_chart_series_t * series); */ void lv_chart_hide_series(lv_obj_t * chart, lv_chart_series_t * series, bool hide); +/** + * Change the color of a series + * @param obj pointer to a chart object. + * @param series pointer to a series object + * @param color the new color of the series + */ +void lv_chart_set_series_color(lv_obj_t * chart, lv_chart_series_t * series, lv_color_t color); + /** * 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.