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

Sort barchart data #4072

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-strict-ignore
import React, { useState, type CSSProperties } from 'react';
import React, { useMemo, useState, type CSSProperties } from 'react';
import { useTranslation } from 'react-i18next';

import { css } from '@emotion/css';
Expand Down Expand Up @@ -207,6 +207,12 @@ export function BarGraph({

const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 0;

// Sort the data in the bar chart
const unsortedData = data[splitData];
const sortedData = useMemo(() => {
return unsortedData.sort((a, b) => a[balanceTypeOp] - b[balanceTypeOp]);
}, [unsortedData, balanceTypeOp]);

matt-fidd marked this conversation as resolved.
Show resolved Hide resolved
return (
<Container
style={{
Expand All @@ -223,7 +229,7 @@ export function BarGraph({
width={width}
height={height}
stackOffset="sign"
data={data[splitData]}
data={sortedData}
style={{ cursor: pointer }}
margin={{
top: labelsMargin,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4072.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [matt-fidd]
---

Sort barchart data
Loading