Skip to content

Commit

Permalink
set fill for text in bbox title
Browse files Browse the repository at this point in the history
  • Loading branch information
neindochoh committed Feb 19, 2024
1 parent 290448d commit 39cf0ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/lenses/BoundingBoxLens/BBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface BBoxProps {
y: number;
width: number;
height: number;
color: string;
color: chroma.Color;
label: string;
}

Expand All @@ -17,6 +17,9 @@ const BBox = ({ x, y, width, height, color, label }: BBoxProps) => {
const textColor =
chroma.contrast(color, WHITE) > chroma.contrast(color, BLACK) ? WHITE : BLACK;

const colorCss = color.css();
const textColorCss = textColor.css();

return (
<g>
<rect
Expand All @@ -25,19 +28,19 @@ const BBox = ({ x, y, width, height, color, label }: BBoxProps) => {
width={width}
height={height}
fill="none"
stroke={color}
stroke={colorCss}
strokeWidth={2}
></rect>
<rect
x={x}
y={y - 11}
width={width}
height={12}
fill={color}
stroke={color}
fill={colorCss}
stroke={colorCss}
strokeWidth={2}
></rect>
<text x={x} y={y} fontSize={12} stroke={textColor.hex()}>
<text x={x} y={y} fontSize={12} stroke={textColorCss} fill={textColorCss}>
{label}
</text>
</g>
Expand Down
2 changes: 1 addition & 1 deletion src/lenses/BoundingBoxLens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const BoundingBoxLens: Lens = ({ urls, values, columns }) => {
height={(box[3] - box[1]) * renderedHeight}
x={box[0] * renderedWidth + offsetWidth}
y={box[1] * renderedHeight + offsetHeight}
color={colorTransferFunction(categories[index]).hex()}
color={colorTransferFunction(categories[index])}
label={
categoricalDtype?.invertedCategories[categories[index]] ??
''
Expand Down

0 comments on commit 39cf0ee

Please sign in to comment.