# LVGL lv\_chart scatter plot example doesn't compile

**URL:** <https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041>\
**Category:** GIGA Display Shield\
**Created:** [July 24, 2026, 12:41am UTC](https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041 "2026-07-24T00:41:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkalucki](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jkalucki/32/1127833_2.png) [@jkalucki](https://forum.arduino.cc/u/jkalucki)\
**Post date:** [July 24, 2026, 12:41am UTC](https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041/1 "2026-07-24T00:41:28Z")

</div>

There are no examples in the Arduino IDE for LVGL LV\_CHART\_TYPE\_SCATTER. I've looked at a number of versions (v8.4, v9.0, v9.5) of the github repo for LVGL and lv\_example\_chart\_7.c ([lvgl/examples/widgets/chart/lv\_example\_chart\_7.c at release/v9.0 · lvgl/lvgl · GitHub](https://github.com/lvgl/lvgl/blob/release/v9.0/examples/widgets/chart/lv_example_chart_7.c)). All LVGL versions seem to have the same lv\_example\_chart\_7.c and all versions contain references to symbols that don't exist in the Arduino\_H7\_Video library. Compiling for GIGA and GIGA DISPLAY shield.

By some poking around, and stripping out missing features, I got the example plot working with static colors just fine. But I'm trying to manipulate scatter plot points in the same way as the demo to fade out older points. The example code is from a significantly different LVGL version.

This code cribbed from the examples and stripped down works great:

```arduino
  lv_obj_t *chart = lv_chart_create(grid);
  lv_obj_set_grid_cell(chart, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_STRETCH, 1, 1);
  lv_obj_set_size(chart, lv_obj_get_width(obj), lv_obj_get_height(obj));
  lv_obj_align(chart, LV_ALIGN_CENTER, 0, 0);
  lv_obj_add_event_cb(chart, draw_event_cb, LV_EVENT_DRAW_MAIN_BEGIN, NULL);
  lv_obj_set_style_line_width(chart, 0, LV_PART_ITEMS); /*Remove the lines*/

  lv_chart_set_type(chart, LV_CHART_TYPE_SCATTER);
  lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_X, CHART_X_MIN, CHART_X_MAX);
  lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, CHART_Y_MIN, CHART_Y_MAX);
  lv_chart_set_point_count(chart, GRAPH_LEN);
  lv_chart_set_div_line_count(chart, 8, 8);

  lv_chart_series_t *ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);

[...]

  lv_chart_set_next_value2(chart, ser, x, y);

```

This callback from the example is for some other version of LVGL:

```arduino
static void draw_event_cb(lv_event_t *e) {
   lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
    lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
    if(base_dsc->part == LV_PART_INDICATOR) {
        lv_obj_t * obj = lv_event_get_target(e);
        lv_chart_series_t * ser = lv_chart_get_series_next(obj, NULL);
        lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
        uint32_t cnt = lv_chart_get_point_count(obj);

        /*Make older value more transparent*/
        rect_draw_dsc->bg_opa = (LV_OPA_COVER * base_dsc->id2) / (cnt - 1);

        /*Make smaller values blue, higher values red*/
        int32_t * x_array = lv_chart_get_x_array(obj, ser);
        int32_t * y_array = lv_chart_get_y_array(obj, ser);
        /*dsc->id is the tells drawing order, but we need the ID of the point being drawn.*/
        uint32_t start_point = lv_chart_get_x_start_point(obj, ser);
        uint32_t p_act = (start_point + base_dsc->id2) % cnt; /*Consider start point to get the index of the array*/
        lv_opa_t x_opa = (x_array[p_act] * LV_OPA_50) / 200;
        lv_opa_t y_opa = (y_array[p_act] * LV_OPA_50) / 1000;

        rect_draw_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_RED),
                                               lv_palette_main(LV_PALETTE_BLUE),
                                               x_opa + y_opa);
    }
}

```

compiling:

```arduino
/Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino: In function 'void draw_event_cb(lv_event_t*)':
/Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:445:46: error: invalid use of incomplete type 'lv_draw_task_t {aka struct _lv_draw_task_t}'
     lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
                                              ^~
In file included from /Users/john/Documents/Arduino/libraries/lvgl/src/../src/lv_init.h:17:0,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/../lvgl.h:21,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/lvgl.h:16,
                 from /Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:3:
/Users/john/Documents/Arduino/libraries/lvgl/src/../src/misc/lv_types.h:121:16: note: forward declaration of 'lv_draw_task_t {aka struct _lv_draw_task_t}'
 typedef struct _lv_draw_task_t lv_draw_task_t;
                ^ ~~~~~~~~~~~~~~
/Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:445:48: error: invalid use of incomplete type 'lv_draw_task_t {aka struct _lv_draw_task_t}'
     lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
                                                ^ ~~~~~~~
In file included from /Users/john/Documents/Arduino/libraries/lvgl/src/../src/lv_init.h:17:0,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/../lvgl.h:21,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/lvgl.h:16,
                 from /Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:3:
/Users/john/Documents/Arduino/libraries/lvgl/src/../src/misc/lv_types.h:121:16: note: forward declaration of 'lv_draw_task_t {aka struct _lv_draw_task_t}'
 typedef struct _lv_draw_task_t lv_draw_task_t;
                ^ ~~~~~~~~~~~~~~
/Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:447:45: error: invalid conversion from 'void*' to 'lv_obj_t* {aka _lv_obj_t*}' [-fpermissive]
         lv_obj_t * obj = lv_event_get_target(e);
                          ~~~~~~~~~~~~~~~~~~~^~~
/Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:449:55: error: invalid use of incomplete type 'lv_draw_task_t {aka struct _lv_draw_task_t}'
         lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
                                                       ^~
In file included from /Users/john/Documents/Arduino/libraries/lvgl/src/../src/lv_init.h:17:0,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/../lvgl.h:21,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/lvgl.h:16,
                 from /Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:3:
/Users/john/Documents/Arduino/libraries/lvgl/src/../src/misc/lv_types.h:121:16: note: forward declaration of 'lv_draw_task_t {aka struct _lv_draw_task_t}'
 typedef struct _lv_draw_task_t lv_draw_task_t;
                ^ ~~~~~~~~~~~~~~
/Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:449:57: error: invalid use of incomplete type 'lv_draw_task_t {aka struct _lv_draw_task_t}'
         lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
                                                         ^ ~~~~~~~
In file included from /Users/john/Documents/Arduino/libraries/lvgl/src/../src/lv_init.h:17:0,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/../lvgl.h:21,
                 from /Users/john/Documents/Arduino/libraries/lvgl/src/lvgl.h:16,
                 from /Users/john/Documents/Arduino/giga-2core-main/giga-2core-main.ino:3:
/Users/john/Documents/Arduino/libraries/lvgl/src/../src/misc/lv_types.h:121:16: note: forward declaration of 'lv_draw_task_t {aka struct _lv_draw_task_t}'
 typedef struct _lv_draw_task_t lv_draw_task_t;
                ^ ~~~~~~~~~~~~~~

```

Not sure where to go next. I'm probably just missing something obvious with versions.

TIA

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [July 24, 2026, 1:44am UTC](https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041/2 "2026-07-24T01:44:15Z")

</div>

I assume the compile errors from the version you want to make work?

I downloaded the entire repo and tried the example. It fails on several statements, so it would appear the repo is flawed. Submitting an issue against the lvgl/lvgl repo should get a resolution.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [July 24, 2026, 9:45pm UTC](https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041/3 "2026-07-24T21:45:33Z")

</div>

Hi @jkalucki. I was not able to reproduce the fault. Please provide a complete sketch that will produce these errors when I compile it.

---

<div class="post-metadata">

**Author:** ![jkalucki](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jkalucki/32/1127833_2.png) [@jkalucki](https://forum.arduino.cc/u/jkalucki)\
**Post date:** [July 26, 2026, 9:32pm UTC](https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041/4 "2026-07-26T21:32:04Z")

</div>

I sorted it out. Thanks for the responses!

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [July 26, 2026, 9:34pm UTC](https://forum.arduino.cc/t/lvgl-lv-chart-scatter-plot-example-doesnt-compile/1453041/5 "2026-07-26T21:34:52Z")

</div>

You are welcome. I'm glad it is working now. Thanks for taking the time to post an update!
