[Chartjs]-I am using Chart.js and want to change the tool tip to display date format based on timestamp input

4👍

the tooltipFormat option is documented here: http://www.chartjs.org/docs/#scales-time-scale

it should be added under the time sub option as mentioned in the doc.

tooltipFormat: The moment js format string to use for the tooltip.

go to https://momentjs.com/docs/ to find the correct format. For example, if you wanted MM/DD/YYYY format ie. 04/27/2017 try this:

plunker: http://plnkr.co/edit/xntCXNiaL5rFVpy2VATN?p=preview

     scales: {
        xAxes: [{
          type: 'time',
          time: {
              tooltipFormat:'MM/DD/YYYY', // <- HERE
              displayFormats: {
                 'millisecond':'HH:mm:ss',
                 'second': 'HH:mm:ss',
                 'minute': 'HH:mm:ss',
                 'hour': 'HH:mm:ss',
                 'day': 'HH:mm:ss',
                 'week': 'HH:mm:ss',
                 'month': 'HH:mm:ss',
                 'quarter': 'HH:mm:ss',
                 'year': 'HH:mm:ss',
              }
            }
        }]
    }

Leave a comment