Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/visx-annotation/src/components/CircleSubject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import AnnotationContext from '../context/AnnotationContext';
export type CircleSubjectProps = Pick<AnnotationContextType, 'x' | 'y'> & {
/** Optional className to apply to CircleSubject in addition to 'visx-annotation-subject'. */
className?: string;
/** Allows you to customize the pointerEvents attribute on the `<circle>` element.
*
* Default: `"none"` */
pointerEvents?: React.SVGAttributes<SVGCircleElement>['pointerEvents'];
/** Color of CircleSubject. */
stroke?: string;
/** Radius of CircleSubject. */
Expand All @@ -16,6 +20,7 @@ export default function CircleSubject({
className,
x: propsX,
y: propsY,
pointerEvents = 'none',
stroke = '#222',
radius = 16,
...restProps
Expand All @@ -30,7 +35,7 @@ export default function CircleSubject({
cy={propsY || annotationContext.y}
r={radius}
fill="transparent"
pointerEvents="none"
pointerEvents={pointerEvents}
stroke={stroke}
{...restProps}
/>
Expand Down
9 changes: 7 additions & 2 deletions packages/visx-annotation/src/components/Connector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export type ConnectorProps = Pick<AnnotationContextType, 'x' | 'y' | 'dx' | 'dy'
/** Color of the connector line. */
stroke?: string;
/** Optional additional props. */
pathProps?: React.SVGProps<SVGPathElement>;
pathProps?: Omit<React.SVGProps<SVGPathElement>, 'pointerEvents'>;
/** Allows you to customize the pointerEvents attribute on the `<path>` element.
*
* Default: `"none"` */
pointerEvents?: React.SVGAttributes<SVGPathElement>['pointerEvents'];
};

export default function Connector({
Expand All @@ -26,6 +30,7 @@ export default function Connector({
type = 'elbow',
stroke = '#222',
pathProps,
pointerEvents = 'none',
}: ConnectorProps) {
// if props are provided, they take precedence over context
const annotationContext = useContext(AnnotationContext);
Expand Down Expand Up @@ -63,7 +68,7 @@ export default function Connector({
strokeWidth={1}
stroke={stroke}
fill="transparent"
pointerEvents="none"
pointerEvents={pointerEvents}
d={`M${x0},${y0}${type === 'elbow' ? `L${x1},${y1}` : ''}L${x2},${y2}`}
{...pathProps}
/>
Expand Down
4 changes: 3 additions & 1 deletion packages/visx-annotation/src/components/HtmlLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type HtmlLabelProps = Pick<
| 'anchorLineStroke'
| 'className'
| 'horizontalAnchor'
| 'pointerEvents'
| 'resizeObserverPolyfill'
| 'showAnchorLine'
| 'verticalAnchor'
Expand All @@ -30,6 +31,7 @@ export default function HtmlLabel({
className,
containerStyle,
horizontalAnchor: propsHorizontalAnchor,
pointerEvents = 'none',
resizeObserverPolyfill,
showAnchorLine = true,
verticalAnchor: propsVerticalAnchor,
Expand Down Expand Up @@ -67,7 +69,7 @@ export default function HtmlLabel({
<Group
top={containerCoords.y}
left={containerCoords.x}
pointerEvents="none"
pointerEvents={pointerEvents}
className={cx('visx-annotationlabel', className)}
>
<foreignObject width={width} height={height} overflow="visible">
Expand Down
7 changes: 6 additions & 1 deletion packages/visx-annotation/src/components/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export type LabelProps = {
fontColor?: string;
/** Whether the label is horizontally anchored to the start, middle, or end of its x position. */
horizontalAnchor?: TextProps['textAnchor'];
/** Allows you to customize the pointerEvents attribute on the Group (`<g>`) wrapper of the Annotation.
*
* Default: `"none"` */
pointerEvents?: React.SVGAttributes<SVGElement>['pointerEvents'];
/** Optionally inject a ResizeObserver polyfill, else this *must* be globally available. */
resizeObserverPolyfill?: UseMeasureOptions['polyfill'];
/** Whether to render a line indicating label text anchor. */
Expand Down Expand Up @@ -75,6 +79,7 @@ export default function Label({
className,
fontColor = '#222',
horizontalAnchor: propsHorizontalAnchor,
pointerEvents = 'none',
resizeObserverPolyfill,
showAnchorLine = true,
showBackground = true,
Expand Down Expand Up @@ -190,7 +195,7 @@ export default function Label({
<Group
top={containerCoords.y}
left={containerCoords.x}
pointerEvents="none"
pointerEvents={pointerEvents}
className={cx('visx-annotationlabel', className)}
opacity={titleBounds.height === 0 && subtitleBounds.height === 0 ? 0 : 1}
>
Expand Down
7 changes: 6 additions & 1 deletion packages/visx-annotation/src/components/LineSubject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export type LineSubjectProps = {
strokeWidth?: number;
/** Orientation of line. */
orientation?: 'vertical' | 'horizontal';
/** Allows you to customize the pointerEvents attribute on the `<line>` element.
*
* Default: `"none"` */
pointerEvents?: React.SVGAttributes<SVGLineElement>['pointerEvents'];
/** x position of LineSubject (for vertical LineSubjects). */
x?: number;
/** y position of LineSubject (for horizontal LineSubjects). */
Expand All @@ -26,6 +30,7 @@ export default function LineSubject({
x: propsX,
y: propsY,
orientation = 'vertical',
pointerEvents = 'none',
min,
max,
stroke = '#222',
Expand All @@ -43,7 +48,7 @@ export default function LineSubject({
y1={lineIsVertical ? min : propsY || annotationContext.y}
y2={lineIsVertical ? max : propsY || annotationContext.y}
fill="transparent"
pointerEvents="none"
pointerEvents={pointerEvents}
stroke={stroke}
{...restProps}
/>
Expand Down