LA.27
LA.27

Reputation: 2248

Highstock with datepicker and a non-default date

I've been working on integrating datepicker into Highstock and have problems with date format. There are many pages describing the solution for a default date format (yy-mm-dd). A good example is that one:

http://forum.highcharts.com/viewtopic.php?f=9&t=13612

However, I'd like to have a different date format: dd-mm-yyyy. I've tried the following code:

window.chart = new Highcharts.StockChart({
// ...
    rangeSelector: {
        inputDateFormat: '%d-%m-%Y',
        inputEditDateFormat: '%d-%m-%Y',
        }

// ...
}, function (chart) {

             //apply the date pickers
            setTimeout(function () {
                $('input.highcharts-range-selector', $('#' + chart.options.chart.renderTo)).datepicker({
                    format: "dd-mm-yyyy"
                });
            }, 0);
        });

But the control goes mad then (i.e. it either selects random dates like 3-June-34 [== 34 year, not 1934] or even refuses to change the date at all.

I guess there must be some a problem in converting date between datepicker and chart. How to fix it ?

Upvotes: 2

Views: 3470

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

You need to set inputDateParser. By default Highcharts will take date, and use Date.parse(), where dd-mm-yyyy isn't supported format.

See working demo: http://jsfiddle.net/BWEm5/152/ (choose date before 2013 year for example).

Upvotes: 4

Related Questions