Remove dead code in app and XBRL loader

This commit is contained in:
2026-03-21 13:03:12 -04:00
parent 7d2816e3c4
commit dd289968b8
22 changed files with 22 additions and 796 deletions

View File

@@ -1,44 +0,0 @@
import { useState, useCallback } from 'react';
import type { ChartZoomState } from '@/lib/types';
export function useChartZoom(dataLength: number) {
const [zoomState, setZoomState] = useState<ChartZoomState>({
startIndex: 0,
endIndex: Math.max(0, dataLength - 1),
isZoomed: false
});
const handleZoomChange = useCallback(
(brushData: { startIndex?: number; endIndex?: number }) => {
if (
brushData.startIndex === undefined ||
brushData.endIndex === undefined
) {
return;
}
setZoomState({
startIndex: brushData.startIndex,
endIndex: brushData.endIndex,
isZoomed:
brushData.startIndex !== 0 ||
brushData.endIndex !== dataLength - 1
});
},
[dataLength]
);
const resetZoom = useCallback(() => {
setZoomState({
startIndex: 0,
endIndex: Math.max(0, dataLength - 1),
isZoomed: false
});
}, [dataLength]);
return {
zoomState,
handleZoomChange,
resetZoom
};
}

View File

@@ -1,71 +0,0 @@
import {
ComposedChart,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
Scatter
} from 'recharts';
import type { ChartDataPoint } from '@/lib/types';
import { getChartColors } from '../utils/chart-colors';
import { ChartTooltip } from '../primitives/chart-tooltip';
import { CandlestickShape } from '../utils/candlestick-shapes';
import { isOHLCVData } from '../utils/chart-data-transformers';
type CandlestickChartViewProps = {
data: ChartDataPoint[];
formatters?: {
price?: (value: number) => string;
date?: (value: string) => string;
volume?: (value: number) => string;
};
};
export function CandlestickChartView({
data,
formatters
}: CandlestickChartViewProps) {
const colors = getChartColors();
const ohlcvData = data.filter(isOHLCVData);
if (ohlcvData.length === 0) {
return (
<div className="flex h-full items-center justify-center text-sm text-[color:var(--terminal-muted)]">
Candlestick chart requires OHLCV data
</div>
);
}
return (
<ResponsiveContainer width="100%" height="100%">
<ComposedChart data={ohlcvData}>
<CartesianGrid strokeDasharray="2 2" stroke={colors.grid} />
<XAxis
dataKey="date"
stroke={colors.muted}
fontSize={11}
tickFormatter={formatters?.date}
minTickGap={32}
/>
<YAxis
stroke={colors.muted}
fontSize={11}
tickFormatter={formatters?.price}
width={60}
domain={['auto', 'auto']}
/>
<Tooltip
content={(tooltipProps) => <ChartTooltip {...tooltipProps} formatters={formatters} />}
cursor={{ stroke: colors.muted, strokeDasharray: '3 3' }}
/>
<Scatter
dataKey="close"
shape={<CandlestickShape />}
isAnimationActive={false}
/>
</ComposedChart>
</ResponsiveContainer>
);
}

View File

@@ -1,68 +0,0 @@
import { getPriceChangeColor } from './chart-colors';
type CandlestickShapeProps = {
cx?: number;
payload?: {
open: number;
high: number;
low: number;
close: number;
};
};
/**
* Custom candlestick shape component for Recharts
* Renders candlestick with wick and body
*/
export function CandlestickShape(props: CandlestickShapeProps) {
const { cx, payload } = props;
if (!payload || !cx) return null;
const { open, high, low, close } = payload;
const isPositive = close >= open;
const color = getPriceChangeColor(close - open);
// Calculate positions
const bodyTop = Math.min(open, close);
const bodyBottom = Math.max(open, close);
const bodyHeight = Math.max(bodyBottom - bodyTop, 1);
// Candlestick width
const width = 8;
return (
<g>
{/* Upper wick */}
<line
x1={cx}
y1={high}
x2={cx}
y2={bodyTop}
stroke={color}
strokeWidth={1}
/>
{/* Body */}
<rect
x={cx - width / 2}
y={bodyTop}
width={width}
height={bodyHeight}
fill={isPositive ? 'transparent' : color}
stroke={color}
strokeWidth={1}
/>
{/* Lower wick */}
<line
x1={cx}
y1={bodyBottom}
x2={cx}
y2={low}
stroke={color}
strokeWidth={1}
/>
</g>
);
}

View File

@@ -19,14 +19,6 @@ export function getChartColors(): ChartColorPalette {
};
}
/**
* Get color for price change (positive/negative)
*/
export function getPriceChangeColor(change: number): string {
const colors = getChartColors();
return change >= 0 ? colors.positive : colors.negative;
}
/**
* Convert CSS variable to computed color value
* Used for chart export since html-to-image can't render CSS variables