45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
|
#include "../../lv_examples.h"
|
||
|
#if LV_USE_CHART && LV_BUILD_EXAMPLES
|
||
|
|
||
|
void lv_example_chart_1(void)
|
||
|
{
|
||
|
/*Create a chart*/
|
||
|
lv_obj_t * 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_LINE); /*Show lines and points too*/
|
||
|
|
||
|
/*Add two data series*/
|
||
|
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
|
||
|
lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_SECONDARY_Y);
|
||
|
|
||
|
/*Set the next points on 'ser1'*/
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 10);
|
||
|
lv_chart_set_next_value(chart, ser1, 30);
|
||
|
lv_chart_set_next_value(chart, ser1, 70);
|
||
|
lv_chart_set_next_value(chart, ser1, 90);
|
||
|
|
||
|
/*Directly set points on 'ser2'*/
|
||
|
ser2->y_points[0] = 90;
|
||
|
ser2->y_points[1] = 70;
|
||
|
ser2->y_points[2] = 65;
|
||
|
ser2->y_points[3] = 65;
|
||
|
ser2->y_points[4] = 65;
|
||
|
ser2->y_points[5] = 65;
|
||
|
ser2->y_points[6] = 65;
|
||
|
ser2->y_points[7] = 65;
|
||
|
ser2->y_points[8] = 65;
|
||
|
ser2->y_points[9] = 65;
|
||
|
|
||
|
lv_chart_refresh(chart); /*Required after direct set*/
|
||
|
}
|
||
|
|
||
|
#endif
|