From 9895507ddfabe9e6a8544e4b9c98ef59d9baf074 Mon Sep 17 00:00:00 2001 From: balaji-jr Date: Thu, 14 Mar 2024 02:02:08 +0530 Subject: [PATCH 1/2] Event chart feedbacks --- src/pages/Logs/EventTimeLineGraph.tsx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/pages/Logs/EventTimeLineGraph.tsx b/src/pages/Logs/EventTimeLineGraph.tsx index f47b3e60..18e77f68 100644 --- a/src/pages/Logs/EventTimeLineGraph.tsx +++ b/src/pages/Logs/EventTimeLineGraph.tsx @@ -4,7 +4,7 @@ import { useQueryResult } from '@/hooks/useQueryResult'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { useLogsPageContext } from './logsContextProvider'; import dayjs, { Dayjs } from 'dayjs'; -import { BarChart, ChartTooltipProps } from '@mantine/charts'; +import { ChartTooltipProps, AreaChart } from '@mantine/charts'; import { HumanizeNumber } from '@/utils/formatBytes'; import { useHeaderContext } from '@/layouts/MainLayout/Context'; @@ -32,6 +32,8 @@ type GraphRecord = { const calcAverage = (data: GraphRecord[]) => { if (!Array.isArray(data) || data.length === 0) return 0; + + console.log(data) const total = data.reduce((acc, d) => { return acc + d.log_count; }, 0); @@ -59,8 +61,6 @@ const parseGraphData = (data: GraphRecord[], avg: number, startTime: Dayjs) => { if (!countData || typeof countData !== 'object') { return { events: 0, - belowAvgCount: 0, - aboveAvgCount: 0, minute: ts, aboveAvgPercent: 0, }; @@ -69,8 +69,6 @@ const parseGraphData = (data: GraphRecord[], avg: number, startTime: Dayjs) => { const aboveAvgPercent = parseInt(((aboveAvgCount / avg) * 100).toFixed(2)); return { events: countData.log_count, - belowAvgCount: aboveAvgCount >= 0 ? avg : countData.log_count, - aboveAvgCount: aboveAvgCount <= 0 ? 0 : aboveAvgCount, minute: `${countData.minute_range}Z`, aboveAvgPercent, }; @@ -103,7 +101,7 @@ function ChartTooltip({ payload }: ChartTooltipProps) { {`${ isAboveAvg ? '+' : '' - }${aboveAvgPercent}% above avg (Last 30 mins)`} + }${aboveAvgPercent}% ${isAboveAvg ? 'above' : 'below'} avg (Last 30 mins)`} ); @@ -177,27 +175,24 @@ const EventTimeLineGraph = () => { w={isLoading ? '98%' : '100%'} style={isLoading ? { marginLeft: '1.8rem', alignSelf: 'center' } : !hasData ? { marginLeft: '1rem' } : {}}> {hasData ? ( - , position: { y: -20 }, }} - type="stacked" valueFormatter={(value) => new Intl.NumberFormat('en-US').format(value)} withXAxis={false} withYAxis={hasData} yAxisProps={{ tickCount: 2, tickFormatter: (value) => `${HumanizeNumber(value)}` }} - referenceLines={[{ y: avgEventCount, color: 'red.5' }]} + referenceLines={[{ y: avgEventCount, color: 'red.6', label: 'Avg' }]} tickLine="none" - barChartProps={{ onClick: setTimeRange }} + areaChartProps={{ onClick: setTimeRange, style: { cursor: 'pointer' }}} gridAxis="xy" + fillOpacity={0.5} /> ) : ( From 26c5dd736061c945069cb43fbf14e020c40f0c79 Mon Sep 17 00:00:00 2001 From: balaji-jr Date: Thu, 14 Mar 2024 02:03:31 +0530 Subject: [PATCH 2/2] rm console st --- src/pages/Logs/EventTimeLineGraph.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/Logs/EventTimeLineGraph.tsx b/src/pages/Logs/EventTimeLineGraph.tsx index 18e77f68..b0a75f4c 100644 --- a/src/pages/Logs/EventTimeLineGraph.tsx +++ b/src/pages/Logs/EventTimeLineGraph.tsx @@ -33,7 +33,6 @@ type GraphRecord = { const calcAverage = (data: GraphRecord[]) => { if (!Array.isArray(data) || data.length === 0) return 0; - console.log(data) const total = data.reduce((acc, d) => { return acc + d.log_count; }, 0);