Bar Chart lv_example_4 does not properly support LV_CHART_UPDATE_SHIFT

My assumptions:
The lv_chart.c source appears to support LV_CHART_UPDATE_SHIFT.
The coloration using fill_dsc->color is a valid technique.

The original lv_example_chart_4 appears to work when displayed statically.

I modified lv_example_chart_4 (I am new, how do you properly embed source code in a Post?)

The modification was to remove the initialization for loop, replace it with a timed add_data procedure. Also, lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR); was added.

This appears to work properly as data and coloration are in sync and change from the left.

Then change lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_SHIFT);

The values for each bar is shifted in from the right, however, the coloration cycles in from the left. The values are shifted but the fill_dsc->color continues as if it were circular update mode.

The problem: the fill_dsc->color object is not properly implemented for LV_CHART_UPDATE_MODE_SHIFT.

#include “…/…/lv_examples.h”

#if LV_USE_CHART && LV_DRAW_SW_COMPLEX && LV_BUILD_EXAMPLES

static void add_data(lv_timer_t* t)
{
uint32_t value = lv_rand(00, 100);
lv_obj_t* chart = lv_timer_get_user_data(t);
lv_chart_series_t* ser = lv_chart_get_series_next(chart, NULL);

lv_chart_set_next_value(chart, ser, value);
lv_chart_refresh(chart);

}

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 = lv_draw_task_get_draw_dsc(draw_task);

if (base_dsc->part != LV_PART_ITEMS) {
    return;
}

lv_draw_fill_dsc_t* fill_dsc = lv_draw_task_get_fill_dsc(draw_task);
if (fill_dsc) {
    lv_obj_t* chart = lv_event_get_target(e);
    int32_t* y_array = lv_chart_get_y_array(chart, lv_chart_get_series_next(chart, NULL));
    int32_t v = y_array[base_dsc->id2];

    uint32_t ratio = v * 255 / 100;
    fill_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_GREEN), lv_palette_main(LV_PALETTE_RED), ratio);
}

}

//Recolor the bars of a chart based on their value

void lv_example_chart_4(void)
{
//Create a chart1
lv_obj_t* chart = lv_chart_create(lv_screen_active());
lv_chart_set_type(chart, LV_CHART_TYPE_BAR);
lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR);
lv_chart_set_point_count(chart, 24);
lv_obj_set_style_pad_column(chart, 2, 0);
lv_obj_set_size(chart, 260, 160);
lv_obj_center(chart);

lv_chart_series_t* ser = lv_chart_add_series(chart, lv_color_hex(0xff0000), LV_CHART_AXIS_PRIMARY_Y);
lv_obj_add_event_cb(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(chart, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);

lv_timer_create(add_data, 250, chart);

}

#endif

#include "../../lv_examples.h"

#if LV_USE_CHART && LV_DRAW_SW_COMPLEX && LV_BUILD_EXAMPLES

static void add_data(lv_timer_t* t)
{
    uint32_t value = lv_rand(00, 100);
    lv_obj_t* chart = lv_timer_get_user_data(t);
    lv_chart_series_t* ser = lv_chart_get_series_next(chart, NULL);

    lv_chart_set_next_value(chart, ser, value);
    lv_chart_refresh(chart);
}

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 = lv_draw_task_get_draw_dsc(draw_task);

    if (base_dsc->part != LV_PART_ITEMS) {
        return;
    }

    lv_draw_fill_dsc_t* fill_dsc = lv_draw_task_get_fill_dsc(draw_task);
    if (fill_dsc) {
        lv_obj_t* chart = lv_event_get_target(e);
        int32_t* y_array = lv_chart_get_y_array(chart, lv_chart_get_series_next(chart, NULL));
        int32_t v = y_array[base_dsc->id2];

        uint32_t ratio = v * 255 / 100;
        fill_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_GREEN), lv_palette_main(LV_PALETTE_RED), ratio);
    }
}

/**
 * Recolor the bars of a chart based on their value
 */
void lv_example_chart_4(void)
{
    /*Create a chart1*/
    lv_obj_t* chart = lv_chart_create(lv_screen_active());
    lv_chart_set_type(chart, LV_CHART_TYPE_BAR);
    lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR);
    lv_chart_set_point_count(chart, 24);
    lv_obj_set_style_pad_column(chart, 2, 0);
    lv_obj_set_size(chart, 260, 160);
    lv_obj_center(chart);

    lv_chart_series_t* ser = lv_chart_add_series(chart, lv_color_hex(0xff0000), LV_CHART_AXIS_PRIMARY_Y);
    lv_obj_add_event_cb(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
    lv_obj_add_flag(chart, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);

    lv_timer_create(add_data, 250, chart);
}

#endif