fix(chart): fix last point not drawn in scatter chart (#7665)
Co-authored-by: Gregor Stemme <gregor.stemme@Sartorius.com>
This commit is contained in:
@@ -1037,8 +1037,7 @@ static void draw_series_scatter(lv_obj_t * obj, lv_layer_t * layer)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*Don't draw the first point. A second point is also required to draw the line*/
|
||||
if(i != 0) {
|
||||
if(i != 0) { /*Don't draw line *to* the first point.*/
|
||||
lv_area_t point_area;
|
||||
point_area.x1 = (int32_t)line_dsc.p1.x - point_w;
|
||||
point_area.x2 = (int32_t)line_dsc.p1.x + point_w;
|
||||
@@ -1046,10 +1045,10 @@ static void draw_series_scatter(lv_obj_t * obj, lv_layer_t * layer)
|
||||
point_area.y2 = (int32_t)line_dsc.p1.y + point_h;
|
||||
|
||||
if(ser->y_points[p_prev] != LV_CHART_POINT_NONE && ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
line_dsc.base.id2 = i;
|
||||
line_dsc.base.id2 = i - 1;
|
||||
lv_draw_line(layer, &line_dsc);
|
||||
if(point_w && point_h) {
|
||||
point_dsc_default.base.id2 = i;
|
||||
point_dsc_default.base.id2 = i - 1;
|
||||
lv_draw_rect(layer, &point_dsc_default, &point_area);
|
||||
}
|
||||
}
|
||||
@@ -1058,7 +1057,7 @@ static void draw_series_scatter(lv_obj_t * obj, lv_layer_t * layer)
|
||||
}
|
||||
|
||||
/*Draw the last point*/
|
||||
if(i == chart->point_cnt) {
|
||||
if(i == chart->point_cnt - 1) {
|
||||
|
||||
if(ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
lv_area_t point_area;
|
||||
|
||||
BIN
tests/ref_imgs/widgets/chart_scatter.png
Normal file
BIN
tests/ref_imgs/widgets/chart_scatter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
tests/ref_imgs_vg_lite/widgets/chart_scatter.png
Normal file
BIN
tests/ref_imgs_vg_lite/widgets/chart_scatter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -193,4 +193,23 @@ void test_draw_task_hooking(void)
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/chart_bar_draw_hook.png");
|
||||
}
|
||||
|
||||
void test_chart_scatter(void)
|
||||
{
|
||||
lv_obj_center(chart);
|
||||
lv_obj_set_size(chart, LV_PCT(100), LV_PCT(100));
|
||||
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_SCATTER);
|
||||
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_X, 50, 100);
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 20);
|
||||
|
||||
lv_chart_set_point_count(chart, 3);
|
||||
lv_chart_series_t * ser = lv_chart_add_series(chart, red_color, LV_CHART_AXIS_PRIMARY_Y);
|
||||
lv_chart_set_next_value2(chart, ser, 50, 10);
|
||||
lv_chart_set_next_value2(chart, ser, 75, 12);
|
||||
lv_chart_set_next_value2(chart, ser, 100, 20);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/chart_scatter.png");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user