carbon-charts icon indicating copy to clipboard operation
carbon-charts copied to clipboard

[Bug]: Heatmap chart view data as table cannot handle nulls

Open chrisdudley opened this issue 1 year ago • 0 comments

Application/Team

IBM API Connect

What happened?

The Heatmap chart in latest carbon charts (react) crashes when try to show as data table if any of the data values were null.

@carbon_charts-react.js?v=465cc5d7:8904 Uncaught TypeError: Cannot read properties of null (reading 'toLocaleString')
    at number (@carbon_charts-react.js?v=465cc5d7:8904:90)
    at @carbon_charts-react.js?v=465cc5d7:11460:9
    at Array.map (<anonymous>)
    at tR.getTabularDataArray (@carbon_charts-react.js?v=465cc5d7:11457:12)
    at qo.getModalHTML (@carbon_charts-react.js?v=465cc5d7:15626:204)
    at DocumentFragment.handleShowModal (@carbon_charts-react.js?v=465cc5d7:15614:259)
    at YB.dispatchEvent (@carbon_charts-react.js?v=465cc5d7:21948:98)
    at Object.clickFunction (@carbon_charts-react.js?v=465cc5d7:14366:53)
    at p0.triggerFunctionAndEvent (@carbon_charts-react.js?v=465cc5d7:14240:115)
    at HTMLButtonElement.<anonymous> (@carbon_charts-react.js?v=465cc5d7:14126:37)

We intentionally use nulls to pad data out for the time period a user has selected - even if we only actually have data for a subset of that time period. It renders the actual heatmap fine - but "show as data table" explodes.

Version

"@carbon/charts-react": "1.14.3",

Data & options used

Default options is sufficient. If any of the data points happens to have a null value then exporting the data table will fail.

  {
    date: '2023-10-26',
    hour: '23:00',
    value: null,
  },

Relevant log output

No response

StackBlitz example

https://stackblitz.com/edit/react-imtvrq-ryhwwc?file=src%2Fdata.js

What priority level would this be in your opinion?

P2

chrisdudley avatar Feb 26 '24 14:02 chrisdudley