fix: show TA-lib pattern spans on chart and add delete all annotations button
- Fix SpanAnnotationManager price range calculation: use direct candle filtering by time range instead of dummy Candle objects that fell back to 0/0 high/low, causing invisible rectangles - Add handleDeleteAllAnnotations in page.tsx (deletes all span annotations and regular annotations for current chart) - Add 'Delete All Annotations' button in sidebar below TA-Lib panel
This commit is contained in:
parent
7901a1a257
commit
d416aa409c
3 changed files with 50 additions and 5 deletions
|
|
@ -405,6 +405,21 @@ export default function Home() {
|
|||
}
|
||||
};
|
||||
|
||||
const handleDeleteAllAnnotations = async () => {
|
||||
if (!activeChartId) return;
|
||||
await Promise.all([
|
||||
fetch(`/api/span-annotations?chartId=${activeChartId}`, { method: 'DELETE' }),
|
||||
fetch(`/api/annotations?all=true&chartId=${activeChartId}`, { method: 'DELETE' }),
|
||||
]);
|
||||
await Promise.all([
|
||||
fetchSpanAnnotations(activeChartId),
|
||||
fetchAnnotations(activeChartId),
|
||||
chartRef.current?.refreshData(),
|
||||
]);
|
||||
setSelectedSpanId(null);
|
||||
setSelectedLabelId(null);
|
||||
};
|
||||
|
||||
const handleLabelDelete = async (id: number) => {
|
||||
setAnnotations(annotations.filter((a) => a.id !== id));
|
||||
if (selectedLabelId === id) {
|
||||
|
|
@ -778,6 +793,17 @@ export default function Home() {
|
|||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete all annotations */}
|
||||
<div className="px-3 py-2 border-t border-sidebar-border">
|
||||
<button
|
||||
onClick={handleDeleteAllAnnotations}
|
||||
disabled={!activeChartId}
|
||||
className="w-full px-2 py-1 text-[10px] text-destructive border border-destructive/30 rounded hover:bg-destructive/10 transition-colors disabled:opacity-50"
|
||||
>
|
||||
Delete All Annotations
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Training Panel */}
|
||||
<div className="px-3 py-2 border-t border-sidebar-border">
|
||||
<TrainingPanel />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue