1

Here i used line highcharts in my react project and in my line highchart I display tooltip, in this tooltime I have one date but this date is in timestamp format and I want to display this timestamp in date format in tooltip how it is possible in highcharts tooltip ?

 tooltip: {
    headerFormat: '<b>{series.name}</b>',
    pointFormat: '{point.x}',  // 1554422400
  },
Dharmesh
  • 5,383
  • 17
  • 46
  • 62
  • Possible duplicate of [this](https://stackoverflow.com/questions/17033752/customize-highcharts-tooltip-to-show-datetime) question – tarzen chugh Apr 30 '19 at 10:47
  • 1
    Possible duplicate of [customize highcharts tooltip to show datetime](https://stackoverflow.com/questions/17033752/customize-highcharts-tooltip-to-show-datetime) – Udhay Titus Apr 30 '19 at 10:47
  • @tarzenchugh i tried solutions from that answer but it shows same date(18 jan 1970) if i have different different timestamp – Dharmesh Apr 30 '19 at 11:09

2 Answers2

1

In the pointFormatter function you can use Highcharts dateFormat method:

tooltip: {
    ...,
    pointFormatter: function() {
        return Highcharts.dateFormat('%a %d %b %H:%M:%S', this.x)
    }
}

Live demo: http://jsfiddle.net/BlackLabel/oLt62kbu/

API Reference:

https://api.highcharts.com/class-reference/Highcharts#.dateFormat

https://api.highcharts.com/highcharts/tooltip.pointFormatter

ppotaczek
  • 36,341
  • 2
  • 14
  • 24
  • Hi @DDD, yes because my timestamps looks like this: `[0, 1, 2, 3, 4, ...]`. Check this example: http://jsfiddle.net/BlackLabel/kLfh42ys/ – ppotaczek Apr 30 '19 at 11:08
1

Use moment.js npm, dedicated to time and all related formats of date and time

costal oktopus
  • 319
  • 2
  • 12