How to draw functions like sin/cos with lvgl

I have found few examples on how to draw function figures with LVGL, such as sin(x) or cos(x). I tried to draw function with charts, however, they are not smooth. Is any way LVGL can draw functions like plt.plot in Python?
code:

lv_obj_t *chart = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart, 400, 200);
lv_obj_align(chart, LV_ALIGN_CENTER, 0, 0);
lv_chart_set_point_count(chart, NUM_POINTS);
lv_chart_set_type(chart, LV_CHART_TYPE_SCATTER);
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y,-20, 20);
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_X,-2*PI, 2*PI);

lv_color_t color;
color.ch.alpha = 0.5;
color.ch.red = 230;
color.ch.green = 155;
lv_chart_series_t *series = lv_chart_add_series(chart, color,LV_CHART_AXIS_PRIMARY_X);

for(int i = 0; i < NUM_POINTS; i++) {
    float x = (float)i / NUM_POINTS * 2 * PI;
    float y = 20 * sin(FREQUENCY * x);
    //lv_chart_set_next_value2(chart, series, x,y);

}

while(1) {
    lv_task_handler();
    usleep(1000000 / 30); // Update every 30 frames per second
}  while(1) {
/* Periodically call the lv_task handler.
 * It could be done in a timer interrupt or an OS task too.*/
lv_timer_handler();
usleep(5 * 1000);

}‘’’

No expertise on the topic, but I guess you have to go for more data points like in the example.

Thx for sharing these examples!