Ngx-charts: How to update the data in line chart

Created on 14 Dec 2016  路  5Comments  路  Source: swimlane/ngx-charts

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
Shows the same data all the time in the plot

Expected behavior
Update the data, specifically the series.valuewhen list item is clicked

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ng2d3 version: x.x.x
    "ng2d3": "^2.0.0",

  • Angular version: 2.x.x
    "angular-cli": "1.0.0-beta.19-3",

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    Typescript, HTML

Most helpful comment

You need to pass it a new array in order for the change detection to trigger. The charts use immutable inputs.

Simplest way would be to just do results = [...results]. This will generate a new array and trigger the change detection. This has already been answered: https://github.com/swimlane/ngx-charts/issues/118

All 5 comments

@SikFar Why did you close the issue? Did you solve it, in which case how? I'm currently trying to figure out how to update the data in a line-chart but with no success.

You need to pass it a new array in order for the change detection to trigger. The charts use immutable inputs.

Simplest way would be to just do results = [...results]. This will generate a new array and trigger the change detection. This has already been answered: https://github.com/swimlane/ngx-charts/issues/118

Thanks @marjan-georgiev that worked!

Not 100% sure this is the full fix. The chart needs me to mouse over it, for it to update. Is there a way to update it without requiring the user to move the mouse over the chart to see the update?

Not 100% sure this is the full fix. The chart needs me to mouse over it, for it to update. Is there a way to update it without requiring the user to move the mouse over the chart to see the update?

I'm experiencing the same problem. Is there a way around this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amcdnl picture amcdnl  路  4Comments

cfremgen picture cfremgen  路  3Comments

jvbianchi picture jvbianchi  路  4Comments

merinshaji picture merinshaji  路  3Comments

faisalnet5 picture faisalnet5  路  3Comments