Skip to content

Commit c004350

Browse files
committedDec 31, 2021
feat(annotations): add support for border radius to rect annotations
1 parent 720716b commit c004350

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed
 

‎packages/annotations/src/Annotation.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const Annotation = <Datum,>(annotation: BoundAnnotation<Datum>) => {
3030
y={y}
3131
width={annotation.width}
3232
height={annotation.height}
33+
borderRadius={annotation.borderRadius}
3334
/>
3435
)}
3536
<AnnotationLink points={computed.points} />

‎packages/annotations/src/RectAnnotationOutline.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ export const RectAnnotationOutline = ({
66
y,
77
width,
88
height,
9+
borderRadius = 6,
910
}: {
1011
x: number
1112
y: number
1213
width: number
1314
height: number
15+
borderRadius?: number
1416
}) => {
1517
const theme = useTheme()
1618
const { animate, config: springConfig } = useMotionConfig()
@@ -30,6 +32,8 @@ export const RectAnnotationOutline = ({
3032
<animated.rect
3133
x={animatedProps.x}
3234
y={animatedProps.y}
35+
rx={borderRadius}
36+
ry={borderRadius}
3337
width={animatedProps.width}
3438
height={animatedProps.height}
3539
style={{
@@ -45,6 +49,8 @@ export const RectAnnotationOutline = ({
4549
<animated.rect
4650
x={animatedProps.x}
4751
y={animatedProps.y}
52+
rx={borderRadius}
53+
ry={borderRadius}
4854
width={animatedProps.width}
4955
height={animatedProps.height}
5056
style={theme.annotations.outline}

‎packages/annotations/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export type RectAnnotationSpec<Datum> = BaseAnnotationSpec<Datum> & {
107107
offset?: number
108108

109109
size?: never
110+
borderRadius?: number
110111
}
111112

112113
export type AnnotationSpec<Datum> =

‎website/src/data/components/network/props.ts

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ const props: ChartProperty[] = [
247247
noteY: 36,
248248
offset: 6,
249249
noteTextOffset: 5,
250+
borderRadius: 3,
250251
},
251252
}),
252253
isInteractive({ flavors: allFlavors, defaultValue: defaults.isInteractive }),

‎website/src/lib/chart-properties/annotations.ts

+13
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ export const annotations = ({
7272
],
7373
},
7474
},
75+
{
76+
key: 'borderRadius',
77+
flavors,
78+
help: `Rect border radius.`,
79+
type: 'number',
80+
required: false,
81+
when: (settings: any) => settings.type === 'rect',
82+
control: {
83+
type: 'range',
84+
min: 0,
85+
max: 12,
86+
},
87+
},
7588
{
7689
key: 'note',
7790
flavors,

0 commit comments

Comments
 (0)
Please sign in to comment.