third_eye
third_eye

Reputation: 428

Timestamp formatting Highcharts datatable

I'm charting timeseries data in Highcharts with millisecond precision and it works fine, however when I bring up the data table it uses a different time format:

Highcharts screenshot

Is there a way to show milliseconds in the table? Thanks.

Upvotes: 1

Views: 195

Answers (1)

Wojciech Chmiel
Wojciech Chmiel

Reputation: 7372

Unfortunately, Highcharts does not have the default option to show data in milliseconds (timestamp) in a data table. However, it can be done easily by wrapping Highcharts.Chart.prototype.getDataRows method and map the data array used for plotting the table.

Wrapper code:

(function(H) {
  H.wrap(H.Chart.prototype, 'getDataRows', function(proceed, multiLevelHeaders) {
    var rows = proceed.call(this, multiLevelHeaders);
    rows = rows.map(row => {
      if (row.x) {
        row[0] = H.dateFormat('%Y-%m-%y %H:%M:%S.%L', row.x);
      }
      return row;
    });

    return rows;
  });
}(Highcharts));

Demo:

Upvotes: 1

Related Questions