Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeatMap chart bug fixes #33525

Merged
merged 10 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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 @@
{
Anush2303 marked this conversation as resolved.
Show resolved Hide resolved
"type": "patch",
"comment": "HeatMap chart bug fixes",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions packages/charts/react-charting/etc/react-charting.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ export interface IHeatMapChartProps extends Pick<ICartesianChartProps, Exclude<k
legendProps?: Partial<ILegendsProps>;
rangeValuesForColorScale: string[];
showYAxisLables?: boolean;
sortOrder?: 'none' | 'alphabetical';
styles?: IStyleFunctionOrObject<IHeatMapChartStyleProps, IHeatMapChartStyles>;
xAxisDateFormatString?: string;
xAxisNumberFormatString?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,7 @@ export const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> =
/>
);
case 'heatmap':
return (
<HeatMapChart
{...transformPlotlyJsonToHeatmapProps(plotlySchema)}
legendProps={legendProps}
componentRef={chartRef}
calloutProps={{ layerProps: { eventBubblingEnabled: true } }}
/>
);
return <HeatMapChart {...transformPlotlyJsonToHeatmapProps(plotlySchema)} />;
Anush2303 marked this conversation as resolved.
Show resolved Hide resolved
case 'sankey':
return (
<SankeyChart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ export const transformPlotlyJsonToHeatmapProps = (jsonObj: any): IHeatMapChartPr
x: layout.xaxis?.type === 'date' ? new Date(xVal) : xVal,
y: layout.yaxis?.type === 'date' ? new Date(yVal) : yVal,
value: zVal,
rectText: zVal,
});

zMin = Math.min(zMin, zVal);
Expand All @@ -423,6 +424,7 @@ export const transformPlotlyJsonToHeatmapProps = (jsonObj: any): IHeatMapChartPr
rangeValuesForColorScale,
hideLegend: true,
showYAxisLables: true,
sortOrder: 'none',
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,11 @@ export class HeatMapChartBase extends React.Component<IHeatMapChartProps, IHeatM
yPoints[item]
.sort((a: IHeatMapChartDataPoint, b: IHeatMapChartDataPoint) => {
if (this._xAxisType === XAxisTypes.StringAxis) {
return (a.x as string).toLowerCase() > (b.x as string).toLowerCase() ? 1 : -1;
return this.props.sortOrder === 'none'
? 0
: (a.x as string).toLowerCase() > (b.x as string).toLowerCase()
? 1
: -1;
} else if (this._xAxisType === XAxisTypes.DateAxis) {
return (a.x as Date).getTime() - (b.x as Date).getTime();
} else if (this._xAxisType === XAxisTypes.NumericAxis) {
Expand Down Expand Up @@ -687,7 +691,7 @@ export class HeatMapChartBase extends React.Component<IHeatMapChartProps, IHeatM
if (this._xAxisType === XAxisTypes.DateAxis || this._xAxisType === XAxisTypes.NumericAxis) {
return +a - +b;
} else {
return a.toLowerCase() > b.toLowerCase() ? 1 : -1;
return this.props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
}
});
xAxisPoints = unFormattedXAxisDataPoints.map((xPoint: string) => {
Expand All @@ -714,7 +718,7 @@ export class HeatMapChartBase extends React.Component<IHeatMapChartProps, IHeatM
if (this._yAxisType === YAxisType.DateAxis || this._yAxisType === YAxisType.NumericAxis) {
return +a - +b;
} else {
return a.toLowerCase() > b.toLowerCase() ? 1 : -1;
return this.props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
}
});
yAxisPoints = unFormattedYAxisDataPoints.map((yPoint: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export interface IHeatMapChartProps extends Pick<ICartesianChartProps, Exclude<k
*@default false
*Used for showing complete y axis lables */
showYAxisLables?: boolean;

/**
* @default alphabetical
* The prop used to decide order of string axis labels */
sortOrder?: 'none' | 'alphabetical';
}

/**
Expand Down
Loading