You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
getPriceStyle(attributes) {
const [width, height] = this.getSize(attributes);
const label = this.data.label;
const styles = [];
const priceHeight = 20; // 每个项的高度
// const totalHeight = label.length * priceHeight; // 所有项的总高度
// const startY = (height - totalHeight) / 2; // 起始位置,使得项整体居中
// console.log('startY', startY);
label.forEach((item, index) => {
styles.push({
x: -width / 2 + 8,
y: height / 2 - (index * priceHeight), // 每项向下偏移20像素
text:
${item.title}: ${item.value}
,fontSize: 12,
fill: '#1D2129',
opacity: 1,
width: width,
});
});
return styles;
}
这里y值计算出来后, label的length越大,第一项的y偏移越大
Beta Was this translation helpful? Give feedback.
All reactions