antvis / antvis/G2Plot

🤔 [QUESTION]设置annotations后报错

Open
#3,309 1 comment 0 reactions 0 assignees View on GitHub
Question
Dominant language
TypeScript
Stars
2.7k
Forks
591
PR merge metrics
No merged PRs in 30d

Description

我的图表配置是这样的
`this.chart1 = new DualAxes('chart1', {
data: [this.chartdata, this.chartdata],
xField: 'area',
yField: ['tzje', 'tzzs'],
yAxis: {
tzje: {
max: 330,
title: {
text: "金额(亿元)",
position: "end",
autoRotate: false,
offset: -10,
},
},
tzzs: {
max: 10,
min: -60,
title: {
text: "增速(%)",
position: "end",
autoRotate: false,
offset: -10,
},
}
},
tooltip: {
formatter: (datum => {
if (datum.hasOwnProperty("tzzs")) {
return {name: "增速", value: datum.tzzs + '%'};
} else if (datum.hasOwnProperty("tzje")) {
return {name: "金额", value: datum.tzje + '亿元'};
}

})
},
legend: {
position: "top",
itemName: {
formatter: ((text, item, index) => {
if (text === "tzje") return "金额"
else if (text === "tzzs") return "增速"
})
}
},
xAxis: {
label: {
autoRotate: true,
autoHide: false,
autoEllipsis: false,
}
},
geometryOptions: [
{
geometry: 'column',
color: '#3177ec',
columnStyle: (data => {
if (data.area === "江门市") {
return {
fill: "#00c462"
}
} else {
return {
fill: "#3177ec"
}
}
}),
},
{
geometry: 'line',
color: '#ff7a0d',
lineStyle: {
lineWidth: 3,
},
point: {
shape: 'circle',
size: 4,
style: {
opacity: 0.5,
stroke: '#ff7a0d',
fill: '#fff',
},
},
},
],
// 顶部预留空间
appendPadding: [20, 0, 0, 0],
annotations: [
{
type: "text",
position: ["0%", "max"],
content: "万",
offsetX: 4,
style: {
textAlign: "left",
textBaseline: "top",
fontWeight: 500
},
id: "y-axis-unit"
}
]

});`
但运行的时候报以下错误
image
这个要如何解决???

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported error with the provided DualAxes configuration, especially the annotations block, and inspect the runtime stack trace shown in the attached screenshot. The issue does not name a source file or test, and completion criteria are not specified beyond identifying and resolving the runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.