antvis/G2

[feature]时间类型堆叠条形图 #4165

IcyW posted onGitHub

请问是否已有支持时间类型的堆叠条形图模板例子?

所需功能: 1)多个条形同时展示 2)每个条形中可以根据时间展示为不同色块的时间阶段 3)横坐标展示为时间 4)支持slider调整时间,局部展示(如有更佳)

尝试过最靠近所需功能点的堆叠条形图,其中的数量即为两个阶段之间天数,但是还需要横坐标改为时间格式展示、且需要将tips改为时间段的展示。又或者data直接填例如2022-07-01这样的时间格式,但是横坐标的间隔并不是真实的时间天数,只是处理为普通枚举类型。 <img width="1497" alt="image" src="https://user-images.githubusercontent.com/16513834/191463740-8b374c3f-331c-47a3-8698-92c78c5067f4.png">

堆叠条形图:https://g2-v4.antv.vision/zh/examples/bar/stack#stacked <img width="1066" alt="image" src="https://user-images.githubusercontent.com/16513834/191457405-27e9b32b-3f4f-488d-abb0-7631b51e283d.png">

时间条形图:https://g2-v4.antv.vision/zh/examples/bar/basic#time-bar <img width="1047" alt="image" src="https://user-images.githubusercontent.com/16513834/191457142-908a7b5e-8d1b-4010-815c-71b96ed59f90.png">


相关问题: #4007 #3776 ,需要时间堆叠条形图: #3902

posted by IcyW over 2 years ago

自问自答一下, chart.scale("时间“, { type: time }); 或许能解决这个问题?

posted by IcyW over 2 years ago

这个需求实际是一个甘特图(gantt),所以 x 轴是任务的时间起止,确实解法就是你说的,设置时间的 scale 类型为 time 或者 datetime。

否则,会把 x 轴的数据当做一个文本,然后等间距,而不是根据时间去映射间距。

posted by hustcc over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests