This commit is contained in:
joylink_cuiweidong 2021-01-13 18:33:21 +08:00
commit 3be5df98e8

View File

@ -7,6 +7,7 @@ import Text from 'zrender/src/graphic/Text';
import Polygon from 'zrender/src/graphic/shape/Polygon'; import Polygon from 'zrender/src/graphic/shape/Polygon';
const defaultStyle = { const defaultStyle = {
distance: 12,
block:{ block:{
stroke: '#fff', mapStyle: { stroke: '#fff', mapStyle: {
FB: { fill: '#fff', stroke: '#000' }, FB: { fill: '#fff', stroke: '#000' },
@ -40,14 +41,13 @@ export default class Responder extends Group {
create() { create() {
const model = this.model; const model = this.model;
const responderStyle = this.style.Responder || defaultStyle; const responderStyle = this.style.Responder || defaultStyle;
const distance = 12; const distanceX = responderStyle.distance * Math.sin(model.rotate);
const offsetX = distance * Math.sin(model.rotate); const distanceY = responderStyle.distance * Math.cos(model.rotate);
const offsetY = distance * Math.cos(model.rotate);
const blockWidth = responderStyle.block.width || 5; const blockWidth = responderStyle.block.width || 5;
const blockHeight = responderStyle.block.height || 12; const blockHeight = responderStyle.block.height || 12;
const blockStyle = responderStyle.block.mapStyle[model.type] || { fill: '#fff'}; const blockStyle = responderStyle.block.mapStyle[model.type] || { fill: '#fff'};
const blockX = model.position.x - blockWidth / 2 - offsetX; const blockX = model.position.x - blockWidth / 2 - distanceX;
const blockY = model.position.y - blockHeight / 2 - offsetY; const blockY = model.position.y - blockHeight / 2 - distanceY;
const textX = blockX + model.textOffset.x; const textX = blockX + model.textOffset.x;
const textY = blockY + model.textOffset.y; const textY = blockY + model.textOffset.y;
const textName = `${model.type}-${model.name}`; const textName = `${model.type}-${model.name}`;
@ -103,7 +103,6 @@ export default class Responder extends Group {
this.text = new Text({ this.text = new Text({
zlevel: this.zlevel, zlevel: this.zlevel,
z: this.z + 1, z: this.z + 1,
origin,
style: { style: {
x: textX, x: textX,
y: textY, y: textY,