Skip to content

Commit

Permalink
fix(chart) don't draw series lines with < 1 points
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Aug 9, 2021
1 parent a1b362c commit 655f42b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/extra/widgets/chart/lv_chart.c
Expand Up @@ -839,6 +839,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
if(_lv_area_intersect(&com_area, &obj->coords, clip_area) == false) return;

lv_chart_t * chart = (lv_chart_t *)obj;
if(chart->point_cnt < 1) return;

This comment has been minimized.

Copy link
@embeddedt

embeddedt Aug 9, 2021

Member

I think the condition needs to be chart->point_cnt < 2 to prevent the bug. See the following line:

p2.x = ((w * i) / (chart->point_cnt - 1)) + x_ofs;

If chart->point_cnt is 1 here, w * i will be divided by 0.

This comment has been minimized.

Copy link
@kisvegabor

kisvegabor Aug 9, 2021

Author Member

Uh, it was stupid 😅
Fixed here 6118d63


uint16_t i;
lv_point_t p1;
Expand Down

0 comments on commit 655f42b

Please sign in to comment.