diff --git a/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/SkeletonTable.tsx b/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/SkeletonTable.tsx index 0218f07d..36329abe 100644 --- a/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/SkeletonTable.tsx +++ b/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/SkeletonTable.tsx @@ -1,32 +1,34 @@ const SkeletonTable = () => - [...Array(5)].map(i => ( - - -
-
-
-
-
+ [...Array(5).keys()] + .map(i => i + 1) + .map(i => ( + + +
+
+
+
+
+
-
- - -
- - -
- - -
- - -
- - -
- - - )); + + +
+ + +
+ + +
+ + +
+ + +
+ + + )); export default SkeletonTable; diff --git a/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/index.tsx b/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/index.tsx index 910fa7b7..5bd75874 100644 --- a/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/index.tsx +++ b/packages/nextjs/components/onchain-impact-dashboard/LeaderboardTable/index.tsx @@ -112,7 +112,7 @@ const LeaderboardTable = ({ projects, loading, selectedMetricName = "impact_inde -
+
{ - const formatNumber = (num: number, dec?: number) => { - const m = 1000000; - const k = 1000; - const text = num >= m ? "M" : num >= k ? "K" : ""; - if (dec != undefined) { - const divisor = num >= m ? m : num >= k ? k : 1; - const value = new Intl.NumberFormat().format(parseFloat((num / divisor).toFixed(dec))); - return `${value}${text}`; - } - return new Intl.NumberFormat().format(num); - }; - const CustomTooltip = ({ active, payload, label }: any) => { - if (active && payload && payload.length) { - return ( -
-

{formatDate(label)}

- {payload.map((entry: any, index: any) => ( -
-

- {formatNumber(entry.value)} -

-
- ))} -
- ); - } - return null; + const options = { + chart: { + type: "line", + height: 360, + }, + title: { + text: "", + }, + subtitle: { + text: "", + }, + credits: { + enabled: false, + }, + xAxis: { + type: "datetime", + title: { + text: "", + }, + dateTimeLabelFormats: { + day: "%e %b", + }, + }, + legend: { + enabled: false, + }, }; + + const chartComponentRef = useRef(null); const metricToWork = metrics[selectedMetric]; const values = totalsRecord.map(d => d[metricToWork?.name]); + const newValues = totalsRecord.map(d => { + const date = new Date(d["date"]); + return [Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()), d[metricToWork?.name]]; + }); + let minValue = Math.min(...values); const maxValue = Math.max(...values); const isEmpty = maxValue == 0 && minValue == 0; - const buffer = minValue * 0.04 + 5; + const buffer = minValue * 0.03 + 5; minValue = minValue - buffer > 0 ? minValue : minValue + buffer; + return ( <>
@@ -143,37 +151,51 @@ export const ProjectTotalsGraph = ({
)}
- - +
{isEmpty ? (
No data found
) : ( - - - - - formatNumber(v, 0)} - ticks={[minValue - buffer, maxValue + buffer]} - /> - } /> - + \u25CF ' + + this.series.name + + ": " + + formattedNumber + + "
" + ); + }, + }, + + series: [ + { + name: metricToWork.label, + data: newValues, + color: stringToColor(metricToWork.label || ""), + }, + ], + }} + ref={chartComponentRef} + /> )} - +
) : (
diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 0188f7d8..381b66e9 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -26,6 +26,8 @@ "d3-scale": "^4.0.2", "daisyui": "^4.4.19", "fs": "^0.0.1-security", + "highcharts": "^11.4.6", + "highcharts-react-official": "^3.2.1", "lodash": "^4.17.21", "mongodb": "^6.8.0", "next": "^14.0.4", diff --git a/yarn.lock b/yarn.lock index 77a4115b..36ae5348 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1253,6 +1253,8 @@ __metadata: eslint-config-prettier: ^8.5.0 eslint-plugin-prettier: ^4.2.1 fs: ^0.0.1-security + highcharts: ^11.4.6 + highcharts-react-official: ^3.2.1 lodash: ^4.17.21 mongodb: ^6.8.0 mongoose: ^8.4.5 @@ -5950,6 +5952,23 @@ __metadata: languageName: node linkType: hard +"highcharts-react-official@npm:^3.2.1": + version: 3.2.1 + resolution: "highcharts-react-official@npm:3.2.1" + peerDependencies: + highcharts: ">=6.0.0" + react: ">=16.8.0" + checksum: 615f1a352eb95f0e78189506e7d551071438fc11eabff78c55aeb6cc63658f4c284f4920f9e9c85113b319661bf5745c668ef22b71920c1a9f24749e49584aaf + languageName: node + linkType: hard + +"highcharts@npm:^11.4.6": + version: 11.4.6 + resolution: "highcharts@npm:11.4.6" + checksum: 7aa3871d19892c20a95b36754cc8c0234af0dd310e1fbe9a87cf489c315d55ac99497d1dba87f0bea8356b9e5886231bbb25f6de0b1dba92b31456aeee481cab + languageName: node + linkType: hard + "hmac-drbg@npm:^1.0.1": version: 1.0.1 resolution: "hmac-drbg@npm:1.0.1"