Skip to content

Commit c906eef

Browse files
committed
visualizer: prettify graphs
1 parent 3e43b18 commit c906eef

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

ui/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
# files used for debugging
27+
public/traces/*.jsonl

ui/src/components/Blocks/modules/BlockGraph.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSimContext } from "@/contexts/SimContext/context";
22
import { FC, useCallback, useMemo } from "react";
3-
import { Bar, BarChart, Legend, Tooltip, XAxis, YAxis } from "recharts";
3+
import { Bar, BarChart, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
44

55
export const BlockGraph: FC = ({ }) => {
66
const {
@@ -34,14 +34,16 @@ export const BlockGraph: FC = ({ }) => {
3434
return (
3535
<div className="flex flex-col w-full h-4/5 items-center justify-center">
3636
<h2 className="font-bold text-xl">Transactions Per Block</h2>
37-
<BarChart width={640} height={480} data={data}>
38-
<XAxis dataKey="name" />
39-
<YAxis />
40-
<Tooltip />
41-
<Legend />
42-
<Bar dataKey="praosTx" stackId="a" name={"TXs in block"} fill="#8884d8" onClick={viewBlock} />
43-
<Bar dataKey="leiosTx" stackId="a" name={"TXs from Leios"} fill="#82ca9d" onClick={viewBlock} />
44-
</BarChart>
37+
<ResponsiveContainer width="80%" height="80%">
38+
<BarChart data={data}>
39+
<XAxis dataKey="name" />
40+
<YAxis />
41+
<Tooltip />
42+
<Legend />
43+
<Bar dataKey="praosTx" stackId="a" name={"TXs in block"} fill="#8884d8" onClick={viewBlock} />
44+
<Bar dataKey="leiosTx" stackId="a" name={"TXs from Leios"} fill="#82ca9d" onClick={viewBlock} />
45+
</BarChart>
46+
</ResponsiveContainer>
4547
</div>
4648
)
4749

ui/src/components/Sim/SimWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ export const SimWrapper: FC = ({
7878
const setActiveTab = useCallback((tab: Tab) => dispatch({ type: 'SET_ACTIVE_TAB', payload: tab }), [dispatch]);
7979
return (
8080
<>
81-
<div className="flex flex-col items-center justify-between gap-4 z-10 absolute left-10 top-10">
81+
{activeTab === Tab.Graph ? <div className="flex flex-col items-center justify-between gap-4 z-10 absolute left-10 top-10">
8282
<Stats />
83-
</div>
83+
</div> : null}
8484
<div className="flex items-center justify-center gap-4 relative h-screen w-screen">
8585
{activeTab === Tab.Graph && topologyLoaded ? <GraphWrapper /> : null}
8686
{activeTab === Tab.Blocks ? <BlocksView /> : null}

ui/src/components/Transactions/TransactionsView.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSimContext } from "@/contexts/SimContext/context";
22
import { FC, useMemo } from "react";
3-
import { Area, AreaChart, Tooltip, XAxis, YAxis } from "recharts";
3+
import { Area, AreaChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
44

55
export const TransactionsView: FC = ({ }) => {
66
const {
@@ -28,15 +28,17 @@ export const TransactionsView: FC = ({ }) => {
2828
return (
2929
<div className="flex flex-col w-full h-4/5 items-center justify-center">
3030
<h2 className="font-bold text-xl">Transactions</h2>
31-
<AreaChart width={640} height={480} data={data}>
32-
<XAxis dataKey="Time" />
33-
<YAxis />
34-
<Tooltip />
35-
<Area type="monotone" dataKey="Created" stackId="1" stroke="#26de81" fill="#26de81" />
36-
<Area type="monotone" dataKey="In Input Block" stackId="1" stroke="#2bcbba" fill="#2bcbba" />
37-
<Area type="monotone" dataKey="In Endorser Block" stackId="1" stroke="#4b7bec" fill="#4b7bec" />
38-
<Area type="monotone" dataKey="On Chain" stackId="1" stroke="#2d98da" fill="#2d98da" />
39-
</AreaChart>
31+
<ResponsiveContainer width="80%" height="80%">
32+
<AreaChart data={data}>
33+
<XAxis dataKey="Time" />
34+
<YAxis />
35+
<Tooltip />
36+
<Area type="monotone" dataKey="Created" stackId="1" stroke="#9e0142" fill="#9e0142" />
37+
<Area type="monotone" dataKey="In Input Block" stackId="1" stroke="#d0394e" fill="#d0394e" />
38+
<Area type="monotone" dataKey="In Endorser Block" stackId="1" stroke="#ef6445" fill="#ef6445" />
39+
<Area type="monotone" dataKey="On Chain" stackId="1" stroke="#fb9d56" fill="#fb9d56" />
40+
</AreaChart>
41+
</ResponsiveContainer>
4042
</div>
4143
);
4244
}

0 commit comments

Comments
 (0)