g2({
type: "view",
data: teamGoals[league],
title: `${leagueNameCN[league]}球队进球/失球情况`,
children: [
{
type: "lineX",
data: [goalsForMedian]
},
{
type: "lineY",
data: [goalsAgainstMedian],
labels: [
{
text: "攻守兼备",
dy: -100,
textBaseline: "bottom",
fontSize: 20,
fill: "#000",
fillOpacity: 0.45
}
]
},
{
type: "range",
data: [
{
goalsFor: [goalsForMedian, goalsForMax],
goalsAgainst: [goalsAgainstMin, goalsAgainstMedian],
region: "1"
},
{
goalsFor: [goalsForMin, goalsForMedian],
goalsAgainst: [goalsAgainstMin, goalsAgainstMedian],
region: "2"
},
{
goalsFor: [goalsForMin, goalsForMedian],
goalsAgainst: [goalsAgainstMedian, goalsAgainstMax],
region: "3"
},
{
goalsFor: [goalsForMedian, goalsForMax],
goalsAgainst: [goalsAgainstMedian, goalsAgainstMax],
region: "4"
}
],
encode: { x: "goalsFor", y: "goalsAgainst" },
style: {
fill: (d) =>
d.region === "1"
? "rgba(0,255,0,0.5)"
: d.region === "3"
? "rgba(255,0,0,0.5)"
: "transparent",
fillOpacity: 0.2
},
animate: { enter: { type: "fadeIn" } }
},
{
type: "image",
style: {
src: leagueLogos[league],
x: "90%",
y: "80%",
width: 177 * 0.8,
height: 224 * 0.8,
opacity: 0.6
},
tooltip: false,
labels: [
{
text: subtitles[league],
dy: 200,
textBaseline: "bottom",
fontSize: 12,
fill: "#000",
fillOpacity: 0.45
}
]
},
{
type: "image",
encode: {
x: "goalsFor",
y: "goalsAgainst",
src: (d) => teamLogos[league][d.team]
},
scale: {
y: {
range: [0, 1]
}
},
style: { stroke: "#bbb", fillOpacity: 0.8 },
axis: { x: { title: "进球" }, y: { title: "失球" } },
legend: false,
tooltip: {
title: "team",
items: [
{ channel: "x", name: "进球" },
{ channel: "y", name: "失球" }
]
}
}
]
})