How to draw a translucent rectangle over a chart


I want a translucent rectangle to be drawn on top of all chart elements

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


What LVGL version are you using?


What do you want to achieve?

Overlay any drawings on the chart

What have you tried so far?

I start drawing on chart on LV_EVENT_DRAW_PART_END event.
I set transparency draw_rect_dsc.bg_opa = LV_OPA_10; But the rectangle is not at the top level and is not transparent.

Code to reproduce

static void cb_Chart(lv_event_t *e)
lv_obj_t *obj = lv_event_get_target(e);
lv_obj_draw_part_dsc_t *dsc = lv_event_get_draw_part_dsc(e);

   lv_draw_rect_dsc_t draw_rect_dsc;
   draw_rect_dsc.bg_opa = LV_OPA_10;
   draw_rect_dsc.bg_color = lv_color_hex(0xff0000);

  lv_area_t a;
  a.x1 = obj->coords.x1 + 20;
  a.y1 = obj->coords.y1 + 20;
  a.x2 = obj->coords.x1 + 40;
  a.y2 = obj->coords.y1 + 80;
  lv_draw_rect(dsc->draw_ctx, &draw_rect_dsc, &a);


in main code

lv_obj_add_event_cb(Chart, cb_Chart, LV_EVENT_DRAW_PART_END, NULL);

Screenshot and/or video