1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(example) chart example to add gap between the old and new data (#2565)

* fix(chart) draw line chart indicator (bullet)

There was a missing bullet if the previous point was LV_CHART_POINT_NONE

* feat(example) add chart example with gap in circular mode

* add missing prototype
This commit is contained in:
Gabor Kiss-Vamosi 2021-09-27 11:01:31 +02:00 committed by GitHub
parent 28e9593e58
commit 5565d5965a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#include "../../lv_examples.h"
#if LV_USE_CHART && LV_DRAW_COMPLEX && LV_BUILD_EXAMPLES
static void add_data(lv_timer_t * t)
{
lv_obj_t * chart = t->user_data;
lv_chart_series_t * ser = lv_chart_get_series_next(chart, NULL);
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
uint16_t p = lv_chart_get_point_count(chart);
uint16_t s = lv_chart_get_x_start_point(chart, ser);
lv_coord_t * a = lv_chart_get_y_array(chart, ser);
a[(s + 1) % p] = LV_CHART_POINT_NONE;
a[(s + 2) % p] = LV_CHART_POINT_NONE;
a[(s + 2) % p] = LV_CHART_POINT_NONE;
lv_chart_refresh(chart);
}
/**
* Circular line chart with gap
*/
void lv_example_chart_9(void)
{
/*Create a stacked_area_chart.obj*/
lv_obj_t * chart = lv_chart_create(lv_scr_act());
lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR);
lv_obj_set_size(chart, 200, 150);
lv_obj_center(chart);
lv_chart_set_point_count(chart, 30);
lv_chart_series_t * ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
/*Prefill with data*/
uint32_t i;
for(i = 0; i < 30; i++) {
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
}
lv_timer_create(add_data, 300, chart);
}
#endif

View File

@ -58,6 +58,7 @@ void lv_example_chart_5(void);
void lv_example_chart_6(void);
void lv_example_chart_7(void);
void lv_example_chart_8(void);
void lv_example_chart_9(void);
void lv_example_checkbox_1(void);
void lv_example_checkbox_2(void);