How to change the width and the color of the bar in the bar chart?

Important: unclear posts may not receive useful answers.

Description

Hi, I want to change the width and the color of the bar in the bar chart.

I look up the document of the V8.2 about chart. In the Parts and Styles, I see that " LV_PART_ITEMS Refers to the line or bar series." and “Bar chart: The typical background properties are used to style the bars.” are related.

So I use lv_obj_set_style_bg_color() and lv_obj_set_style_width to achieve my goal, but I failed.

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

What LVGL version are you using?

V8.2

What do you want to achieve?

What have you tried so far?

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:

lv_obj_t *chart = lv_chart_create(rt_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_bg_color(chart, lv_palette_main(LV_PALETTE_GREEN), LV_PART_ITEMS);
lv_obj_set_style_width(chart, 10, LV_PART_ITEMS);

Screenshot and/or video

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

@kisvegabor

Hi,

It’s really not documented correctly. Please try this:

    lv_obj_set_style_pad_column(chart, 0, LV_PART_ITEMS);   /*Space between columns of the same index*/
    lv_obj_set_style_pad_column(chart, 0, LV_PART_MAIN);    /*Space between columns of the adjacent index*/

If it works well for you, I’ll update the docs.

Thank you. That’s what I want.

Great, I updated the docs here: docs(chart): describe how to set the space between columns · lvgl/lvgl@746917d · GitHub