Replies: 1 comment
-
柱状图按照时间比例刻度分布方法说明 你希望柱子的间距能真实反映日期,以时间为 x 轴,2015-11-10 到 2015-11-20 之间的日期分布在真实的时间线上。 正确配置方式
import { Column } from '@ant-design/charts';
const Demo = () => {
const config = {
data: [
{ time: "2015-11-19", value: 120 },
{ time: "2015-11-16", value: 10 },
{ time: "2015-11-13", value: 22 },
// 可继续补全部分时间点
],
xField: "time",
yField: "value",
// 关键配置:指定 type 为 time
xAxis: {
type: 'time',
// 可选:自定义时间格式显示
tickFormat: (val) =>
new Date(val).toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' }),
},
};
return <Column {...config} />;
}; 参数解释
注意事项
相关文档链接如果仍未达到预期效果,请补充你的完整配置、依赖版本和预期效果截图,我会进一步诊断。 此回答由AI自动生成,仅供参考。如有疑问,请等待维护者回复。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
以下面为例,我希望相邻柱子之间的距离不同,比如以x轴为时间坐标从2015-11-10到2015-11-20,柱子能出现在对应的刻度上,类似这样

我查阅了官网文档 时间比例尺,但是文档不够详细,尝试配置后并没有生效
Beta Was this translation helpful? Give feedback.
All reactions