Sort barchart data (#4072)
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 121 KiB |
@@ -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,
|
||||
|
||||
6
upcoming-release-notes/4072.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [matt-fidd]
|
||||
---
|
||||
|
||||
Sort barchart data
|
||||