Skip to content

Auto scaling of y-axes doesn't work if data is typed array  #5681

@jalajc

Description

@jalajc

Auto scaling of y-axes doesn't work if data is typed array say e.g.
myMixedChart.data.datasets[0].data = Uint32Array_data_array;

However, labels (x-axis) redraw as per new data (even when typed array is used).

Current Behaviour/Expected Behavior

I wouldn't call this strictly a bug, but since lot of folks use serialization libraries such as protobuff etc, de-serialization results into typed arrays. which when assigned to data of chart object, auto-scaling fails and is hard to debug (untill you know typed array is causing issue). Expected behavior is auto-scaling should work on typed arrays too.

Possible Solution

use Array.from before assigning typed array to chart data. e.g.
myMixedChart.data.datasets[0].data = Array.from(Uint32Array_data_array);

Context

Using serialization library which returns chart data as binary buffer. Once de-serialization is done, all the data arrays are typed arrays.

Environment

  • Chart.js version: 2.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions