Skip to content

Commit 5a78416

Browse files
Anush2303Anush
andauthored
fix(declarative-chart): negative VSBC fix (microsoft#34481)
Co-authored-by: Anush <anushgupta@microsoft.com>
1 parent 6fde0b5 commit 5a78416

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix(declarative-chart): negative VSBC only lines case fix",
4+
"packageName": "@fluentui/react-charting",
5+
"email": "anushgupta@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/charts/react-charting/etc/react-charting.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ export interface IVerticalStackedBarChartProps extends ICartesianChartProps {
16151615
xAxisInnerPadding?: number;
16161616
xAxisOuterPadding?: number;
16171617
xAxisPadding?: number;
1618-
yMinValue?: undefined;
1618+
yMinValue?: number | undefined;
16191619
}
16201620

16211621
// @public

packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export const transformPlotlyJsonToVSBCProps = (
292292
): IVerticalStackedBarChartProps => {
293293
const mapXToDataPoints: { [key: string]: IVerticalStackedChartProps } = {};
294294
let yMaxValue = 0;
295+
let yMinValue = 0;
295296
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
296297
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
297298
input.data.forEach((series: PlotData, index1: number) => {
@@ -343,6 +344,7 @@ export const transformPlotlyJsonToVSBCProps = (
343344
});
344345
if (!usesSecondaryYScale(series)) {
345346
yMaxValue = Math.max(yMaxValue, yVal);
347+
yMinValue = Math.min(yMinValue, yVal);
346348
}
347349
}
348350
});
@@ -356,6 +358,7 @@ export const transformPlotlyJsonToVSBCProps = (
356358
height: input.layout?.height ?? 350,
357359
barWidth: 'auto',
358360
yMaxValue,
361+
yMinValue,
359362
chartTitle,
360363
xAxisTitle,
361364
yAxisTitle,
@@ -364,6 +367,7 @@ export const transformPlotlyJsonToVSBCProps = (
364367
hideTickOverlap: true,
365368
hideLegend,
366369
roundCorners: true,
370+
supportNegativeData: true,
367371
};
368372
};
369373

packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/PlotlySchemaAdapterUT.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4994,9 +4994,11 @@ Object {
49944994
"hideTickOverlap": true,
49954995
"mode": "plotly",
49964996
"roundCorners": true,
4997+
"supportNegativeData": true,
49974998
"width": undefined,
49984999
"xAxisTitle": "",
49995000
"yAxisTitle": "",
50005001
"yMaxValue": 3400,
5002+
"yMinValue": 0,
50015003
}
50025004
`;

packages/charts/react-charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export interface IVerticalStackedBarChartProps extends ICartesianChartProps {
8888
calloutProps?: Partial<ICalloutProps>;
8989

9090
/**
91-
* yMinValue is not supported for bar charts, so only allow "undefined"
91+
* yMinValue is supported for bar charts that has only lines
9292
*/
93-
yMinValue?: undefined;
93+
yMinValue?: number | undefined;
9494

9595
/**
9696
* Allow hover actions on the legend

0 commit comments

Comments
 (0)