diff --git a/change/@fluentui-react-charting-beea75ce-fc3b-4589-8902-28d31ef030fa.json b/change/@fluentui-react-charting-beea75ce-fc3b-4589-8902-28d31ef030fa.json new file mode 100644 index 00000000000000..77a2c534856186 --- /dev/null +++ b/change/@fluentui-react-charting-beea75ce-fc3b-4589-8902-28d31ef030fa.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Fix chart title overflow", + "packageName": "@fluentui/react-charting", + "email": "kumarkshitij@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx b/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx index 4054279ee4d05a..068b07776febda 100644 --- a/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx +++ b/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx @@ -13,6 +13,7 @@ import { import { Callout, DirectionalHint } from '@fluentui/react/lib/Callout'; import { ChartHoverCard, convertToLocaleString, getAccessibleDataObject } from '../../utilities/index'; import { FocusZone, FocusZoneDirection } from '@fluentui/react-focus'; +import { TooltipHost, TooltipOverflowMode } from '@fluentui/react'; const getClassNames = classNamesFunction(); @@ -88,12 +89,15 @@ export class HorizontalBarChartBase extends React.Component
{points!.chartTitle && ( -
- {points!.chartTitle} -
+ + {points!.chartTitle} + + )} {chartDataText}
@@ -228,21 +232,21 @@ export class HorizontalBarChartBase extends React.Component +
{convertToLocaleString(x, culture)}
); case 'fraction': return (
- {convertToLocaleString(x, culture)} + {convertToLocaleString(x, culture)} {'/' + convertToLocaleString(y, culture)}
); case 'percentage': const dataRatioPercentage = `${convertToLocaleString(Math.round((x / y) * 100), culture)}%`; return ( -
+
{dataRatioPercentage}
); diff --git a/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.styles.ts b/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.styles.ts index 47a22f4807b440..d1040736c4a67e 100644 --- a/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.styles.ts +++ b/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.styles.ts @@ -34,7 +34,14 @@ export const getHorizontalBarChartStyles = (props: IHorizontalBarChartStyleProps justifyContent: 'space-between', marginBottom: '3px', }, - chartDataText: { + chartTitleLeft: { + fontWeight: FontWeights.bold, + textOverflow: 'ellipsis', + overflow: 'hidden', + whiteSpace: 'nowrap', + display: 'block', + }, + chartTitleRight: { fontWeight: FontWeights.bold, }, chartDataTextDenominator: { diff --git a/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.types.ts b/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.types.ts index 4ab5dbbeba4b00..9b3be300cf220b 100644 --- a/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.types.ts +++ b/packages/react-charting/src/components/HorizontalBarChart/HorizontalBarChart.types.ts @@ -132,9 +132,14 @@ export interface IHorizontalBarChartStyles { barWrapper: IStyle; /** - * Style for the chart data text. + * Style for left side text of the chart title */ - chartDataText: IStyle; + chartTitleLeft: IStyle; + + /** + * Style for right side text of the chart title + */ + chartTitleRight: IStyle; /** * Style for the chart data text denominator. diff --git a/packages/react-charting/src/components/HorizontalBarChart/__snapshots__/HorizontalBarChart.test.tsx.snap b/packages/react-charting/src/components/HorizontalBarChart/__snapshots__/HorizontalBarChart.test.tsx.snap index cef795548d3569..a5bf5bd1bb384d 100644 --- a/packages/react-charting/src/components/HorizontalBarChart/__snapshots__/HorizontalBarChart.test.tsx.snap +++ b/packages/react-charting/src/components/HorizontalBarChart/__snapshots__/HorizontalBarChart.test.tsx.snap @@ -57,14 +57,45 @@ exports[`HorizontalBarChart - mouse events Should render callout correctly on mo >
- one + + one + +
- two + + two + +
- one + + one + +
- two + + two + +
(); @@ -237,9 +238,13 @@ export class MultiStackedBarChartBase extends React.Component
{data!.chartTitle && ( -
- {data!.chartTitle} -
+ + {data!.chartTitle} + )} {showRatio && (
diff --git a/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.styles.ts b/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.styles.ts index a083018e6070c8..bfd1e861b140c8 100644 --- a/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.styles.ts +++ b/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.styles.ts @@ -1,4 +1,5 @@ import { IMultiStackedBarChartStyleProps, IMultiStackedBarChartStyles } from './MultiStackedBarChart.types'; +import { FontWeights } from '@fluentui/react/lib/Styling'; export const getMultiStackedBarChartStyles = (props: IMultiStackedBarChartStyleProps): IMultiStackedBarChartStyles => { const { className, width, barHeight, shouldHighlight, theme, href } = props; @@ -26,6 +27,13 @@ export const getMultiStackedBarChartStyles = (props: IMultiStackedBarChartStyleP justifyContent: 'space-between', marginBottom: '3px', }, + chartTitleLeft: { + fontWeight: FontWeights.bold, + textOverflow: 'ellipsis', + overflow: 'hidden', + whiteSpace: 'nowrap', + display: 'block', + }, singleChartRoot: { width: width ? width : '100%', display: 'flex', diff --git a/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.types.ts b/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.types.ts index 09eca46a0101dd..d54b23100f4b75 100644 --- a/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.types.ts +++ b/packages/react-charting/src/components/StackedBarChart/MultiStackedBarChart.types.ts @@ -168,6 +168,11 @@ export interface IMultiStackedBarChartStyles { */ chartTitle: IStyle; + /** + * Style for left side text of the chart title + */ + chartTitleLeft: IStyle; + /** * Style to change the opacity of bars in dataviz when we hover on a single bar or legends */ diff --git a/packages/react-charting/src/components/StackedBarChart/StackedBarChart.base.tsx b/packages/react-charting/src/components/StackedBarChart/StackedBarChart.base.tsx index a62c7db2f19c8b..a850ec9bd3969d 100644 --- a/packages/react-charting/src/components/StackedBarChart/StackedBarChart.base.tsx +++ b/packages/react-charting/src/components/StackedBarChart/StackedBarChart.base.tsx @@ -7,6 +7,7 @@ import { IRefArrayData, IStackedBarChartProps, IStackedBarChartStyleProps, IStac import { Callout, DirectionalHint } from '@fluentui/react/lib/Callout'; import { FocusZone, FocusZoneDirection } from '@fluentui/react-focus'; import { ChartHoverCard, convertToLocaleString, getAccessibleDataObject } from '../../utilities/index'; +import { TooltipHost, TooltipOverflowMode } from '@fluentui/react'; const getClassNames = classNamesFunction(); export interface IStackedBarChartState { @@ -105,9 +106,13 @@ export class StackedBarChartBase extends React.Component
{data!.chartTitle && ( -
- {data!.chartTitle} -
+ + {data!.chartTitle} + )} {showRatio && (
diff --git a/packages/react-charting/src/components/StackedBarChart/StackedBarChart.styles.ts b/packages/react-charting/src/components/StackedBarChart/StackedBarChart.styles.ts index ecb1bc992e2d42..3e6154f92fbdfb 100644 --- a/packages/react-charting/src/components/StackedBarChart/StackedBarChart.styles.ts +++ b/packages/react-charting/src/components/StackedBarChart/StackedBarChart.styles.ts @@ -36,6 +36,13 @@ export const getStyles = (props: IStackedBarChartStyleProps): IStackedBarChartSt justifyContent: 'space-between', marginBottom: '3px', }, + chartTitleLeft: { + fontWeight: FontWeights.bold, + textOverflow: 'ellipsis', + overflow: 'hidden', + whiteSpace: 'nowrap', + display: 'block', + }, legendContainer: { margin: '4px 0px 0px 4px', }, diff --git a/packages/react-charting/src/components/StackedBarChart/StackedBarChart.types.ts b/packages/react-charting/src/components/StackedBarChart/StackedBarChart.types.ts index 5fe5d7d2a77043..43dbf3d23febcf 100644 --- a/packages/react-charting/src/components/StackedBarChart/StackedBarChart.types.ts +++ b/packages/react-charting/src/components/StackedBarChart/StackedBarChart.types.ts @@ -210,6 +210,11 @@ export interface IStackedBarChartStyles { */ chartTitle: IStyle; + /** + * Style for left side text of the chart title + */ + chartTitleLeft: IStyle; + /** * Style for the legend container div */ diff --git a/packages/react-charting/src/components/StackedBarChart/__snapshots__/MultiStackedBarChart.test.tsx.snap b/packages/react-charting/src/components/StackedBarChart/__snapshots__/MultiStackedBarChart.test.tsx.snap index fee1e650bf6f23..09b67808422bb9 100644 --- a/packages/react-charting/src/components/StackedBarChart/__snapshots__/MultiStackedBarChart.test.tsx.snap +++ b/packages/react-charting/src/components/StackedBarChart/__snapshots__/MultiStackedBarChart.test.tsx.snap @@ -55,12 +55,46 @@ exports[`MultiStackedBarChart - mouse events Should render callout correctly on } >
- + Monitored - + +
- + Unmonitored - + +
- + Monitored - + +
- + Unmonitored - + +
- + Monitored - + +
- + Unmonitored - + +
- + Monitored - + +
- + Unmonitored - + +
- + Monitored - + +
- + Unmonitored - + +
- + Monitored - + +
@@ -2171,7 +2545,7 @@ exports[`MultiStackedBarChart snapShot testing renders hideRatio correctly 1`] = &:focus { outline: none; } - data-focuszone-id="FocusZone19" + data-focuszone-id="FocusZone26" onFocus={[Function]} onKeyDown={[Function]} onMouseDownCapture={[Function]} @@ -2188,7 +2562,7 @@ exports[`MultiStackedBarChart snapShot testing renders hideRatio correctly 1`] = >
- + Unmonitored - + +
- + Monitored - + +
- + Unmonitored - + +
- + + Stacked bar chart 2nd example + +
- + + Stacked bar chart 2nd example + +
- + + Stacked bar chart 2nd example + +
- + + Stacked bar chart 2nd example + +
- + + Stacked bar chart 2nd example + +
- + + Stacked bar chart 2nd example + +
- + + Stacked bar chart 2nd example + +
@@ -1354,7 +1592,7 @@ exports[`StackedBarChart snapShot testing renders hideNumberDisplay correctly 1` &:focus { outline: none; } - data-focuszone-id="FocusZone11" + data-focuszone-id="FocusZone15" onFocus={[Function]} onKeyDown={[Function]} onMouseDownCapture={[Function]} @@ -1373,7 +1611,7 @@ exports[`StackedBarChart snapShot testing renders hideNumberDisplay correctly 1`
- + + Stacked bar chart 2nd example + +
- + Stacked bar chart 2nd example - + +
@@ -1680,7 +1986,7 @@ exports[`StackedBarChart snapShot testing renders ignoreFixStyle correctly 1`] = &:focus { outline: none; } - data-focuszone-id="FocusZone17" + data-focuszone-id="FocusZone23" onFocus={[Function]} onKeyDown={[Function]} onMouseDownCapture={[Function]} @@ -1699,7 +2005,7 @@ exports[`StackedBarChart snapShot testing renders ignoreFixStyle correctly 1`] =