chart update

This commit is contained in:
2024-02-28 23:57:15 -05:00
parent 084a5050b7
commit 6a396953bf
17 changed files with 2886 additions and 205 deletions
+30
View File
@@ -0,0 +1,30 @@
"use client";
import { ResponsiveTreeMap } from "@nivo/treemap";
import React from "react";
const MarketHeatmap = ({ data }: any) => (
<ResponsiveTreeMap
data={data}
identity="name"
value="loc"
valueFormat=".02s"
tile="binary"
// margin={{ top: 10, right: 10, bottom: 10, left: 10 }}
labelSkipSize={30}
labelTextColor="black"
parentLabelPosition="left"
parentLabelTextColor={{
from: "color",
modifiers: [["darker", 2]],
}}
colors={{ scheme: "red_yellow_green" }}
borderColor={{
from: "color",
modifiers: [["brighter", 0.1]],
}}
motionConfig="wobbly"
/>
);
export default MarketHeatmap;
+59 -64
View File
@@ -1,71 +1,66 @@
"use client";
import React from "react";
import { ResponsiveLine } from "@nivo/line";
import { createChart, ColorType } from "lightweight-charts";
import React, { MutableRefObject, useEffect, useRef } from "react";
import { indexData, portfolioData } from "@/app/MockData/MockData";
function PortfolioChart({ data }: any) {
return (
<ResponsiveLine
data={data}
theme={{
"text": {
"fontSize": 11,
"fill": "#ffffff",
"outlineWidth": 0,
"outlineColor": "transparent",
const PortfolioChart = (props: any) => {
const {
data,
colors: {
backgroundColor = "transparent",
portfolioLineColor = "#FACC15",
indexLineColor = "#FFFFFF",
textColor = "white",
} = {},
} = props;
const chartContainerRef = useRef() as MutableRefObject<HTMLDivElement>;
useEffect(() => {
const handleResize = () => {
chart.applyOptions({
width: chartContainerRef.current.clientWidth * 0.95,
});
};
const chart = createChart(chartContainerRef.current, {
layout: {
background: { type: ColorType.Solid, color: backgroundColor },
textColor,
},
width: chartContainerRef.current.clientWidth * 0.95,
height: 300,
grid: {
vertLines: {
visible: false,
},
}}
margin={{ top: 50, right: 110, bottom: 50, left: 60 }}
xScale={{ type: "point" }}
yScale={{
type: "linear",
min: "auto",
max: "auto",
stacked: true,
reverse: false,
}}
yFormat=" >-.2f"
curve="monotoneX"
axisTop={null}
axisRight={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: "",
legendOffset: 0,
truncateTickAt: 0,
}}
axisBottom={{
tickSize: 0,
tickPadding: 0,
tickRotation: -1,
legend: "",
legendOffset: 36,
legendPosition: "middle",
truncateTickAt: 0,
}}
axisLeft={null}
enableGridX={false}
colors={{ scheme: "yellow_orange_brown" }}
enablePoints={false}
pointSize={10}
pointColor={{ theme: "background" }}
pointBorderWidth={2}
pointBorderColor={{ from: "serieColor" }}
pointLabelYOffset={-12}
crosshairType="cross"
useMesh={true}
legends={[]}
motionConfig={{
mass: 1,
tension: 250,
friction: 1,
clamp: true,
precision: 0.01,
velocity: 0,
}}
/>
},
});
chart.timeScale().fitContent();
const portfolioSeries = chart.addLineSeries({
color: portfolioLineColor,
});
portfolioSeries.setData(portfolioData);
const indexSeries = chart.addLineSeries({
color: indexLineColor,
});
indexSeries.setData(indexData);
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
chart.remove();
};
}, [data, backgroundColor, portfolioLineColor, indexLineColor, textColor]);
return (
<div className="flex justify-center" ref={chartContainerRef} id="chart" />
);
}
};
export default PortfolioChart;
@@ -16,7 +16,7 @@ const HomepageModule = ({ title, children }: HomepageModuleProps) => {
<Settings2Icon size={20} />
</Button>
</div>
<div className="h-3/4 w-full">{children}</div>
<div className="w-full">{children}</div>
</div>
);
};
+22 -4
View File
@@ -1,11 +1,25 @@
import { PortfolioData } from "@/app/MockData/MockData";
import PortfolioChart from "../charts/PortfolioChart";
import { heatmapData, portfolioData } from "@/app/MockData/MockData";
import HomepageModule from "./HomepageModuleCard";
import PortfolioChart from "../charts/PortfolioChart";
import MarketHeatmap from "../charts/MarketHeatmap";
import { Button } from "../ui/button";
import { ArrowRight } from "lucide-react";
export const PortfolioModule = () => {
return (
<HomepageModule title="Portfolio">
<PortfolioChart data={PortfolioData} />
<div className="flex justify-between px-4">
<div>$34,120.87</div>
<div className="rounded-full bg-neutral-900 px-4">2W 1M YTD</div>
<div className="text-green-500">^10.0% $3,412.09</div>
</div>
<PortfolioChart data={portfolioData} />
<div className="flex justify-between">
<Button className="text-white" variant="link">
Go to Portfolio
<ArrowRight className="ml-1" size={16} />
</Button>
</div>
</HomepageModule>
);
};
@@ -15,7 +29,11 @@ export const NewsModule = () => {
};
export const HeatmapModule = () => {
return <HomepageModule title="Heatmap"></HomepageModule>;
return (
<HomepageModule title="Heatmap">
<MarketHeatmap data={heatmapData} />
</HomepageModule>
);
};
export const MarketsModule = () => {
+3 -3
View File
@@ -4,13 +4,13 @@ import { Button } from "../ui/button";
const NavPages = () => {
return (
<div className="flex justify-between gap-8 px-8">
<Button variant="link" className="text-secondary font-bold">
<Button variant="link" className="text-white font-bold">
HOME
</Button>
<Button variant="link" className="text-secondary font-bold">
<Button variant="link" className="text-white font-bold">
PORTFOLIO
</Button>
<Button variant="link" className="text-secondary font-bold">
<Button variant="link" className="text-white font-bold">
RESEARCH
</Button>
</div>
+16 -3
View File
@@ -1,8 +1,8 @@
import React from "react";
import { Button } from "../ui/button";
import NavbarSearch from "./NavbarSearch";
import { Circle, icons } from "lucide-react";
import { Circle, Search, icons } from "lucide-react";
import NavPages from "./NavPages";
import { Input } from "../ui/input";
const Navbar = () => {
return (
@@ -14,7 +14,20 @@ const Navbar = () => {
<NavPages />
</div>
<div className="flex">
<NavbarSearch />
<div className="flex items-center px-4">
<div className="">
<Input
className="rounded-full rounded-r-none min-w-80 bg-inherit border-primary p-4"
type="search"
placeholder="Search"
/>
</div>
<div className="">
<Button type="submit" className="w-14 rounded-full rounded-l-none">
<Search size={16} />
</Button>
</div>
</div>
<Button className="rounded-full" size="icon">
ME
-25
View File
@@ -1,25 +0,0 @@
import React from "react";
import { Input } from "../ui/input";
import { Button } from "../ui/button";
import { Search } from "lucide-react";
const NavbarSearch = () => {
return (
<div className="flex items-center px-4">
<div className="">
<Input
className="rounded-full rounded-r-none min-w-80 bg-inherit border-primary p-4"
type="search"
placeholder="Search"
/>
</div>
<div className="">
<Button type="submit" className="w-14 rounded-full rounded-l-none">
<Search size={16} />
</Button>
</div>
</div>
);
};
export default NavbarSearch;