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": "Fix multi stacked bar chart min width",
"packageName": "@fluentui/react-charting",
"email": "atishay.jain@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ export class MultiStackedBarChartBase extends React.Component<IMultiStackedBarCh
0,
);

let sumOfPercent = 0;
data.chartData!.map((point: IChartDataPoint, index: number) => {
const pointData = point.data ? point.data : 0;
value = (pointData / total) * 100 ? (pointData / total) * 100 : 0;
if (value < 1 && value !== 0) {
value = 1;
} else if (value > 99 && value !== 100) {
value = 99;
}
sumOfPercent += value;

return sumOfPercent;
});

const scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;

let prevPosition = 0;
let value = 0;

Expand All @@ -154,6 +170,13 @@ export class MultiStackedBarChartBase extends React.Component<IMultiStackedBarCh
prevPosition += value;
}
value = (pointData / total) * 100 ? (pointData / total) * 100 : 0;
if (value < 1 && value !== 0) {
value = 1 / scalingRatio;
} else if (value > 99 && value !== 100) {
value = 99 / scalingRatio;
} else {
value = value / scalingRatio;
}

startingPoint.push(prevPosition);

Expand Down