customize highcharts tooltip to show datetime

前端 未结 5 1450
生来不讨喜
生来不讨喜 2020-12-01 09:19

I\'m developing a project that is expected to show this graph: http://jsfiddle.net/Kc23N/

When I click a point (tooltip) I want to show a date understandable, not th

5条回答
  •  执念已碎
    2020-12-01 09:55

    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  '' + this.series.name +'
    ' + Highcharts.dateFormat('%e - %b - %Y', new Date(this.x)) + '
    ' + this.y + ' Kg.'; } }

提交回复
热议问题