Sort barchart data (#4072)

This commit is contained in:
Matt Fiddaman
2025-01-08 17:52:51 +00:00
committed by GitHub
parent ce0ca60bcf
commit 6111f94b51
11 changed files with 14 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 121 KiB

View File

@@ -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';
@@ -203,6 +203,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]);
return (
<Container
style={{
@@ -219,7 +225,7 @@ export function BarGraph({
width={width}
height={height}
stackOffset="sign"
data={data[splitData]}
data={sortedData}
style={{ cursor: pointer }}
margin={{
top: labelsMargin,

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [matt-fidd]
---
Sort barchart data