feat: change average to median
This commit is contained in:
parent
b5e798339b
commit
1d37608a19
3 changed files with 14 additions and 16 deletions
|
|
@ -227,13 +227,11 @@ const Analytics = () => {
|
|||
previous: filteredData(period.code).previous.length
|
||||
}
|
||||
|
||||
const avgAmount = {
|
||||
current:
|
||||
R.sum(R.map(d => d.fiat, filteredData(period.code).current)) /
|
||||
(txs.current === 0 ? 1 : txs.current),
|
||||
previous:
|
||||
R.sum(R.map(d => d.fiat, filteredData(period.code).previous)) /
|
||||
(txs.previous === 0 ? 1 : txs.previous)
|
||||
const median = values => (values.length === 0 ? 0 : R.median(values))
|
||||
|
||||
const medianAmount = {
|
||||
current: median(R.map(d => d.fiat, filteredData(period.code).current)),
|
||||
previous: median(R.map(d => d.fiat, filteredData(period.code).previous))
|
||||
}
|
||||
|
||||
const txVolume = {
|
||||
|
|
@ -365,9 +363,9 @@ const Analytics = () => {
|
|||
/>
|
||||
<div className={classes.verticalLine} />
|
||||
<OverviewEntry
|
||||
label="Avg. txn amount"
|
||||
value={avgAmount.current}
|
||||
oldValue={avgAmount.previous}
|
||||
label="Median amount"
|
||||
value={medianAmount.current}
|
||||
oldValue={medianAmount.previous}
|
||||
currency={fiatLocale}
|
||||
/>
|
||||
<div className={classes.verticalLine} />
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const OverTimeDotGraphHeader = ({
|
|||
cashIn: <div className={classes.cashInIcon}></div>,
|
||||
cashOut: <div className={classes.cashOutIcon}></div>,
|
||||
transaction: <div className={classes.txIcon}></div>,
|
||||
average: (
|
||||
median: (
|
||||
<svg height="12" width="18">
|
||||
<path
|
||||
stroke={primaryColor}
|
||||
|
|
@ -55,7 +55,7 @@ const OverTimeDotGraphHeader = ({
|
|||
IconElement={legend.transaction}
|
||||
label={'One transaction'}
|
||||
/>
|
||||
<LegendEntry IconElement={legend.average} label={'Average'} />
|
||||
<LegendEntry IconElement={legend.median} label={'Median'} />
|
||||
</Box>
|
||||
</div>
|
||||
<div className={classes.graphHeaderRight}>
|
||||
|
|
|
|||
|
|
@ -498,9 +498,9 @@ const Graph = ({
|
|||
|
||||
const buildAvg = useCallback(
|
||||
g => {
|
||||
const mean = d3.mean(data, d => new BigNumber(d.fiat).toNumber()) ?? 0
|
||||
const median = d3.median(data, d => new BigNumber(d.fiat).toNumber()) ?? 0
|
||||
|
||||
if (log && mean === 0) return
|
||||
if (log && median === 0) return
|
||||
|
||||
g.attr('stroke', primaryColor)
|
||||
.attr('stroke-width', 3)
|
||||
|
|
@ -508,8 +508,8 @@ const Graph = ({
|
|||
.call(g =>
|
||||
g
|
||||
.append('line')
|
||||
.attr('y1', 0.5 + y(mean))
|
||||
.attr('y2', 0.5 + y(mean))
|
||||
.attr('y1', 0.5 + y(median))
|
||||
.attr('y2', 0.5 + y(median))
|
||||
.attr('x1', GRAPH_MARGIN.left)
|
||||
.attr('x2', GRAPH_WIDTH)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue