jQuery UI Widgets Forums Chart Add "0" to hour and minutes

This topic contains 2 replies, has 2 voices, and was last updated by  brogen 9 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Add "0" to hour and minutes #76331

    brogen
    Participant

    Hi all,

    Example here

    I’m trying to “change” my value on xAxis.

    Now : 17 Sep 0:0
    I want : 17 sep 00:00

    I have another question, less important.
    Is it possible to have “17 sep 00:00” on xAxix and : “17/9/2015 00:00” on Crossair ?

    Any easy advice ?

    Thanks

    Add "0" to hour and minutes #76337

    Vladimir
    Participant

    Hello brogen,

    Yes it is possible to do both things.

    The crosshair format is specified in the seriesGroup toolTipFormatFunction property of the series.
    And the xAxis labels are specified in the xAxis: { labels: {formatFunction: myformatFunction(data) {//apply your formatting here and return a string} } }

    Having this said, regarding your first question you could use format like the following:

    formatFunction(date){
        var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
        return date.getDate() + ' ' + months[date.getMonth()] + ' ' + ("0" + date.getHours()).slice(-2) + ':' +  ("0" + date.getMinutes()).slice(-2);
    }

    Best Regards,
    Vladimir

    jQWidgets team
    http://www.jqwidgets.com/

    Add "0" to hour and minutes #76344

    brogen
    Participant

    YES ! I was looking for that for arround 4 days now. But i wanted ask again…
    It’s working.
    I just added a comma ^^

    Thanks for all, again :).

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.