Skip to content

Commit

Permalink
Merge pull request #38 from skip-mev/zygis/add-min-scale
Browse files Browse the repository at this point in the history
feat(main-chart): add minimum max scale for main chart
  • Loading branch information
Zygimantass authored Jan 9, 2024
2 parents 970bead + 7582cda commit d958040
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/pages/home/MainChart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import CustomTooltip from "@/components/CustomTooltip";
import { MAIN_CHART_DATA_MAX } from "@/constants";
import { useMainChartData, useValidatorsWithStatsQuery } from "@/hooks";
import { toggleSelectedMoniker, useHomeStore } from "@/store/home";
import clsx from "clsx";
Expand Down Expand Up @@ -44,6 +45,13 @@ export const MainChart = () => {
);
}

const points = chartData
const lastPoint = points[points.length - 1]

const largestDatapoint = Math.max(...Object.entries(lastPoint).map(
([key, value]) => key === "key" ? 0 : value
), MAIN_CHART_DATA_MAX)

return (
<ResponsiveContainer className="overflow-hidden" height={300} width="100%">
<LineChart data={chartData} margin={{ left: 16, right: 32 }}>
Expand All @@ -62,6 +70,7 @@ export const MainChart = () => {
/>
<YAxis
axisLine={false}
domain={[0, largestDatapoint <= MAIN_CHART_DATA_MAX ? MAIN_CHART_DATA_MAX : "auto"]}
tickLine={false}
padding={{ top: 20, bottom: 20 }}
style={{
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export const API_URL =
process.env.NEXT_PUBLIC_API_URL || "https://dydx-mev-api-dev.skip.money";
export const MAIN_CHART_DATAPOINT_LIMIT = 5000;
export const MAIN_CHART_DATAPOINT_EVERY = 5;
export const MAIN_CHART_DATA_MAX = 10000;
export const PROBABILITY_THRESHOLD = 0.67;

0 comments on commit d958040

Please sign in to comment.