From 447fa01b87dd42df84a5a28cd5cfece69d8da8c4 Mon Sep 17 00:00:00 2001 From: "Atishay Jain (atisjai)" Date: Wed, 30 Nov 2022 14:22:09 +0530 Subject: [PATCH 1/4] Allow single point in area chart --- .../src/components/AreaChart/AreaChart.base.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx b/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx index 56553ce04ddbe8..825ab6367e660d 100644 --- a/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx +++ b/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx @@ -576,6 +576,22 @@ export class AreaChartBase extends React.Component + {singleStackedData.length == 1} ? + {' '} + : Date: Wed, 30 Nov 2022 14:23:25 +0530 Subject: [PATCH 2/4] Add change file --- ...eact-charting-806735ad-55f4-4170-a545-c3c5a84e8701.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-react-charting-806735ad-55f4-4170-a545-c3c5a84e8701.json diff --git a/change/@fluentui-react-charting-806735ad-55f4-4170-a545-c3c5a84e8701.json b/change/@fluentui-react-charting-806735ad-55f4-4170-a545-c3c5a84e8701.json new file mode 100644 index 00000000000000..e4e0d1b25bbe20 --- /dev/null +++ b/change/@fluentui-react-charting-806735ad-55f4-4170-a545-c3c5a84e8701.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Support single point in area chart", + "packageName": "@fluentui/react-charting", + "email": "atishay.jain@microsoft.com", + "dependentChangeType": "patch" +} From 416c8db69901153ee7fc4abe94f5dd5d20d6f71c Mon Sep 17 00:00:00 2001 From: "Atishay Jain (atisjai)" Date: Wed, 30 Nov 2022 14:50:34 +0530 Subject: [PATCH 3/4] Fix lint issue --- .../react-charting/src/components/AreaChart/AreaChart.base.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx b/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx index 825ab6367e660d..07b25924303e71 100644 --- a/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx +++ b/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx @@ -576,7 +576,7 @@ export class AreaChartBase extends React.Component - {singleStackedData.length == 1} ? + {singleStackedData.length === 1} ? Date: Wed, 30 Nov 2022 16:51:14 +0530 Subject: [PATCH 4/4] Add tests for area chart single point --- .../components/AreaChart/AreaChart.base.tsx | 53 +-- .../components/AreaChart/AreaChart.test.tsx | 18 + .../__snapshots__/AreaChart.test.tsx.snap | 334 ++++++++++++++++++ 3 files changed, 379 insertions(+), 26 deletions(-) diff --git a/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx b/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx index 07b25924303e71..b464ef428cee3f 100644 --- a/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx +++ b/packages/react-charting/src/components/AreaChart/AreaChart.base.tsx @@ -576,32 +576,33 @@ export class AreaChartBase extends React.Component - {singleStackedData.length === 1} ? - {' '} - : - + {singleStackedData.length === 1 ? ( + + ) : ( + + )} , ); }); diff --git a/packages/react-charting/src/components/AreaChart/AreaChart.test.tsx b/packages/react-charting/src/components/AreaChart/AreaChart.test.tsx index 08aed2d4459789..b668d73a2770a9 100644 --- a/packages/react-charting/src/components/AreaChart/AreaChart.test.tsx +++ b/packages/react-charting/src/components/AreaChart/AreaChart.test.tsx @@ -44,6 +44,18 @@ const chartPoints = { lineChartData: points, }; +const singlePoint = [ + { + legend: 'metaData1', + data: [{ x: 20, y: 50 }], + color: 'red', + }, +]; +const singleChartPoint = { + chartTitle: 'AreaChart', + lineChartData: singlePoint, +}; + describe('AreaChart snapShot testing', () => { it('renders Areachart correctly', () => { const component = renderer.create(); @@ -86,6 +98,12 @@ describe('AreaChart snapShot testing', () => { const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); + + it('renders Areachart with single point correctly', () => { + const component = renderer.create(); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); }); describe('AreaChart - basic props', () => { diff --git a/packages/react-charting/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap b/packages/react-charting/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap index a7b6297e69425e..109f986add1f77 100644 --- a/packages/react-charting/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap +++ b/packages/react-charting/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap @@ -1734,6 +1734,340 @@ exports[`AreaChart snapShot testing renders Areachart correctly 1`] = ` `; +exports[`AreaChart snapShot testing renders Areachart with single point correctly 1`] = ` + +`; + exports[`AreaChart snapShot testing renders enabledLegendsWrapLines correctly 1`] = `