Skip to content

Commit

Permalink
fix(react-charting): resolve overlapping bars issue in histogram (#33695
Browse files Browse the repository at this point in the history
)
  • Loading branch information
krkshitij authored Jan 21, 2025
1 parent 5afd9da commit 08575f8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: resolve overlapping bars issue in histogram",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> =
(opts?: IImageExportOptions) => {
return toImage(chartRef.current?.chartContainer, {
background: theme.semanticColors.bodyBackground,
scale: 3,
scale: 5,
...opts,
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ export const transformPlotlyJsonToVBCProps = (
data: vbcData,
// width: layout?.width,
// height: layout?.height,
barWidth: 24,
supportNegativeData: true,
chartTitle,
xAxisTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, number | Date> = {};
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,
Expand Down

0 comments on commit 08575f8

Please sign in to comment.