customize highcharts tooltip to show datetime

前端 未结 5 1452
生来不讨喜
生来不讨喜 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 10:03

    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  '' + this.series.name +'
    ' + 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

提交回复
热议问题