-
{XValue}
- {/*TO DO if we add time for callout then will use this */}
- {/*
07:00am
*/}
+
{XValue || convertToLocaleString(Legend, culture)}
-
+ {variant === ChartHoverCardVariant.LongLegend && !!XValue && !!Legend && (
{convertToLocaleString(Legend, culture)}
+ )}
+
+
+ {variant !== ChartHoverCardVariant.LongLegend && !!XValue && !!Legend && (
+
{convertToLocaleString(Legend, culture)}
+ )}
{convertToLocaleString(YValue, culture)}
+ {!!ratio && (
+
+ {convertToLocaleString(ratio[0], culture)}
+ {' / ' + convertToLocaleString(ratio[1], culture)}
+
+ )}
- {!!ratio && (
-
- <>
- {convertToLocaleString(ratio[0], culture)}/
- {convertToLocaleString(ratio[1], culture)}
- >
-
- )}
- {!!descriptionMessage &&
{descriptionMessage}
}
+ {!!descriptionMessage && (
+ <>
+
+
{descriptionMessage}
+ >
+ )}
);
}
diff --git a/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.styles.ts b/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.styles.ts
index 16918a422ccba..2b61595d98a3f 100644
--- a/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.styles.ts
+++ b/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.styles.ts
@@ -1,83 +1,71 @@
-import { IChartHoverCardStyles, IChartHoverCardStyleProps } from './ChartHoverCard.types';
-import { FontWeights } from '@fluentui/react/lib/Styling';
+import { IChartHoverCardStyles, IChartHoverCardStyleProps, ChartHoverCardVariant } from './ChartHoverCard.types';
+import { FontSizes, FontWeights } from '@fluentui/react/lib/Styling';
export const getChartHoverCardStyles = (props: IChartHoverCardStyleProps): IChartHoverCardStyles => {
- const { color, XValue, theme, isRatioPresent = false } = props;
+ const { theme, variant, hasBothMetrics } = props;
return {
- calloutContentRoot: [
- {
- display: 'grid',
- overflow: 'hidden',
- padding: '11px 16px 10px 16px',
- backgroundColor: theme.semanticColors.bodyBackground,
- backgroundBlendMode: 'normal, luminosity',
- },
- ],
+ calloutContentRoot: {
+ ...theme.fonts.medium,
+ color: theme.semanticColors.bodyText,
+ padding: '16px',
+ backgroundColor: theme.semanticColors.bodyBackground,
+ backgroundBlendMode: 'normal, luminosity',
+ },
+
calloutDateTimeContainer: {
+ marginBottom: '8px',
+ },
+
+ calloutContentX: {
+ fontWeight: FontWeights.semibold,
+ },
+
+ calloutBlockContainer: {
display: 'flex',
- flexDirection: 'row',
- justifyContent: 'space-between',
+ alignItems: 'center',
},
- calloutContentX: [
- theme.fonts.small,
- {
- lineHeight: '16px',
- opacity: '0.8',
- color: theme.semanticColors.bodySubtext,
- },
- ],
- calloutBlockContainer: [
- theme.fonts.xxLarge,
- {
- marginTop: XValue ? '13px' : 'unset',
- paddingLeft: '8px',
- lineHeight: '22px',
- color: theme.semanticColors.bodyText,
- borderLeft: `4px solid ${color}`,
- },
- ],
- calloutlegendText: [
- theme.fonts.small,
- {
- lineHeight: '16px',
- color: theme.semanticColors.bodyText,
- },
- ],
- calloutContentY: [
- theme.fonts.xxLarge,
- {
- color: color ? color : theme.semanticColors.bodyText,
- fontWeight: 'bold',
- lineHeight: '36px',
- },
- ],
- calloutInfoContainer: [
- isRatioPresent && {
- display: 'flex',
- alignItems: 'flex-end',
- },
- ],
- ratio: [
- theme.fonts.small,
- {
- marginLeft: '6px',
- color: theme.semanticColors.bodyText,
- },
- ],
- numerator: {
- fontWeight: FontWeights.bold,
+
+ calloutlegendText: {
+ marginRight: variant === ChartHoverCardVariant.LongLegend ? '0px' : '24px',
+ textOverflow: 'ellipsis',
+ overflow: 'hidden',
+ whiteSpace: 'nowrap',
+ marginBottom: variant === ChartHoverCardVariant.LongLegend ? '4px' : '0px',
+ flexGrow: 1,
+ },
+
+ calloutContentY: {
+ fontWeight: FontWeights.semibold,
+ flexShrink: 0,
},
- denominator: {
+
+ calloutInfoContainer: {},
+
+ ratio: {
+ marginLeft: hasBothMetrics ? '24px' : '0px',
+ flexShrink: 0,
+ },
+
+ numerator: {
fontWeight: FontWeights.semibold,
},
- descriptionMessage: [
- theme.fonts.small,
- {
- color: theme.semanticColors.bodyText,
- marginTop: '10px',
- paddingTop: '10px',
- borderTop: `1px solid ${theme.semanticColors.menuDivider}`,
- },
- ],
+
+ denominator: {},
+
+ descriptionMessage: {
+ fontSize: FontSizes.small,
+ },
+
+ calloutLegendIcon: {
+ marginRight: '8px',
+ flexShrink: 0,
+ },
+
+ divider: {
+ height: '1px',
+ backgroundColor: '#c8c8c8',
+ marginTop: '8px',
+ marginBottom: '8px',
+ },
};
};
diff --git a/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.types.ts b/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.types.ts
index 144282bd4e753..a5e5506719d73 100644
--- a/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.types.ts
+++ b/packages/react-charting/src/utilities/ChartHoverCard/ChartHoverCard.types.ts
@@ -1,4 +1,10 @@
import { ITheme, IStyle, IStyleFunctionOrObject } from '@fluentui/react';
+
+export enum ChartHoverCardVariant {
+ ShortLegend = 'short-legend',
+ LongLegend = 'long-legend',
+}
+
export interface IChartHoverCardProps {
/**
* X value for hover card
@@ -42,6 +48,12 @@ export interface IChartHoverCardProps {
* The prop used to define the culture to localized the numbers
*/
culture?: string;
+
+ /**
+ * Specifies the variant of hover card to be rendered
+ * @defaultvalue ChartHoverCardVariant.ShortLegend
+ */
+ variant?: ChartHoverCardVariant;
}
export interface IChartHoverCardStyles {
@@ -94,6 +106,16 @@ export interface IChartHoverCardStyles {
* styles for the description
*/
descriptionMessage?: IStyle;
+
+ /**
+ * styles for the legend icon
+ */
+ calloutLegendIcon?: IStyle;
+
+ /**
+ * styles for the group divider
+ */
+ divider?: IStyle;
}
export interface IChartHoverCardStyleProps {
@@ -103,17 +125,12 @@ export interface IChartHoverCardStyleProps {
theme: ITheme;
/**
- * color for hover card
+ * Specifies the variant of ChartHoverCard to be rendered
*/
- color?: string;
-
- /**
- * X value for hover card
- */
- XValue?: string;
+ variant?: ChartHoverCardVariant;
/**
- * indicate if denomination is present
+ * Indicates whether both YValue and ratio are present
*/
- isRatioPresent?: boolean;
+ hasBothMetrics?: boolean;
}
diff --git a/packages/react-examples/src/react-charting/AreaChart/AreaChart.Multiple.Example.tsx b/packages/react-examples/src/react-charting/AreaChart/AreaChart.Multiple.Example.tsx
index 4e816dc6308bc..811160b8633ba 100644
--- a/packages/react-examples/src/react-charting/AreaChart/AreaChart.Multiple.Example.tsx
+++ b/packages/react-examples/src/react-charting/AreaChart/AreaChart.Multiple.Example.tsx
@@ -33,42 +33,52 @@ export class AreaChartMultipleExample extends React.Component<{}, IAreaChartBasi
{
x: 20,
y: 9,
+ yAxisCalloutData: { 'Subcount1-1': 2, 'Subcount1-2': 3, 'Subcount1-3': 4 },
},
{
x: 25,
y: 14,
+ yAxisCalloutData: { 'Subcount1-1': 3, 'Subcount1-2': 5, 'Subcount1-3': 6 },
},
{
x: 30,
y: 14,
+ yAxisCalloutData: { 'Subcount1-1': 3, 'Subcount1-2': 5, 'Subcount1-3': 6 },
},
{
x: 35,
y: 23,
+ yAxisCalloutData: { 'Subcount1-1': 6, 'Subcount1-2': 8, 'Subcount1-3': 9 },
},
{
x: 40,
y: 20,
+ yAxisCalloutData: { 'Subcount1-1': 5, 'Subcount1-2': 7, 'Subcount1-3': 8 },
},
{
x: 45,
y: 31,
+ yAxisCalloutData: { 'Subcount1-1': 9, 'Subcount1-2': 10, 'Subcount1-3': 12 },
},
{
x: 50,
y: 29,
+ yAxisCalloutData: { 'Subcount1-1': 8, 'Subcount1-2': 10, 'Subcount1-3': 11 },
},
{
x: 55,
y: 27,
+ yAxisCalloutData: { 'Subcount1-1': 8, 'Subcount1-2': 9, 'Subcount1-3': 10 },
},
{
x: 60,
y: 37,
+ yAxisCalloutData: { 'Subcount1-1': 11, 'Subcount1-2': 12, 'Subcount1-3': 14 },
},
{
x: 65,
y: 51,
+ yAxisCalloutData: { 'Subcount1-1': 16, 'Subcount1-2': 17, 'Subcount1-3': 18 },
},
];
@@ -76,42 +86,52 @@ export class AreaChartMultipleExample extends React.Component<{}, IAreaChartBasi
{
x: 20,
y: 21,
+ yAxisCalloutData: { 'Subcount2-1': 6, 'Subcount2-2': 7, 'Subcount2-3': 8 },
},
{
x: 25,
y: 25,
+ yAxisCalloutData: { 'Subcount2-1': 7, 'Subcount2-2': 8, 'Subcount2-3': 10 },
},
{
x: 30,
y: 10,
+ yAxisCalloutData: { 'Subcount2-1': 2, 'Subcount2-2': 3, 'Subcount2-3': 5 },
},
{
x: 35,
y: 10,
+ yAxisCalloutData: { 'Subcount2-1': 2, 'Subcount2-2': 3, 'Subcount2-3': 5 },
},
{
x: 40,
y: 14,
+ yAxisCalloutData: { 'Subcount2-1': 3, 'Subcount2-2': 5, 'Subcount2-3': 6 },
},
{
x: 45,
y: 18,
+ yAxisCalloutData: { 'Subcount2-1': 5, 'Subcount2-2': 6, 'Subcount2-3': 7 },
},
{
x: 50,
y: 9,
+ yAxisCalloutData: { 'Subcount2-1': 2, 'Subcount2-2': 3, 'Subcount2-3': 4 },
},
{
x: 55,
y: 23,
+ yAxisCalloutData: { 'Subcount2-1': 6, 'Subcount2-2': 8, 'Subcount2-3': 9 },
},
{
x: 60,
y: 7,
+ yAxisCalloutData: { 'Subcount2-1': 1, 'Subcount2-2': 2, 'Subcount2-3': 4 },
},
{
x: 65,
y: 55,
+ yAxisCalloutData: { 'Subcount2-1': 17, 'Subcount2-2': 18, 'Subcount2-3': 20 },
},
];
@@ -119,42 +139,52 @@ export class AreaChartMultipleExample extends React.Component<{}, IAreaChartBasi
{
x: 20,
y: 30,
+ yAxisCalloutData: { 'Subcount3-1': 9, 'Subcount3-2': 10, 'Subcount3-3': 11 },
},
{
x: 25,
y: 35,
+ yAxisCalloutData: { 'Subcount3-1': 10, 'Subcount3-2': 12, 'Subcount3-3': 13 },
},
{
x: 30,
y: 33,
+ yAxisCalloutData: { 'Subcount3-1': 10, 'Subcount3-2': 11, 'Subcount3-3': 12 },
},
{
x: 35,
y: 40,
+ yAxisCalloutData: { 'Subcount3-1': 12, 'Subcount3-2': 13, 'Subcount3-3': 15 },
},
{
x: 40,
y: 10,
+ yAxisCalloutData: { 'Subcount3-1': 2, 'Subcount3-2': 3, 'Subcount3-3': 5 },
},
{
x: 45,
y: 40,
+ yAxisCalloutData: { 'Subcount3-1': 12, 'Subcount3-2': 13, 'Subcount3-3': 15 },
},
{
x: 50,
y: 34,
+ yAxisCalloutData: { 'Subcount3-1': 10, 'Subcount3-2': 11, 'Subcount3-3': 13 },
},
{
x: 55,
y: 40,
+ yAxisCalloutData: { ['Subcount3-1']: 12, 'Subcount3-2': 13, 'Subcount3-3': 15 },
},
{
x: 60,
y: 60,
+ yAxisCalloutData: { 'Subcount3-1': 19, 'Subcount3-2': 20, 'Subcount3-3': 21 },
},
{
x: 65,
y: 40,
+ yAxisCalloutData: { 'Subcount3-1': 12, 'Subcount3-2': 13, 'Subcount3-3': 15 },
},
];