有项目需求:图表上的拐点要求背景透明。
自己实验想让折线图上面的点变成透明或其他颜色,发现设置不起作用。点的颜色与线的颜色无法分开。求教各位哪里设置的有问题?
static lv_chart_series_t *ser1;
lv_obj_t* uchart1=lv_chart_create(chart1_cotain);
lv_chart_set_type(uchart1,LV_CHART_TYPE_LINE);//折现方式
lv_chart_set_point_count(uchart1,80);
lv_chart_set_range(uchart1,LV_CHART_AXIS_PRIMARY_X,0,100);
lv_chart_set_update_mode(uchart1,LV_CHART_UPDATE_MODE_CIRCULAR);//数据更新方式
lv_chart_set_div_line_count(uchart1,4,10);//表格网格线
/*添加显示数据 */
ser1=lv_chart_add_series(uchart1,lv_color_hex(0xff0000),LV_CHART_AXIS_PRIMARY_Y);
lv_obj_set_style_line_width(uchart1,2,LV_PART_ITEMS);//设置线宽
lv_obj_set_style_line_color(uchart1,lv_color_hex(0x008000),LV_PART_ITEMS);//不起作用
lv_obj_set_style_size(uchart1,10,10,LV_PART_INDICATOR);//设置点大小
lv_obj_set_style_border_width(uchart1,1,LV_PART_INDICATOR);
lv_obj_set_style_border_color(uchart1,lv_color_hex(0x00000),LV_PART_INDICATOR);
/*表格绘制 */
lv_obj_add_flag(uchart1,LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_obj_add_event_cb(uchart1,chart1_draw_event_cb,LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS,NULL);
/*设定一个定时器,每300ms更新表格数据 lv_timer_t *chart1Time=*/
lv_timer_create(uchart1Time_cb,300,uchart1);
//chart1数据更新回调
static void chart1_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);
lv_obj_t *obj=lv_event_get_target(e);
// if(base_dsc->part==LV_PART_INDICATOR)
// {
// lv_draw_rect_dsc_t *rect_draw_dsc=lv_draw_task_get_draw_dsc(draw_task);
// rect_draw_dsc->bg_opa=LV_OPA_100;
// rect_draw_dsc->bg_color=lv_color_hex(0xb37979);
// rect_draw_dsc->border_width=1;//设置不起作用
// rect_draw_dsc->border_color=lv_color_hex(0x00ff00);//设置不起作用
// }
lv_chart_refresh(obj);
}
//chart1数据更新定时器回调
static void uchart1Time_cb(lv_timer_t *timer)
{
lv_obj_t *chart=(lv_obj_t *)lv_timer_get_user_data(timer);
lv_chart_set_next_value(chart,ser1,lv_rand(1,99));
}
设置线宽可以,设置线的颜色不行,点的颜色和线的颜色始终保持一致,怎么将线的颜色与点的颜色分开?