Hello Dear friends.
I am working with charts in circular mode. I am looking for adding some space between the recent data and the oldest data. Now it does stick them together. What should I do to achieve this?
By which I mean to hide 3 to 5 old data and hide them away.
I was thinking about adding such feature but havenât done yet. You can do it by manually pre-deleting some points.
Just get the the array of the values with lv_chart_get_y_array(chart, ser1), set a pointâs value and also set the next 3 or 5 values to LV_CHART_POINT_NONE to add a gap.
So how can one get which place is the current pointing place (index) of the chart for the next value? It would get the array, but it is also important to know which place is, so one can change the value by hand.
@kisvegabor Iâve faced some issues and trying to find the source. It may have happend on my side, so when I got assured of the source of the problem, I would notify here.
The problem I have encountered is that in some cases it tries to tie the current point to some points on the grid lines.
Dear @kisvegabor
I know this is an old issue but I have found the symptom, I donât know if it is due to the origin or if it relies on the way I used the widget. Speaking about âline type chartâ in circular mode, following the code in https://github.com/lvgl/lvgl/blob/master/examples/widgets/chart/lv_example_chart_9.c,
if the space between points is considerable, for example about 10 points, the âvery oldâ point of the chart which will be updated by the next update command, tries to stick the newest data inserted into the graph. In this case, the graph ignores that the previous data in the chart is None, but would stick to the data that is not None.
@kisvegabor I know it is an old topic, but I have encountered this issue another time and now I can explain it more clear. Now I am using version 8.4.0 and I think the problem is the way the chart widget handles the start point to redraw the chart.
Consider that the chart has 512 data points. Chart have written 512 data in advance and it is in the redraw stage. Suppose in the redraw stage the last data have been written at index 200 and now you want to add another data. So in the redraw of the chart, data at index 201 is the newest one and consider you want to have non-drawing items of 8 points. In this case, the point at index 209 is the oldest data available in the series from the last redraw.
Now the problem arises. For example, if the newest data at index 201, would be 150, and the oldest data which is at index 209, would be 100, the widget library tries to stick to the last available data rather than LV_CHART_POINT_NONE. This way there would be a line drawn between level 150 to 100 in index 209. Now what I would expect is that it should have stuck to data at point 208 which is LV_CHART_POINT_NONE rather than considering data at 201 which is 150. I think the function draw_series_line for this concept may need reconsideration.
I havenât tested V9.1 but I think since the majority of the code concept is the same, this issue can be present in that version.
and in function draw_series_line(...) here is my suggestion
if(crowded_mode) {
if(ser->y_points[p_prev] != LV_CHART_POINT_NONE && ser->y_points[p_act] != LV_CHART_POINT_NONE) {
/*Draw only one vertical line between the min and max y-values on the same x-value*/
y_max = LV_MAX(y_max, p2.y);
y_min = LV_MIN(y_min, p2.y);
if(p1.x != p2.x) {
lv_coord_t y_cur = p2.y;
p2.x--; /*It's already on the next x value*/
p1.x = p2.x;
p1.y = y_min;
p2.y = y_max;
if(p1.y == p2.y) p2.y++; /*If they are the same no line will be drawn*/
lv_draw_line(draw_ctx, &line_dsc_default, &p1, &p2);
p2.x++; /*Compensate the previous x--*/
y_min = y_cur; /*Start the line of the next x from the current last y*/
y_max = y_cur;
}
}
else if(ser->y_points[p_prev] == LV_CHART_POINT_NONE && ser->y_points[p_act] != LV_CHART_POINT_NONE)
{
y_min = p2.y;
y_max = p2.y;
}
}
I dont fully understand what you say, but if you mean in centimeter, i use at070tn92 lcd which is a 7 inch lcd. Each pixel width is 0.1926mm. Which makes it to be 512x0.1926 = 98.61mm.