Ngx-charts: Bug(tree map): 'Cannot read property 'filter' of undefined'

Created on 3 Apr 2017  路  7Comments  路  Source: swimlane/ngx-charts

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

[x] bug report 
[ ] feature request
[ ] support request

Current behavior
The tree map component will crash if given an empty data collection

Expected behavior
The component shouldn't crash. Instead, it shouldn't render any information/elements

Reproduction of the problem
https://plnkr.co/edit/K9aaZWwZWkqxXDWZFgOo?p=preview

What is the motivation / use case for changing the behavior?
The other chart components have no problems to handle empty data collections. I would expect the same of the tree map component

  • ngx-charts version:
  • 4.x.x (local project)
  • Latest version in the plnkr

  • Angular version:

  • 2.4.x (local project)
  • Latest version in the plnkr
Bug Accept PRs Backlog Med

Most helpful comment

We will fix this. In the meantime, you can also just hide the chart with *ngIf until the data is ready.

All 7 comments

Same error +1

I have the same bug implementing tree map chart on angular 2, any suggestions to solve this?

I have a solution:
Init your chartData link that:
public chartData = [{ 'name': 'init', 'value': 0 }];
and refresh after push in array link that:

this.chartData.push({ 'name': varStr, 'value': varNumber});
this.chartData = [...this._chartData];

I think it's missing a condition on the empty array

We will fix this. In the meantime, you can also just hide the chart with *ngIf until the data is ready.

I'm having this problem. Has it been fixed in any version?

@williangd what version are you using? I believe this was addressed in 7.3.0.

Please reopen if this is still an issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amcdnl picture amcdnl  路  4Comments

lokeshdaiya picture lokeshdaiya  路  3Comments

achimha picture achimha  路  3Comments

DZDomi picture DZDomi  路  4Comments

stephanrauh picture stephanrauh  路  4Comments