Skip to content

Commit

Permalink
fix(heatmap): move Helper Functions Outside of assembleArrow. apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Manviel committed Jun 11, 2024
1 parent 4136550 commit 22cf47b
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/component/tooltip/TooltipHTMLContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ function mirrorPos(pos: string): string {
return pos;
}

function calculateArrowOffset(rotatedWH: number, borderWidth: number, arrowWH: number) {
return Math.round(
(
((rotatedWH - Math.SQRT2 * borderWidth) / 2
+ Math.SQRT2 * borderWidth
- (rotatedWH - arrowWH) / 2)
* 100
) / 100
);
}

function getColorClassName(color: ZRColor) {
const colorValue = convertToColorString(color);
return colorValue.replace(/[^a-zA-Z0-9]/g, '');
}

function assembleArrow(
tooltipModel: Model<TooltipOption>,
borderColor: ZRColor,
Expand Down Expand Up @@ -87,22 +103,6 @@ function assembleArrow(
transformClasses.push(`tooltip-arrow-rotate-${rotateDeg = arrowPos === 'top' ? 225 : 45}`);
}

function calculateArrowOffset(rotatedWH: number, borderWidth: number, arrowWH: number) {
return Math.round(
(
((rotatedWH - Math.SQRT2 * borderWidth) / 2
+ Math.SQRT2 * borderWidth
- (rotatedWH - arrowWH) / 2)
* 100
) / 100
);
}

function getColorClassName(color: ZRColor) {
const colorValue = convertToColorString(color);
return colorValue.replace(/[^a-zA-Z0-9]/g, '');
}

const rotateRadian = rotateDeg * Math.PI / 180;
const arrowWH = arrowSize + borderWidth;
const rotatedWH = arrowWH * Math.abs(Math.cos(rotateRadian)) + arrowWH * Math.abs(Math.sin(rotateRadian));
Expand Down

0 comments on commit 22cf47b

Please sign in to comment.