diff --git a/docs/widgets/extra/chart.md b/docs/widgets/extra/chart.md index 90275425b..9f43432a4 100644 --- a/docs/widgets/extra/chart.md +++ b/docs/widgets/extra/chart.md @@ -140,7 +140,7 @@ The possible values of `dir` `LV_DIR_NONE/RIGHT/UP/LEFT/DOWN/HOR/VER/ALL` or th - vertical line `clip_area`, `p1`, `p2` (points of the line), `line_dsc`, `part` - horizontal line `clip_area`, `p1`, `p2` (points of the line), `line_dsc`, `part` - point `clip_area`, `draw_area` (points of the line), `rect_dsc`, `part` - - `LV_PART_MAIN` (the division lines) `clip_area`, `id` (index of the line), `p1`, `p2` (points of the line), `line_dsc`, `part` + - `LV_PART_MAIN` (the division lines) `clip_area`, `id` (index of the line), `p1`, `p2` (points of the line), `line_dsc`, `part`. Besides events for every line, an event is sent before the first line and after the last line with `id=0xFFFFFFFF`, `p1 = NULL` and `p2 = NULL`. It can be used to add/remove masks, or draw special division lines. Learn more about [Events](/overview/event). diff --git a/src/extra/widgets/chart/lv_chart.c b/src/extra/widgets/chart/lv_chart.c index 6face3dba..b5d1f1989 100644 --- a/src/extra/widgets/chart/lv_chart.c +++ b/src/extra/widgets/chart/lv_chart.c @@ -755,6 +755,10 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area) lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area); obj_draw_dsc.line_dsc = &line_dsc; obj_draw_dsc.part = LV_PART_MAIN; + obj_draw_dsc.id = 0xFFFFFFFF; + obj_draw_dsc.p1 = NULL; + obj_draw_dsc.p2 = NULL; + lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &obj_draw_dsc); lv_opa_t border_opa = lv_obj_get_style_border_opa(obj, LV_PART_MAIN); lv_coord_t border_w = lv_obj_get_style_border_width(obj, LV_PART_MAIN); @@ -775,7 +779,7 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area) } for(i = i_start; i < i_end; i++) { - p1.y = (int32_t)((int32_t)(h - line_dsc.width) * i) / (chart->hdiv_cnt - 1); + p1.y = (int32_t)((int32_t)h * i) / (chart->hdiv_cnt - 1); p1.y += y_ofs; p2.y = p1.y; @@ -801,7 +805,7 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area) } for(i = i_start; i < i_end; i++) { - p1.x = (int32_t)((int32_t)(w - line_dsc.width) * i) / (chart->vdiv_cnt - 1); + p1.x = (int32_t)((int32_t)w * i) / (chart->vdiv_cnt - 1); p1.x += x_ofs; p2.x = p1.x; @@ -814,6 +818,12 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area) lv_event_send(obj, LV_EVENT_DRAW_PART_END, &obj_draw_dsc); } } + + obj_draw_dsc.id = 0xFFFFFFFF; + obj_draw_dsc.p1 = NULL; + obj_draw_dsc.p2 = NULL; + lv_event_send(obj, LV_EVENT_DRAW_PART_END, &obj_draw_dsc); + } static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)