diff --git a/change/@fluentui-react-charting-8bdce3b1-3bbd-4a1d-8000-3cd8b50e1d0c.json b/change/@fluentui-react-charting-8bdce3b1-3bbd-4a1d-8000-3cd8b50e1d0c.json new file mode 100644 index 00000000000000..8f798c9c3ef7af --- /dev/null +++ b/change/@fluentui-react-charting-8bdce3b1-3bbd-4a1d-8000-3cd8b50e1d0c.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Minimum height of non zero positive values set to 1% of Max barHeight", + "packageName": "@fluentui/react-charting", + "email": "shubhabrata08@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx b/packages/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx index 830eef808829d9..ada727396eecd2 100644 --- a/packages/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx +++ b/packages/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx @@ -536,11 +536,16 @@ export class VerticalBarChartBase extends React.Component ; + } else if (barHeight <= Math.ceil(yBarScale(this._yMax) / 100.0)) { + adjustedBarHeight = Math.ceil(yBarScale(this._yMax) / 100.0); + } else { + adjustedBarHeight = barHeight; } const xPoint = xBarScale(point.x as number); - const yPoint = containerHeight - this.margins.bottom! - yBarScale(point.y); + const yPoint = containerHeight - this.margins.bottom! - adjustedBarHeight; return ( { this._refCallback(e, point.legend!); }} @@ -596,11 +601,16 @@ export class VerticalBarChartBase extends React.Component { const barHeight: number = Math.max(yBarScale(point.y), 0); - if (barHeight < 1) { + let adjustedBarHeight = 0; + if (barHeight <= 0) { return ; + } else if (barHeight <= Math.ceil(yBarScale(this._yMax) / 100.0)) { + adjustedBarHeight = Math.ceil(yBarScale(this._yMax) / 100.0); + } else { + adjustedBarHeight = barHeight; } const xPoint = xBarScale(point.x); - const yPoint = containerHeight - this.margins.bottom! - yBarScale(point.y); + const yPoint = containerHeight - this.margins.bottom! - adjustedBarHeight; return ( { diff --git a/packages/react-charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx b/packages/react-charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx index 7dd1a5a5a85e94..b13c9fce252376 100644 --- a/packages/react-charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx +++ b/packages/react-charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx @@ -782,8 +782,8 @@ export class VerticalStackedBarChartBase extends React.Component< }; let barHeight = heightValueScale * point.data; - if (barHeight < barMinimumHeight) { - barHeight = barMinimumHeight; + if (barHeight < Math.max(Math.ceil(this._yMax / 100.0), barMinimumHeight)) { + barHeight = Math.max(Math.ceil(this._yMax / 100.0), barMinimumHeight); } yPoint = yPoint - barHeight - (index ? gapHeight : 0); barTotalValue += point.data; @@ -810,7 +810,7 @@ export class VerticalStackedBarChartBase extends React.Component< /> ); } - if (barHeight < 1) { + if (barHeight < 0) { return ; } return (