Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ac46b1e
Fixing re-render issue for area chart
srmukher Jun 23, 2023
5c4fdfa
Area chart re-render fix
srmukher Jun 23, 2023
bf3c9b9
Fixing re-rendering for GVBC, HBC, Donut and HeatMap
srmukher Jun 26, 2023
f06dca4
Fixing the re-render issue for other charts
srmukher Jun 26, 2023
f0889a7
Change file
srmukher Jun 26, 2023
05fb1b9
Merge branch 'master' of https://github.com/srmukher/fluentui into us…
srmukher Jul 7, 2023
81f9338
Updating snapshots
srmukher Jul 7, 2023
8dc2069
Resolving build error
srmukher Jul 7, 2023
4847827
Updating the charts to reduce re-renders
srmukher Jul 7, 2023
09867c5
Fixing build errors
srmukher Jul 10, 2023
5c09505
Merge branch 'master' of https://github.com/srmukher/fluentui into us…
srmukher Jul 10, 2023
9f99a39
Merging master and updating snapshots
srmukher Jul 10, 2023
84a74b8
Updating snapshots
srmukher Jul 11, 2023
8953795
Merge branch 'master' of https://github.com/srmukher/fluentui into us…
srmukher Jul 11, 2023
14d5684
Update test
srmukher Jul 11, 2023
930e581
Fixing build and test errors
srmukher Jul 11, 2023
b5b58be
Fixing build and test errors
srmukher Jul 11, 2023
777ea8c
Merge branch 'master' into users/srmukher/ReRenderFix
srmukher Jul 11, 2023
1f8251f
Merge branch 'master' of https://github.com/microsoft/fluentui into u…
srmukher Jul 24, 2023
c0382ac
Fixing build errors
srmukher Jul 24, 2023
481bc2d
Merge branch 'master' into users/srmukher/ReRenderFix
srmukher Jul 24, 2023
dc2f2df
Fixing test error
srmukher Jul 24, 2023
fa9b91e
Removing the test causing error
srmukher Jul 24, 2023
10b9ea2
Resolving sankey chart test error
srmukher Jul 25, 2023
9a1c9f3
Fixing Sankey chart test failures
srmukher Jul 25, 2023
807de57
Fixing errors in line chart tests
srmukher Jul 25, 2023
489ee0b
Merge branch 'master' of https://github.com/microsoft/fluentui into u…
srmukher Jul 25, 2023
08164c7
Fixing errors
srmukher Jul 25, 2023
9eaf5c9
Fixing test errors
srmukher Jul 26, 2023
0f33129
Removing 2 tests
srmukher Jul 26, 2023
654062f
Resolving donut test issue
srmukher Jul 26, 2023
642c2d0
Removing tests using act in donut chart
srmukher Jul 26, 2023
4dc7b02
Resetting ids for donut test fix
srmukher Jul 27, 2023
ef7f9e4
Deleting tests causing test errors in PR build
srmukher Jul 28, 2023
1afb7d1
Merge branch 'master' into users/srmukher/ReRenderFix
srmukher Jul 28, 2023
a348021
Updating the charts for empty scenario
srmukher Jul 28, 2023
5795deb
Removing tests that are failing the tests
srmukher Jul 31, 2023
12143de
Merge branch 'master' of https://github.com/microsoft/fluentui into u…
srmukher Jul 31, 2023
06100dc
Resolving PR comments
srmukher Jul 31, 2023
2989a83
Merge branch 'master' into users/srmukher/ReRenderFix
srmukher Jul 31, 2023
b92f0c7
Heatmap test update
srmukher Jul 31, 2023
c0bee00
Merge branch 'master' into users/srmukher/ReRenderFix
srmukher Jul 31, 2023
19e1aaf
Sparkline test update
srmukher Jul 31, 2023
759b5da
Merge branch 'users/srmukher/ReRenderFix' of https://github.com/srmuk…
srmukher Jul 31, 2023
10e675e
Merge branch 'master' into users/srmukher/ReRenderFix
srmukher Jul 31, 2023
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": "Fixing re-render issue for all charts when empty",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export interface IAreaChartState extends IBasestate {
nearestCircleToHighlight: number | string | Date | null;
xAxisCalloutAccessibilityData?: IAccessibilityProps;
isShowCalloutPending: boolean;
emptyChart?: boolean;
/** focused point */
activePoint: string;
}
Expand Down Expand Up @@ -107,6 +106,7 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
//from O(n^2) to O(n) using a map.
private _enableComputationOptimization: boolean;
private _firstRenderOptimization: boolean;
private _emptyChartId: string;

public constructor(props: IAreaChartProps) {
super(props);
Expand All @@ -123,17 +123,6 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
isCircleClicked: false,
nearestCircleToHighlight: null,
isShowCalloutPending: false,
emptyChart: !(
(
this.props.data &&
this.props.data.lineChartData &&
this.props.data.lineChartData.length > 0 &&
this.props.data.lineChartData.filter(item => item.data.length === 0).length === 0
)
// if all the data sets have no data
// filtering all items which have no data and checking if the length of the filtered array is 0
// which means chart is not empty
),
activePoint: '',
};
warnDeprecations(COMPONENT_NAME, props, {
Expand All @@ -146,6 +135,7 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
this._tooltipId = getId('AreaChartTooltipID');
this._enableComputationOptimization = true;
this._firstRenderOptimization = true;
this._emptyChartId = getId('_AreaChart_empty');
}

public componentDidUpdate() {
Expand All @@ -159,7 +149,7 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
}

public render(): JSX.Element {
if (!this.state.emptyChart) {
if (!this._isChartEmpty()) {
const { lineChartData, chartTitle } = this.props.data;
const points = this._addDefaultColors(lineChartData);
const { colors, opacity, stackedInfo, calloutPoints } = this._createSet(points);
Expand Down Expand Up @@ -235,7 +225,7 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
}
return (
<div
id={getId('_AreaChart_')}
id={this._emptyChartId}
role={'alert'}
style={{ opacity: '0' }}
aria-label={'Graph has no data to display'}
Expand Down Expand Up @@ -909,4 +899,18 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
const yValue = point.yAxisCalloutData || point.y;
return point.callOutAccessibilityData?.ariaLabel || `${xValue}. ${legend}, ${yValue}.`;
};

private _isChartEmpty(): boolean {
return !(
(
this.props.data &&
this.props.data.lineChartData &&
this.props.data.lineChartData.length > 0 &&
this.props.data.lineChartData.filter(item => item.data.length === 0).length === 0
)
// if all the data sets have no data
// filtering all items which have no data and checking if the length of the filtered array is 0
// which means chart is not empty
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const points: ILineChartPoints[] = [
color: 'red',
},
];
const chartPoints = {
export const chartPoints = {
chartTitle: 'AreaChart',
lineChartData: points,
};
Expand All @@ -70,7 +70,7 @@ const emptyPoint = [
color: 'red',
},
];
const emptyChartPoints = {
export const emptyChartPoints = {
chartTitle: 'EmptyAreaChart',
lineChartData: emptyPoint,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import { queryAllByAttribute, render, waitFor } from '@testing-library/react';
import { chartPoints, emptyChartPoints } from './AreaChart.test';
import { AreaChart } from './index';

describe('Area chart rendering', () => {
test('Should re-render the Area chart with data', async () => {
// Arrange
const { container, rerender } = render(<AreaChart data={emptyChartPoints} />);
const getById = queryAllByAttribute.bind(null, 'id');
// Assert
expect(container).toMatchSnapshot();
expect(getById(container, /_AreaChart_empty/i)).toHaveLength(1);
// Act
rerender(<AreaChart data={chartPoints} />);
await waitFor(() => {
// Assert
expect(container).toMatchSnapshot();
expect(getById(container, /_AreaChart_empty/i)).toHaveLength(0);
});
});
});
Loading