diff --git a/change/@fluentui-react-charting-11f4c890-d9e5-4e7e-afde-fbfc66beb0d7.json b/change/@fluentui-react-charting-11f4c890-d9e5-4e7e-afde-fbfc66beb0d7.json new file mode 100644 index 0000000000000..e03f66fe77138 --- /dev/null +++ b/change/@fluentui-react-charting-11f4c890-d9e5-4e7e-afde-fbfc66beb0d7.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: resolve overlapping bars issue in histogram", + "packageName": "@fluentui/react-charting", + "email": "110246001+krkshitij@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/packages/charts/react-charting/src/components/DeclarativeChart/DeclarativeChart.tsx b/packages/charts/react-charting/src/components/DeclarativeChart/DeclarativeChart.tsx index 728f5ddfbbf79..c84024a8684b7 100644 --- a/packages/charts/react-charting/src/components/DeclarativeChart/DeclarativeChart.tsx +++ b/packages/charts/react-charting/src/components/DeclarativeChart/DeclarativeChart.tsx @@ -179,7 +179,7 @@ export const DeclarativeChart: React.FunctionComponent = (opts?: IImageExportOptions) => { return toImage(chartRef.current?.chartContainer, { background: theme.semanticColors.bodyBackground, - scale: 3, + scale: 5, ...opts, }); }, diff --git a/packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapter.ts b/packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapter.ts index 54f61f4e559e1..728bc2cf4f1b3 100644 --- a/packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapter.ts +++ b/packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapter.ts @@ -444,7 +444,6 @@ export const transformPlotlyJsonToVBCProps = ( data: vbcData, // width: layout?.width, // height: layout?.height, - barWidth: 24, supportNegativeData: true, chartTitle, xAxisTitle, diff --git a/packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/PlotlySchemaAdapterUT.test.tsx.snap b/packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/PlotlySchemaAdapterUT.test.tsx.snap index 6faa14a576ee1..fb2586596c12f 100644 --- a/packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/PlotlySchemaAdapterUT.test.tsx.snap +++ b/packages/charts/react-charting/src/components/DeclarativeChart/__snapshots__/PlotlySchemaAdapterUT.test.tsx.snap @@ -4571,7 +4571,6 @@ Object { exports[`transform Plotly Json To chart Props transformPlotlyJsonToVBCProps - Should return VBC props 1`] = ` Object { - "barWidth": 24, "chartTitle": "", "data": Array [ Object { diff --git a/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx b/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx index 484461c1a1cab..7b1eeabf68272 100644 --- a/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx +++ b/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx @@ -1272,7 +1272,15 @@ export class VerticalBarChartBase this._domainMargin = MIN_DOMAIN_MARGIN + Math.max(0, Math.min(margin1, margin2)); } } else { - const data = (this.props.data?.map(point => point.x) as number[] | Date[] | undefined) || []; + const uniqueX: Record = {}; + this.props.data?.forEach(point => { + if (point.x instanceof Date) { + uniqueX[point.x.getTime()] = point.x; + } else { + uniqueX[point.x as number] = point.x as number; + } + }); + const data = Object.values(uniqueX) as number[] | Date[]; this._barWidth = getBarWidth( this.props.barWidth, this.props.maxBarWidth,