代码之家  ›  专栏  ›  技术社区  ›  Ras

如何删除React Highchart上工具提示处的十进制时间

  •  0
  • Ras  · 技术社区  · 6 年前

    我有一个区域图,在工具提示中显示一些值和日期时间,如下图所示:

    这是我使用的选项:

    const getConfig = data => ({
        chart: {
            type: 'area'
        },
        rangeSelector: {    
            selected: 1
        },
        title: {
            text: 'Highcharts',
        },
        xAxis: {
            tickInterval: 1000,
        },
        yAxis: {
            allowDecimals: false,
            labels: {
                format: '{value}'
            }
        },
        tooltip: {
            pointFormat: "{point.y:.0f}"
        },
        series: [
            {
                name: 'Data',
                data: data,
            },
        ],
    });
    

    我已经试过了 customize highcharts tooltip to show datetime , 使用此代码:

    tooltip: {
        formatter: function() {
            return  '<b>' + this.series.name +'</b><br/>' +
                Highcharts.dateFormat('%e - %b - %Y',
                                      new Date(this.x))
            + ' date, ' + this.y + ' Kg.';
        }
    }
    

    但仍然没有更改较低的工具提示(datetime),它只是更改较高的工具提示(122值)。

    如何删除工具提示中的十进制值,以便 Sunday, Jul 29, 15:50:14 ?

    1 回复  |  直到 6 年前
        1
  •  1
  •   ppotaczek    6 年前

    使用 日期时间标签格式 :

    tooltip: {
      dateTimeLabelFormats: {
        millisecond: "%A, %b %e, %H:%M:%S"
      }
    }
    

    现场演示: http://jsfiddle.net/BlackLabel/nbgzkwj3/

    应用程序编程接口: https://api.highcharts.com/highcharts/tooltip.dateTimeLabelFormats.millisecond