Skip to content

Disable auto x-keys sorting when parseTime is set to false #83

@kenn

Description

@kenn

The setData method automatically sorts x-keys, but it's problematic in some cases, particular when parseTime: false is speficied.

Given this data,

Morris.Line({
  element: 'demo',
  data: [
    {x: '9:30am',  y: 10},
    {x: '9:45am',  y: 20},
    {x: '10:00am', y: 30},
    {x: '10:15am', y: 40},
    {x: '10:30am', y: 50},
  ],
  xkey: 'x',
  ykeys: ['y'],
  labels: ['ever increasing'],
  parseTime: false
});

We get this chart.

Notice that the leftmost x-key becomes 10:00am, where it should have been 9:30am.

Btw I had hard time figuring this out... users reported this problem but it only occurred when the x-keys span between 9:59am and 10:00am. :)

I think when parseTime: false is specified, automatic sorting on x-keys should be disabled, as the doc says:

Set to false to skip time/date parsing for X values, instead treating them as an equally-spaced series.

So it makes more sense to leave X values as they are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions