Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
渲染微妙级条形图
这个 PR 添加了一个测试案例和 demo 去展示渲染微妙级条形图的办法。(close: #5252 )
存在问题
下面代码不会去渲染第一个条。出现原因是第一个数据的
startTime
和endTime
它们的时间戳是一致的:导致它们会被 Time 比例尺映射为相同的值,从而画不出条形。
解决办法
出现上诉问题的根本原因是:精度丢失,微秒级别的数值在转换为 Date 对象的时候被去掉了。所以我们可以生成一个浮点数的时间戳,然后再交给 Time 比例尺去映射,该过程和 Linear 保持一致。为了展示合适的 ticks,还需要显示地去指定比例尺的 domain,使得其最小值按照微秒级别 floor,以及最大值按照微秒级 ceil。