Skip to content
Discussion options

You must be logged in to vote

@TWDBrob the issue isn't xAxisID, it's your getServiceChartData() function returning undefined elements in the datasets array.

your .map() only returns a dataset object when isServiceSelected() is true. when it's false, there's no explicit return, so the array slot is undefined. chart.js then iterates the datasets and tries to read .xAxisID on undefined:

// your map produces: [{ data, label, ... }, undefined, { data, label, ... }, undefined]
config.data.datasets.filter((d) => d.xAxisID === id)
//                                  ^ crashes on undefined element

fix: use .filter() before .map() so you never have undefined entries:

const getServiceChartData = () =>
  servicesReport['report-data'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TWDBrob
Comment options

Answer selected by TWDBrob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants