I was doing some skepts and realised that in some cases being able to change the Chart shifting direction might be usefull
For example having two diferent charts over eachother but about diferent Values
I was doing some skepts and realised that in some cases being able to change the Chart shifting direction might be usefull
For example having two diferent charts over eachother but about diferent Values
I also found this useful. Do you have time and liking to implement it?
I would like to implement it, but for now, I have two projects going on simultaneously, so I won’t have much time to dedicate to it. Instead, I will use two charts overlaid on each other and modify the position of the text within the LVGL internals. I will make the code changes in the internals available here.
I’m not sure what the specific goal was, but if it is to make a simple automatically-shifting chart go from left-to-right instead of the default right-to-left…it’s actually pretty simple.
My work is on LVGL 8.4.0, but this should apply to the newer version as well.
Firstly, I noticed the code in “lv_chart_set_next_value” ( lvgl/src/widgets/chart/lv_chart.c at 20bbe4a8ac33b2c8d8f44015aa1838c9e17f40cb · lvgl/lvgl · GitHub )
All it really does is round-robin the data through the chart (setting the Series Start point to avoid having to shift data through the entire buffer).
That means that it is very simple to reverse the direction of this function without changing literally anything else. Instead of calling “lv_chart_set_next_value”, roll the functionality yourself like this:
if (ser->start_point == 0) {ser->start_point = NUM_CHART_POINTS - 1;} else {ser->start_point--;}
ser->y_points[ser->start_point] = value;
lv_obj_invalidate(chart);
where “ser” = chart series, and “chart” = chart object. “NUM_CHART_POINTS” is self explanatory; the original routine could pull max points out of the chart object, but for some reason that property doesn’t seem available to the end user.
The last line is basically what the internal “invalidate_point” does with a full shift anyway.
Easy peasy