-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: 5.x版本柱状图 x 轴顺序如何固定(不跟随数据先后顺序) #6600
Comments
图例的顺序是根据数据自动生成的,如果不希望修改数据,可以配置一下color通道的比例尺的顺序 .scale('color', {
domain: ["$appInstanceId", "$appInstanceId1"],
}) |
感谢大佬🙏解决了我的问题! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug / 问题描述
5.x版本柱状图 x 轴顺序如何固定,不跟随数据先后顺序
比如我想让图中x轴的 “1”始终出现在第一位
//code
import { Chart } from "@antv/g2";
const chart = new Chart({
container: "container",
width: 1000,
});
chart
.interval()
.data([ {
Time: 1,
name: "$appInstanceId",
value: 5.083333333333333,
},
{
Time: 2,
name: "$appInstanceId",
value: 5.266666666666667,
},
{
Time: 3,
name: "$appInstanceId",
value: 5.833333333333333,
}, {
Time: 1,
name: "$appInstanceId1",
value: 5.083333333333333,
},
{
Time: 2,
name: "$appInstanceId1",
value: 5.266666666666667,
},
{
Time: 3,
name: "$appInstanceId1",
value: 5.833333333333333,
}])
.encode("x", (d) => (d.Time))
.encode("y", "value")
.encode("color", "name")
.transform({ type: "stackY" })
.axis("x", {
title: null,
tick: false,
// 刻度值
labelAutoHide: true,
labelAlign: "horizontal",
labelAutoEllipsis: true,
labelAutoWrap: false,
labelAutoRotate: false,
});
chart.render();
当 {
Time: 1,
name: "$appInstanceId",
value: 5.083333333333333,
}这条数据不存在时,x轴下标顺序会变成"2 3 1",而预期是"1 2 3"
Reproduction link / 复现链接
https://codesandbox.io/p/sandbox/antv-g2-5-0-template-z2gsmn
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
🆕 5.x
OS / 操作系统
Browser / 浏览器
The text was updated successfully, but these errors were encountered: