Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to redraw chart after data change. #15

Open
morrica opened this issue Aug 25, 2019 · 0 comments
Open

How to redraw chart after data change. #15

morrica opened this issue Aug 25, 2019 · 0 comments

Comments

@morrica
Copy link

morrica commented Aug 25, 2019

I am unable to redraw the chart after updating the TableData. I believe this is possible with straight modern_charts using the chart.draw(table, options) function, but I can't get access to the Chart object using angular_modern_charts Components.

I added the following update method to alter the column data to the usage example but I can't figure out how to redraw the chart without creating an entirely new barData object. Calling it appears to alter the data but the chart is not updated.

void update() {
    Random random = Random();
    double newValue = random.nextInt(500).roundToDouble();
    log.info("Adding $newValue to chart.");

    DataTable dataTable = barData.encoded;

    DataColumnCollection columns = dataTable.columns;
    columns.forEach((column) {
      log.info('Column ${column.index} = ${column.name}');
    });

    DataRowCollection rows = dataTable.rows;
    rows.forEach((row) {
      log.info('Row ${row.index} = ${row.toList()}');
    });

    rows[2][2] = newValue;
    log.info('last = ${rows.last.toList()}');

    _changeDetectorRef.markForCheck();
    _changeDetectorRef.detectChanges();
  }

How can I trigger a redraw of the chart based on the new data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant