vladi
January 2, 2023, 8:30pm
1
Working with lv_chart in SLS v1.1.1:
// ui_ChartBat common definitions
lv_chart_set_type(ui_ChartBat, LV_CHART_TYPE_SCATTER);// by (x,y) coord
lv_chart_set_update_mode(ui_ChartBat,LV_CHART_UPDATE_MODE_SHIFT); ser1=lv_chart_add_series(ui_ChartBat,lv_palette_main(LV_PALETTE_RED),LV_CHART_AXIS_PRIMARY_Y);
lv_chart_set_point_count(ui_ChartBat,101);
lv_chart_set_div_line_count(ui_ChartBat,6,11);// кол-во разделительных линий x,y
// ui_ChartBat Y axis
lv_chart_set_range(ui_ChartBat,LV_CHART_AXIS_PRIMARY_Y,0,20);
lv_chart_set_axis_tick(ui_ChartBat,LV_CHART_AXIS_PRIMARY_Y,10,5,6,4,true,50);
// ui_ChartBat X axis
lv_chart_set_range(ui_ChartBat,LV_CHART_AXIS_PRIMARY_X,0,100);
lv_chart_set_axis_tick(ui_ChartBat,LV_CHART_AXIS_PRIMARY_X,10,5,11,10,true,50);
How I can ‘clear’ the chart (all points) for the SCATTER type? I need to clear the x and y points.
Trying the following:
lv_chart_set_all_value clears y points only.
My idea of
for(i=0;i<=PointXnum;i++){ser1->y_points[i]=0;ser1->x_points[i]=0;}
working bad for the first point.
vladi
January 2, 2023, 8:40pm
2
Hot fix:
lv_chart_remove_series(ui_ChartBat,ser1);// clear old plot
ser1 = lv_chart_add_series(ui_ChartBat,lv_palette_main(LV_PALETTE_RED),LV_CHART_AXIS_PRIMARY_Y);
Is this a good solution? However, lv_chart_refresh runnig a bit later…
It should work
lv_chart_set_all_value(chart, ser, LV_CHART_POINT_NONE);
LV_CHART_POINT_NONE
is not the same as 0
, as it means “do not display that value”.
vladi
January 3, 2023, 11:39am
4
In other words, is it right approch:
If we need to delete all the SCATTER points, we should use add/remove series functions.
If we need to only hide the points we can use lv_chart_set_all_value(chart, ser, LV_CHART_POINT_NONE).
vladi
January 3, 2023, 2:58pm
5
And may be last question: how to draw connecting dots could be disable? If number of points is to big, the dots not needed anymore, I think.
What do you mean by delete points? What is difference between hide and delete?
You can hide the dots with: lv_obj_set_style_size(chart, 0, LV_PART_INDICATOR);
vladi
January 5, 2023, 3:51pm
7
When we delete it mean all points cannot be displayed, not keeped anywhere in LVGL variables, cannot be restored anymore. The ‘hide’ means it currently not displayed, but may be displayed later if necessary.
Hope, to delete points it need to remove series.
The next question attached…
screen.rar (798.0 KB)