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

Stacked timeseries scale with parsing disabled throws TypeError #8932

Closed
TinfoilPancakes opened this issue Apr 18, 2021 · 3 comments · Fixed by #8934
Closed

Stacked timeseries scale with parsing disabled throws TypeError #8932

TinfoilPancakes opened this issue Apr 18, 2021 · 3 comments · Fixed by #8934
Milestone

Comments

@TinfoilPancakes
Copy link
Contributor

TinfoilPancakes commented Apr 18, 2021

Expected Behavior

Should display a stacked timeseries chart with 1 or more datasets.

Current Behavior

Calls to Chart.update() fail resulting in Uncaught TypeError: Cannot read property 'length' of undefined

Full Trace:

Uncaught TypeError: Cannot read property 'length' of undefined
    at updateStacks (chart.js:2975)
    at BarController.parse (chart.js:3182)
    at BarController._resyncElements (chart.js:3491)
    at BarController.buildOrUpdateElements (chart.js:3137)
    at Chart.update (chart.js:6614)

Steps to Reproduce

Can be reproduced at https://www.chartjs.org/docs/latest/samples/scales/time-line.html

Steps:

  • Open Javascript Console
  • Under the Config tab add stacked: true to scales.y
  • Under the Setup tab modify the dataset object with label: 'Dataset with point data' by adding parsing: false
  • Replace the dataset's data with the following
data: [{
  x: Utils.newDate(0).getTime(),
  y: Utils.rand(0, 100)
}, {
  x: Utils.newDate(5).getTime(),
  y: Utils.rand(0, 100)
}, {
  x: Utils.newDate(7).getTime(),
  y: Utils.rand(0, 100)
}, {
  x: Utils.newDate(15).getTime(),
  y: Utils.rand(0, 100)
}]
  • Click the Randomize action.

Context

Trying to improve performance for timeseries data with large sample counts - disabling parsing breaks the chart.

Environment

  • Chart.js version: 3.11
  • Browser name and version: Chrome 90.0.4430.72

Edit: Updated reproduction steps.

@kurkle
Copy link
Member

kurkle commented Apr 18, 2021

The sample uses date strings. Values need to be in the internal format of the scale for chart to work without parsing.

See https://www.chartjs.org/docs/latest/axes/cartesian/time.html#date-formats

@TinfoilPancakes
Copy link
Contributor Author

My apologies, I was referring to the wrong page when writing the steps. However the bug is still reproducable.

Along with listed steps, replace the data of the last dataset with:

data: [{
  x: Utils.newDate(0).getTime(),
  y: Utils.rand(0, 100)
}, {
  x: Utils.newDate(5).getTime(),
  y: Utils.rand(0, 100)
}, {
  x: Utils.newDate(7).getTime(),
  y: Utils.rand(0, 100)
}, {
  x: Utils.newDate(15).getTime(),
  y: Utils.rand(0, 100)
}]

And it will throw exceptions.

@kurkle
Copy link
Member

kurkle commented Apr 18, 2021

I think its because the stacks are build when parsing and are stored in the parsed data.
Not sure if we can support stacked charts with gained speed compared to parsing: true.

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