From acc5c0576863d379d7c0658d8aafd3cb0ede6821 Mon Sep 17 00:00:00 2001 From: mokelgit Date: Mon, 13 Jan 2025 11:00:22 -0500 Subject: [PATCH] updated master, fixed errors --- components/layout/DA-Overview/DATable.tsx | 16 +- .../layout/DA-Overview/DATableCharts.tsx | 148 +++++++++++++++++- types/api/MasterResponse.d.ts | 7 + 3 files changed, 162 insertions(+), 9 deletions(-) diff --git a/components/layout/DA-Overview/DATable.tsx b/components/layout/DA-Overview/DATable.tsx index 4bc24cae..5060b44d 100644 --- a/components/layout/DA-Overview/DATable.tsx +++ b/components/layout/DA-Overview/DATable.tsx @@ -31,7 +31,7 @@ export default function DATable({breakdown_data, selectedTimespan, isMonthly}: { const {data: chart_data, error: chart_error, isLoading: chart_loading, isValidating: chart_validating} = useSWR(DATimeseriesURL); const { isSidebarOpen } = useUIContext(); - const { AllDALayersByKeys, AllChainsByKeys } = useMaster(); + const { AllDALayersByKeys, AllChainsByKeys, data: master } = useMaster(); const [selectedCategory, setSelectedCategory] = useState("size"); const [isBouncing, setIsBouncing] = useState(false); @@ -247,7 +247,7 @@ export default function DATable({breakdown_data, selectedTimespan, isMonthly}: { let typeIndex = breakdown_data[Object.keys(breakdown_data)[0]][selectedTimespan]["fees"].types.indexOf(showUsd ? "usd" : "eth"); Object.keys(breakdown_data).filter((key) => key !== "totals").map((key) => { - console.log(breakdown_data[key][selectedTimespan]["fees"].total[typeIndex]) + if(breakdown_data[key][selectedTimespan]["fees"].total[typeIndex] > maxFees){ @@ -337,15 +337,21 @@ export default function DATable({breakdown_data, selectedTimespan, isMonthly}: { const createDAConsumers = useCallback((da_row) => { + if (!master) return; + const tempBrokeChains = ["orderly", "manta", "derive", "ancient8"] let more = 0; + + const retHTML = da_row.chains.values.map((chain, index) => { - if (chain[1] && chain[1] !== "gitcoin_pgn") { - + + if (chain[1] && chain[1] !== "gitcoin_pgn" && !tempBrokeChains.includes(chain[1])) { + + return ( ); diff --git a/components/layout/DA-Overview/DATableCharts.tsx b/components/layout/DA-Overview/DATableCharts.tsx index 6582f936..db413dfe 100644 --- a/components/layout/DA-Overview/DATableCharts.tsx +++ b/components/layout/DA-Overview/DATableCharts.tsx @@ -17,7 +17,7 @@ import { import Highcharts, { chart } from "highcharts/highstock"; import { useLocalStorage } from "usehooks-ts"; import Image from "next/image"; -import { useMemo } from "react"; +import { useMemo, useState, useCallback } from "react"; import { useMaster } from "@/contexts/MasterContext"; import "@/app/highcharts.axis.css"; import Icon from "@/components/layout/Icon"; @@ -25,6 +25,7 @@ import { DAConsumerChart } from "@/types/api/DAOverviewResponse"; import { stringToDOM } from "million"; import { Any } from "react-spring"; import { format } from "path"; +import VerticalScrollContainer from "@/components/VerticalScrollContainer"; const COLORS = { GRID: "rgb(215, 223, 222)", @@ -42,6 +43,7 @@ export default function DATableCharts({selectedTimespan, data, isMonthly, da_nam const [showUsd, setShowUsd] = useLocalStorage("showUsd", true); const { AllDALayersByKeys, AllChainsByKeys } = useMaster(); + const [selectedChain, setSelectedChain] = useState("all"); @@ -59,8 +61,6 @@ export default function DATableCharts({selectedTimespan, data, isMonthly, da_nam } }) - console.log(new Date(xMax)) - if (!isMonthly) { return { @@ -176,6 +176,141 @@ export default function DATableCharts({selectedTimespan, data, isMonthly, da_nam + const tooltipFormatter = useCallback( + function (this: any) { + const { x, points } = this; + const date = new Date(x); + let dateString = date.toLocaleDateString("en-GB", { + month: "short", + day: "numeric", + year: "numeric", + }); + const chartTitle = this.series.chart.title.textStr; + + // check if data steps are less than 1 day + // if so, add the time to the tooltip + const timeDiff = points[0].series.xData[1] - points[0].series.xData[0]; + if (timeDiff < 1000 * 60 * 60 * 24) { + dateString += + " " + + date.toLocaleTimeString("en-GB", { + hour: "numeric", + minute: "2-digit", + }); + } + + // Create a scrollable container using CSS + const tooltip = `
+
${dateString}
+
`; + const tooltipEnd = `
`; + + // Updated scrollbar styles with thicker width and new color + const scrollbarStyles = ` + + `; + + let pointsSum = points.reduce((acc: number, point: any) => { + acc += point.y; + return acc; + }, 0); + + let pointSumNonNegative = points.reduce((acc: number, point: any) => { + if (point.y > 0) acc += point.y; + return acc; + }, 0); + + const maxPoint = points.reduce((max: number, point: any) => { + if (point.y > max) max = point.y; + return max; + }, 0); + + const maxPercentage = points.reduce((max: number, point: any) => { + if (point.percentage > max) max = point.percentage; + return max; + }, 0); + + const tooltipPoints = points + .sort((a: any, b: any) => b.y - a.y) + .map((point: any, index: number) => { + const { series, y, percentage } = point; + const { name } = series; + const nameString = name; + + let prefix = showUsd ? "$" : "Ξ"; + let suffix = ""; + let value = y; + let displayValue = y; + + return ` +
+
+
${nameString}
+
+
+
${prefix}
+ ${Intl.NumberFormat("en-GB", { + notation: "standard", + maximumFractionDigits: 2, + minimumFractionDigits: 2, + }).format(displayValue)} +
+
${suffix}
+
+
+ `; + }) + .join(""); + + return scrollbarStyles + tooltip + tooltipPoints + tooltipEnd; + }, + [showUsd], + ); + + + const filteredList = useMemo(() => { + + }, [data, selectedTimespan]); + return(
@@ -183,6 +318,7 @@ export default function DATableCharts({selectedTimespan, data, isMonthly, da_nam
chart_watermark
+