diff --git a/web/src/features/charts/FuturePrice.stories.ts b/web/src/features/charts/FuturePrice.stories.ts index a9c40460b2..6707ea72a0 100644 --- a/web/src/features/charts/FuturePrice.stories.ts +++ b/web/src/features/charts/FuturePrice.stories.ts @@ -1,5 +1,5 @@ import { Meta, StoryObj } from '@storybook/react'; -import { halfHourPriceData, priceData } from 'stories/mockData'; +import { halfHourPriceData, priceData, priceData2 } from 'stories/mockData'; import { mockDateDecorator } from 'storybook-mock-date-decorator'; import { FuturePrice } from './FuturePrice'; @@ -25,8 +25,10 @@ export const PositivePrices: Story = { const negativePriceData = JSON.parse(JSON.stringify(priceData)); negativePriceData.priceData['2024-09-02 03:00:00+00:00'] = -0.2; -negativePriceData.priceData['2024-09-02 13:00:00+00:00'] = -0.9; +negativePriceData.priceData['2024-09-02 13:00:00+00:00'] = -1; negativePriceData.priceData['2024-09-02 08:00:00+00:00'] = -0.3; +negativePriceData.priceData['2024-09-02 09:00:00+00:00'] = 0; +negativePriceData.priceData['2024-09-02 10:00:00+00:00'] = -0.0001; export const NegativePrices: Story = { args: { @@ -60,3 +62,12 @@ export const HalfHourPrices: Story = { date: new Date('2024-09-02 01:00:00+00:00'), }, }; + +export const PricesGoingUp: Story = { + args: { + futurePrice: priceData2, + }, + parameters: { + date: new Date('2024-09-01 12:00:00+00:00'), + }, +}; diff --git a/web/src/features/charts/FuturePrice.tsx b/web/src/features/charts/FuturePrice.tsx index 5d62999e48..87b07fd6f3 100644 --- a/web/src/features/charts/FuturePrice.tsx +++ b/web/src/features/charts/FuturePrice.tsx @@ -18,6 +18,7 @@ import { getGranularity, negativeToPostivePercentage, normalizeToGranularity, + priceIn5Percentile, } from './futurePriceUtils'; export function FuturePrice({ futurePrice }: { futurePrice: FuturePriceData | null }) { @@ -44,24 +45,23 @@ export function FuturePrice({ futurePrice }: { futurePrice: FuturePriceData | nu () => calculatePriceBound(filteredPriceData, Math.min, granularity, true), [filteredPriceData, granularity] ); + const hasNegativePrice = minPriceTotal < 0; + const negativePercentage = negativeToPostivePercentage(minPriceTotal, maxPriceTotal); if (!futurePrice || !isFuturePrice(futurePrice)) { return null; } - const hasNegativePrice = minPriceTotal < 0; - const negativePercentage = negativeToPostivePercentage(minPriceTotal, maxPriceTotal); - return (
+
{t(`country-panel.price-chart.now`)}
); @@ -225,11 +235,7 @@ function TimeDisplay({ date, granularity }: { date: string; granularity: number minute: '2-digit', }).format(datetime); - return ( -- {`${t(`country-panel.price-chart.at`)} ${formattedDate}`} -
- ); + return{formattedDate}
; } function PriceDisclaimer() { @@ -292,10 +298,16 @@ const getColor = ( normalizeToGranularity(new Date(), granularity) ) { return 'bg-price-light dark:bg-price-dark opacity-50'; - } else if (price === maxPrice) { + } else if ( + priceIn5Percentile(price, maxPrice, minPrice, true) && + maxPrice != minPrice + ) { return 'bg-danger dark:bg-red-400'; - } else if (price === minPrice) { - return 'bg-success dark:bg-emerald-500'; + } else if ( + priceIn5Percentile(price, maxPrice, minPrice, false) && + maxPrice != minPrice + ) { + return 'bg-success dark:bg-success-dark'; } else { return 'bg-price-light dark:bg-price-dark'; } diff --git a/web/src/features/charts/RoundedCard.tsx b/web/src/features/charts/RoundedCard.tsx index 20d1420530..3292578a25 100644 --- a/web/src/features/charts/RoundedCard.tsx +++ b/web/src/features/charts/RoundedCard.tsx @@ -8,7 +8,7 @@ export const RoundedCard = forwardRef< return (