Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "feat(react-charting): Add prop to regulate removal of default annotation styling",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ export const AnnotationOnlyChart: React.FC<IAnnotationOnlyChartProps> = props =>
)}
<div className={contentClassName} role="presentation">
{hasAnnotations ? (
<ChartAnnotationLayer annotations={resolvedAnnotations} context={context} theme={theme} />
<ChartAnnotationLayer
annotations={resolvedAnnotations}
context={context}
theme={theme}
hideDefaultStyles={true}
/>
) : null}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with all props 1`] = `
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -178,10 +175,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with all props 1`] = `
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -228,10 +222,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with all props 1`] = `
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -278,10 +269,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with all props 1`] = `
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -430,10 +418,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with default props 1`] =
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -490,10 +475,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with default props 1`] =
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -540,10 +522,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with default props 1`] =
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down Expand Up @@ -590,10 +569,7 @@ exports[`AnnotationOnlyChart Snapshots matches snapshot with default props 1`] =
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-items: center;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 4px;
border: 1px solid #edebe9;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
color: #323130;
display: flex;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ChartAnnotationArrowHead } from '../../../types/IChartAnnotation';
export interface IChartAnnotationLayerStyles {
root?: IStyle;
annotation?: IStyle;
annotationNoDefaults?: IStyle;
connectorLayer?: IStyle;
measurement?: IStyle;
annotationContent?: IStyle;
Expand Down Expand Up @@ -79,12 +80,28 @@ export const getStyles: IStyleFunctionOrObject<IChartAnnotationLayerStyleProps,
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
backgroundColor: defaultBackground,
color: defaultTextColor,
padding: DEFAULT_ANNOTATION_PADDING,
borderRadius: 4,
whiteSpace: 'pre-wrap',
zIndex: 2,
backgroundColor: defaultBackground,
boxShadow: theme.effects.elevation4,
border: `1px solid ${defaultBorderColor}`,
},
],
annotationNoDefaults: [
theme.fonts.small,
{
position: 'absolute',
pointerEvents: 'none',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
color: defaultTextColor,
padding: DEFAULT_ANNOTATION_PADDING,
borderRadius: 4,
whiteSpace: 'pre-wrap',
zIndex: 2,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const resolveCoordinates = (
};

export const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps> = React.memo(props => {
const { annotations: annotationsProp, theme, context, className } = props;
const { annotations: annotationsProp, theme, context, className, hideDefaultStyles } = props;

const classNames = getClassNames(getStyles, { theme, className });
const idPrefix = React.useMemo(() => getId('chart-annotation'), []);
Expand Down Expand Up @@ -439,9 +439,16 @@ export const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps> = React.

const containerStyle: React.CSSProperties = {
maxWidth: layout?.maxWidth,
...(hasCustomBackground && {
backgroundColor: applyOpacityToColor(baseBackgroundColor, backgroundOpacity),
}),
...(hasCustomBackground
? {
backgroundColor: applyOpacityToColor(baseBackgroundColor, backgroundOpacity),
}
: !hideDefaultStyles && {
backgroundColor: applyOpacityToColor(
theme.semanticColors.bodyBackground,
DEFAULT_ANNOTATION_BACKGROUND_OPACITY,
),
}),
borderColor: annotation.style?.borderColor,
borderWidth: annotation.style?.borderWidth,
borderStyle: annotation.style?.borderStyle ?? (annotation.style?.borderColor ? 'solid' : undefined),
Expand Down Expand Up @@ -542,6 +549,8 @@ export const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps> = React.
...containerStyle,
};

const annotationClass = hideDefaultStyles ? classNames.annotationNoDefaults : classNames.annotation;

if (!isMeasurementValid) {
measurementElements.push(
<div
Expand All @@ -554,7 +563,7 @@ export const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps> = React.
}
}
}}
className={css(classNames.annotation, classNames.measurement, layout?.className, annotation.style?.className)}
className={css(annotationClass, classNames.measurement, layout?.className, annotation.style?.className)}
style={measurementStyle}
aria-hidden={true}
data-annotation-key={key}
Expand All @@ -581,7 +590,7 @@ export const ChartAnnotationLayer: React.FC<IChartAnnotationLayerProps> = React.
data-annotation-key={key}
>
<div
className={css(classNames.annotation, layout?.className, annotation.style?.className)}
className={css(annotationClass, layout?.className, annotation.style?.className)}
style={containerStyle}
data-annotation-key={key}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export interface IChartAnnotationLayerProps {
context: IChartAnnotationContext;
theme: ITheme;
className?: string;
/**
* When true, removes default border, shadow, and background styling from annotations.
* @default false
*/
hideDefaultStyles?: boolean;
}

export interface IResolvedAnnotationPosition {
Expand Down