How do you enable scrolling over a chart?


I am tring to enable scrolling of the page when the user starts on a chart. This works on tables and tabview backgrounds

What MCU/Processor/Board and compiler are you using?

ESP32 - Arduino

What do you want to achieve?

I would like the tabvlew to scroll when you start swiping on a chart.

What have you tried so far?

Looking at the documentation and i cant see anything that relates to scroll/swipe.

Code to reproduce

static void create_tabSensors(lv_obj_t * parent);

lv_chart_series_t * ser1; 
lv_chart_series_t * ser2; 
lv_chart_series_t * ser3; 
lv_chart_series_t * ser4; 
lv_chart_series_t * ser5; 
lv_chart_series_t * ser6; 
lv_obj_t * chart;

void lv_loadTabs(lv_theme_t * th)
    th = lv_theme_get_current();    /*If `LV_THEME_LIVE_UPDATE  1` `th` is not used directly so get the real theme after set*/

    scr = lv_cont_create(NULL, NULL);

    lv_obj_t * tv = lv_tabview_create(scr, NULL);
    lv_obj_set_size(tv, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL)-38);
    lv_obj_set_pos(tv, 0, 0);

    //Leave the buttons at the top for now...
    //lv_tabview_set_btns_pos(tv, LV_TABVIEW_BTNS_POS_LEFT);
    lv_tabview_set_anim_time(tv, 0);

    lv_obj_t * tabSensors = lv_tabview_add_tab(tv, "Sensors");

static void create_tabSensors(lv_obj_t * parent)
    chart = lv_chart_create(parent, NULL);
    lv_chart_set_point_count(chart, 20);
    lv_obj_set_size(chart, LV_HOR_RES - 60, 150);
    lv_obj_align(chart, sensorTable, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
    lv_chart_set_type(chart, LV_CHART_TYPE_LINE);   /*Show lines*/
    lv_chart_set_series_opa(chart, LV_OPA_70);                            /*Opacity of the data series*/
    lv_chart_set_series_width(chart, 2);                                  /*Line width and point radious*/

    lv_chart_set_range(chart, 1200, 3000);

    /*Add two data series*/
    ser1 = lv_chart_add_series(chart, LV_COLOR_RED);
    ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN);
    ser3 = lv_chart_add_series(chart, LV_COLOR_BLUE);
    ser4 = lv_chart_add_series(chart, LV_COLOR_CYAN);
    ser5 = lv_chart_add_series(chart, LV_COLOR_YELLOW);
    ser6 = lv_chart_add_series(chart, LV_COLOR_LIME);

Screenshot and/or video

I cant upload a video.

Zip works , nope too big…

Try this: lv_obj_set_click(chart, false). The input events have to reach the tabview page and not get consumed by the chart for scrolling to work.

1 Like

Boom! you got it in one :slight_smile:

Thank you