score:60

Accepted answer

you can use moment.js to get the values formatted, but highcharts has it's own date formatting functionality which would be more idiomatic with highcharts. it can be attached onto the tooltip option in the highcharts constructor like so:

        tooltip: {
            formatter: function() {
                return  '<b>' + this.series.name +'</b><br/>' +
                    highcharts.dateformat('%e - %b - %y',
                                          new date(this.x))
                + ' date, ' + this.y + ' kg.';
            }
        }

you may want to also add the datetimelabelformats object with the options you need for your dates, under the xaxis.

i did this example with your code

score:0

as quy le suggested, the built-in xdateformat property is the way to go, but it wasn't working for me. i finally realized that my issue was in the series data where i'd assigned date objects to my x values instead of numbers (the date in milliseconds). instead of { x: new date('2020-01-01'), .. } it needed to be { x: date.parse('2020-01-01'), .. }. after making this change, xdateformat did the trick. it was tough to pin down since it wasn't causing any other issues with the chart (even the reformatting of my x axis labels were working fine).

score:6

i do this:

headerformat: '{point.x:%e %b %h:%m}'

e.g.

"tooltip": {
            outside: true,
            split: false,
            shared: true,
            usehtml: true,
            headerformat: '{point.x:%e %b %h:%m}',
            pointformat: '<p style="font-size:12px;margin:0px;padding-top:1px;padding-bottom:1px;color:{series.color};">{series.name} <strong>{point.y}</strong></p>',
            valuedecimals: 2,
            backgroundcolor: 'black',
            borderwidth: 0,
            style: {
                width: '150px',
                padding: '0px'
            },
            shadow: false
        },

score:15

you need to return a formatted date in the tooltip using tooltip formatter .

here is the tooltip formatter api for your reference.

for formatting the date part, you can make use of highcharts.dateformat()

the format is a subset of the formats for php's strftime function.

you can also refer php's strftime for more date formats.

i managed to format your tooltip as below.

  tooltip: {
                formatter: function() {
                    return  '<b>' + this.series.name +'</b><br/>' +
                        highcharts.dateformat('%e - %b - %y',
                                              new date(this.x))
                    + '  <br/>' + this.y + ' kg.';
                }
            }

score:21

you can use {value:%y-%m-%d} template filter.

for an example:

headerformat: '<span style="font-size: 10px">{point.key:%y-%m-%d}</span><br/>'

score:56

you should use xdateformat in tooltip for customizing your format date
http://api.highcharts.com/highcharts#tooltip.xdateformat

sample:
tooltip: {
           xdateformat: '%y-%m-%d'
         },

Related Query

More Query from same tag