#include "../../lv_examples.h" #if LV_USE_CHART && LV_BUILD_EXAMPLES lv_obj_t * chart; lv_chart_series_t * ser1; static void event_handler(lv_event_t * e) { lv_event_code_t code = lv_event_get_code(e); if(code == LV_EVENT_CLICKED) { chart = lv_chart_create(lv_scr_act()); lv_obj_set_size(chart, 200, 150); lv_obj_center(chart); lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/ ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); lv_obj_del(chart); chart = lv_chart_create(lv_scr_act()); lv_obj_set_size(chart, 200, 150); lv_obj_center(chart); lv_chart_set_type(chart, LV_CHART_TYPE_SCATTER); /*Show lines and points too*/ lv_chart_set_point_count(chart, 600); ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); lv_obj_del(chart); } } void lv_example_chart_1(void) { lv_obj_t * btn1 = lv_btn_create(lv_scr_act()); lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_CLICKED, NULL); lv_obj_align(btn1, LV_ALIGN_TOP_MID, 0, 20); } #endif