VChart icon indicating copy to clipboard operation
VChart copied to clipboard

[Bug] keyTimeFormat of tooltip not work

Open xile611 opened this issue 8 months ago • 2 comments

Version

1.13.9

Link to Minimal Reproduction

no

Steps to Reproduce

const spec = {
  "type": "line",
  "data": {
    "values": [
      {
        "time": "1744859339559",
        "value": 8
      },
      {
        "time": "1744859349559",
        "value": 9
      },
      {
        "time": "1744859359559",
        "value": 11
      },
      {
        "time": "1744859369559",
        "value": 14
      },
      {
        "time": "1744859379559",
        "value": 16
      }
    ]
  },
  "xField": "time",
  "yField": "value",
  "axes": [
    {
      "orient": "bottom",
      "_alias_name": "xAxis",
      "label": {
        "formatMethod": function (label) { return new Date(Number(label)).toLocaleString(); }
      }
    }
  ],
  tooltip: {
    dimension: {
      content: [{
        keyTimeFormat: 'yyyy-MM-dd HH:mm:ss'
      }]
    }
  }
};

Current Behavior

Image

Expected Behavior

tooltip中的key应该显示成时间字符串

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

xile611 avatar Apr 24 '25 09:04 xile611

@xile611 应该这样使用。

dimension: {
  content: [{
    keyTimeFormat: '%Y-%m-%d %H:%M:%S'
  }]
}
Image

@xuefei1313 使用 %Y 这种格式化的方式在前端主流时间处理库中并不流行,是否需要支持 yyyy-MM-dd HH:mm:ss 的格式化风格?

LonelySnowman avatar May 05 '25 13:05 LonelySnowman