Anychart js как обновить данные в графике

У меня есть следующий код:

function Display_values(array_values) {
  if (flag === 0) {
    // create data
    var data = array_values;

    // create a chart
    var chart = anychart.line();

    // create a line series and set the data
    var series = chart.line(data);

    // set scale mode
    chart.xScale().mode('continuous');

    // set the chart title
    chart.title("<?= $LANG['Table_name'] ?>");

    // set the titles of the axes
    var xAxis = chart.xAxis();
    // xAxis.title("Month");
    var yAxis = chart.yAxis();
    // yAxis.title("Sales, $");

    // set the container id
    chart.container("LinearGraphic");

    // initiate drawing the chart
    chart.draw();
    flag += 1;
  } else {
    series = array_values;
    chart.draw();
  }

}

Подскажите как я могу обновить данные в графике(перерисовать) уже после его создания?

P.S данный код выдает ошибку: Uncaught TypeError: Cannot read properties of undefined (reading 'draw')


Ответы (0 шт):