Kamran
Kamran

Reputation: 4100

Highchart strange behavior of Range selector text boxes.

On the following JS Fiddle I have formatted the date as '%d-%m-%Y'. On change of date inside the text box, I was hoping that the navigator will move to the selected date but the navigator is moved to the start of data.

If this code inputDateFormat: '%d-%m-%Y' is removed. Then Its ok But I want the date format as %d-%m-%Y

Upvotes: 0

Views: 152

Answers (1)

Pimmol
Pimmol

Reputation: 1871

I think it's because Date.parse doesn't understand the dd-mm-yyyy notation. See the docs: http://api.highcharts.com/highstock#rangeSelector.inputEditDateFormat

This must be a format that is recognized by JavaScript Date.parse

I added a simple inputDateParser function inside the rangeSelector object, which seems to work:

inputDateParser: function(value) {
  var date = value.split('-');
  var returnDate = new Date(
    parseInt(date[2], 10), 
    parseInt(date[1], 10) - 1, 
    parseInt(date[0], 10) + 1
  ).getTime();

  return returnDate;
}

Demo: http://jsfiddle.net/aw31ddvv/6/

Upvotes: 3

Related Questions