Sort x-axis values. Category: Question

Expected Behavior

I have a simple line chart:

labels: [1.0, 3.0, 4.0]
datasets: [{
                label: "Track Plot",
                borderColor: 'rgb(255, 0, 0)',
                datata: [0.0, 2.0, 3.0]
              }]

When I try to add new point (2.0, 5.0) I expect that dataset will be modified in a such way:
labels: [1.0, 2.0, 3.0, 4.0] datata: [0.0, 5.0, 2.0, 3.0]. So x-axis stay sorted.

config.data.labels.push(2.0);
config.data.datasets[0].data.push(5.0);

Current Behavior

When I try to add new point (2.0, 5.0) the dataset is be modified in a such way:
labels: [1.0, 3.0, 4.0, 2.0] datata: [0.0, 2.0, 3.0, 5.0]. New point is appended to the end of the dataset.

Possible Solution

Is there any options to append new point between other points to make x-axis sorted?

Thanks,
Alina.

Author: Fantashit

1 thought on “Sort x-axis values. Category: Question

Comments are closed.