How to make the major ticks center the bars of the chart ?

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


Hi, I draw a bar chart that is 255*120. But I found that the major ticks don`t center the bars of the chart.

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

What LVGL version are you using?


What do you want to achieve?

I want to make the major ticks center the bars of the chart.

What have you tried so far?

I tried to decrese the numbers of the bars in the bar chart, and found that when the number of the bars is small, the major ticks center the bars of the chart.
So is there any other way?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static lv_coord_t A_phase_data[] = {32,35,38,41,44,47,49,52,54,56,58,60,61,62,63,63};

lv_obj_t *chart = chart = lv_chart_create(harmonic_wave_page);
lv_obj_set_size(chart, 255, 120);
lv_obj_align_to(chart, esc_btn, LV_ALIGN_OUT_TOP_LEFT, 25, -25);
lv_obj_set_style_pad_column(chart, 0, LV_PART_MAIN);

lv_chart_set_type(chart, LV_CHART_TYPE_BAR);
lv_chart_set_point_count(chart, 16);

static lv_chart_series_t *A_phase_ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_set_ext_y_array(chart, A_phase_ser, A_phase_data);

lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 5, 0, 16, 1, true, 50);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.



I’ve pushed a fix to master.