Browse Source

Tokenomics: TokenValue

Joystream Stats 3 years ago
parent
commit
d0a28c992f
1 changed files with 37 additions and 0 deletions
  1. 37 0
      src/components/Tokenomics/TokenValue.tsx

+ 37 - 0
src/components/Tokenomics/TokenValue.tsx

@@ -0,0 +1,37 @@
+import React, { useState } from "react";
+import Chart from "../Chart";
+
+const calculateTokenValue = (exchanges: any[]) => {
+  const tokenValue = {};
+  exchanges
+    .filter((e) => e.date)
+    .forEach((e) => {
+      const date = e.date.split("T")[0];
+      tokenValue[date] = { date, price: (e.price * 1000000).toFixed(1) };
+    });
+  return tokenValue;
+};
+
+const TokenValue = (props: { tokenValue: any }) => {
+  const { exchanges } = props;
+  const [tokenValue] = useState(calculateTokenValue(exchanges));
+
+  return (
+    <div className="p-5 text-center">
+      <h3>Token Value</h3>
+
+      <Chart
+        data={Object.values(tokenValue).sort((a, b) => a.date - b.date)}
+        x="date"
+        y="price"
+        xLabel="Date"
+        yLabel="$"
+        scaleY={true}
+        pixels={600}
+        barStyle={() => `bg-warning`}
+      />
+    </div>
+  );
+};
+
+export default TokenValue;