How to make asix labels longer?

Description

I`m trying to setup X axis labels of my chart. Labels show time and date. They are displayed only partially, because they are too long. E.g. “14:45:30\n23.03.2024” are “14:45:30\n23.03.”

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

Visual Studio Code + PlatformIO, ESP32-S3 (ESP32-S3-DevKitC-1)

What LVGL version are you using?

8.3.6

What do you want to achieve?

Is there a way to increase the maximum length of asix labels?

What have you tried so far?

Code to reproduce

the chartXLabels is

std::vector<std::string> chartXLabels;

that is the part that sets the labels

static void Chart_draw_event_cb(lv_event_t *e)
{
  lv_obj_draw_part_dsc_t *dsc = lv_event_get_draw_part_dsc(e);

  // Check what part we are updating. Only proceed if we are updating one of the tick label(s)
  if (!lv_obj_draw_part_check_type(dsc, &lv_chart_class, LV_CHART_DRAW_PART_TICK_LABEL))
    return;

  // Check this is a callback for a major tick (minor ticks have 0 here)
  if (dsc->text == NULL)
    return;

  if (dsc->id == LV_CHART_AXIS_PRIMARY_X && dsc->value < chartXLabels.size())
  {
    //uint32_t lenght = chartXLabels[dsc->value].size();
    lv_snprintf(dsc->text, dsc->text_length, "%s", chartXLabels[dsc->value].c_str());
  }
}

Show image try change margins

On the display it looks like this:
Always max 14 letters + \n + end of string.
dsc->text_length is always 16.
Is there a way to make is more?

1 Like

Through your prompt and reviewing the code in lv_chart. c, I have discovered
#define LV_CHART_LABEL_MAX_TEXT_LENGTH 16

That`s it. I changed it and full text is displayed. Thank you.