Skip to content

Commit 675b7e7

Browse files
author
lflangis
committed
fix(scatter): SJIP-954 adjust marker layer annotation position
1 parent 83ee250 commit 675b7e7

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

packages/ui/Release.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 10.10.1 2024-09-24
2+
- fix: SJIP-954 adjust marker layer annotation position
3+
14
### 10.10.0 2024-09-24
25
- fix: SJIP-958 feat add bordered style to basic description
36

packages/ui/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ferlab/ui",
3-
"version": "10.10.0",
3+
"version": "10.10.1",
44
"description": "Core components for scientific research data portals",
55
"publishConfig": {
66
"access": "public"

packages/ui/src/components/Charts/ScatterPlot/Canvas/Layers/MarkerCanvasLayer.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { ScatterPlotDatum, ScatterPlotNodeData } from '@nivo/scatterplot';
2-
31
import { TCanvasLayer } from './type';
42

53
type TMarkerCanvasLayer = TCanvasLayer & {
@@ -10,11 +8,17 @@ type TMarkerCanvasLayer = TCanvasLayer & {
108
font: string;
119
};
1210

11+
const DIRECTION_THRESHOLD = 60;
12+
1313
/**
1414
* Try to replicate svg's annotation behavior
1515
*
16+
* Chart must have a padding top of at least the size of the radius
17+
*
18+
* e.g.radius is 12px, chart must have a padding-top of 12 px.
19+
* If not, the top element will be cut when rendering
20+
*
1621
* Nivo's doc said that annotation props is supported but it was a lie
17-
* @returns
1822
*/
1923
const MarkerCanvasLayer = ({
2024
ctx,
@@ -31,7 +35,8 @@ const MarkerCanvasLayer = ({
3135
const target = props.nodes.find((node) => node.id === selectedNodeId);
3236
if (!target) return;
3337

34-
const textPosition = { x: target.x + 30, y: target.y - 30 };
38+
const direction = target.y < DIRECTION_THRESHOLD ? -1 : 1;
39+
const textPosition = { x: target.x + 30, y: target.y - 30 * direction };
3540
const underlineOffset = { x: 7, y: 7 };
3641
const underlineLength = 45;
3742
ctx.beginPath();

packages/ui/src/components/Charts/ScatterPlot/index.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
flex-direction: column;
44
height: 100%;
55
width: 100%;
6-
gap: 48px;
6+
gap: 12px;
77
}
88

99
.controls {

packages/ui/src/components/Charts/SwarmPlot/index.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
flex-direction: column;
44
height: 100%;
55
width: 100%;
6-
gap: 48px;
6+
gap: 24px;
77
}
88

99
.controls {

0 commit comments

Comments
 (0)