fix(chart): fix rounding error in lv_chart_get_point_pos_by_id
fixes #4064
This commit is contained in:
@@ -299,17 +299,17 @@ void lv_chart_get_point_pos_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint1
|
|||||||
int32_t block_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
int32_t block_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||||
LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||||
lv_coord_t block_w = (w - ((chart->point_cnt - 1) * block_gap)) / chart->point_cnt;
|
lv_coord_t block_w = (w - ((chart->point_cnt - 1) * block_gap)) / chart->point_cnt;
|
||||||
lv_coord_t col_w = block_w / ser_cnt;
|
lv_coord_t col_w = (block_w - (ser_cnt - 1) * ser_gap) / ser_cnt;
|
||||||
|
// p_out->x = (int32_t)((int32_t)w * id) / chart->point_cnt;
|
||||||
p_out->x = (int32_t)((int32_t)w * id) / chart->point_cnt;
|
|
||||||
|
|
||||||
|
p_out->x = (int32_t)((int32_t)(w - block_w) * id) / (chart->point_cnt - 1);
|
||||||
lv_chart_series_t * ser_i = NULL;
|
lv_chart_series_t * ser_i = NULL;
|
||||||
_LV_LL_READ_BACK(&chart->series_ll, ser_i) {
|
_LV_LL_READ_BACK(&chart->series_ll, ser_i) {
|
||||||
if(ser_i == ser) break;
|
if(ser_i == ser) break;
|
||||||
p_out->x += col_w;
|
p_out->x += col_w + ser_gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_out->x += (col_w - ser_gap) / 2;
|
p_out->x += col_w / 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p_out->x = 0;
|
p_out->x = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user