From 84f8a871a1e031766c4a14d66a82ac9bf6ac6c6e Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Thu, 30 Nov 2023 09:02:30 -0600 Subject: [PATCH 1/2] add min price line to price history chart --- src/components/price-graph/index.js | 37 +++++++++++++++++++++++------ src/pages/item/index.js | 1 - 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/components/price-graph/index.js b/src/components/price-graph/index.js index 5728218a4..316da382c 100644 --- a/src/components/price-graph/index.js +++ b/src/components/price-graph/index.js @@ -5,6 +5,7 @@ import { VictoryAxis, // VictoryTooltip, VictoryVoronoiContainer, + VictoryLegend, } from 'victory'; import { useTranslation } from 'react-i18next'; @@ -14,7 +15,7 @@ import { useQuery } from '../../modules/graphql-request'; import './index.css'; -function PriceGraph({ item, itemId, itemChange24 }) { +function PriceGraph({ item, itemId }) { if (item && !itemId) { itemId = item.id; if (item.properties?.baseItem?.properties?.defaultPreset?.id === item.id) { @@ -28,6 +29,7 @@ function PriceGraph({ item, itemId, itemChange24 }) { `{ historicalItemPrices(id:"${itemId}"){ price + priceMin timestamp } }`, @@ -38,7 +40,7 @@ function PriceGraph({ item, itemId, itemChange24 }) { height = 1280; } - if (status !== 'success') { + if (status !== 'success' || !data?.data?.historicalItemPrices) { return null; } @@ -48,20 +50,21 @@ function PriceGraph({ item, itemId, itemChange24 }) { let max = 0; - data.data.historicalItemPrices.map((price) => { + data.data.historicalItemPrices.forEach((price) => { if (price.price > max) { max = price.price; } - - return true; }); + const avgDown = data.data.historicalItemPrices[0].price > data.data.historicalItemPrices[data.data.historicalItemPrices.length-1].price; + const minDown = data.data.historicalItemPrices[0].priceMin > data.data.historicalItemPrices[data.data.historicalItemPrices.length-1].priceMin; + return (
+ { + return { + x: new Date(Number(pricePoint.timestamp)), + y: pricePoint.priceMin, + }; + })} + />
); diff --git a/src/pages/item/index.js b/src/pages/item/index.js index 9cc3d0743..779c1e017 100644 --- a/src/pages/item/index.js +++ b/src/pages/item/index.js @@ -607,7 +607,6 @@ The max profitable price is impacted by the intel center and hideout management

{t('Flea price last 7 days')}


From 2a2c8d95cf9d138679fd60ed39141eca94d49cfd Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Thu, 30 Nov 2023 09:13:16 -0600 Subject: [PATCH 2/2] relative min for chart --- src/components/price-graph/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/price-graph/index.js b/src/components/price-graph/index.js index 316da382c..dc33cedd5 100644 --- a/src/components/price-graph/index.js +++ b/src/components/price-graph/index.js @@ -5,7 +5,6 @@ import { VictoryAxis, // VictoryTooltip, VictoryVoronoiContainer, - VictoryLegend, } from 'victory'; import { useTranslation } from 'react-i18next'; @@ -56,6 +55,13 @@ function PriceGraph({ item, itemId }) { } }); + const min = data.data.historicalItemPrices.reduce((curMin, p) => { + if (p.priceMin < curMin) { + return p.priceMin; + } + return curMin; + }, Number.MAX_SAFE_INTEGER); + const avgDown = data.data.historicalItemPrices[0].price > data.data.historicalItemPrices[data.data.historicalItemPrices.length-1].price; const minDown = data.data.historicalItemPrices[0].priceMin > data.data.historicalItemPrices[data.data.historicalItemPrices.length-1].priceMin; @@ -65,7 +71,7 @@ function PriceGraph({ item, itemId }) { height={height} width={1280} padding={{ top: 20, left: 15, right: 15, bottom: 30 }} - minDomain={{ y: 0 }} + minDomain={{ y: min - min * 0.1 }} maxDomain={{ y: max + max * 0.1 }} theme={VictoryTheme.material} containerComponent={