fix: sort markers by timestamp before setting on chart
- Add sorting to annotation markers in ascending order by time - Fixes 'data must be asc ordered by time' error for markers - Ensures both candle data and markers are properly sorted
This commit is contained in:
parent
17eb2ca745
commit
551e8423b2
1 changed files with 9 additions and 7 deletions
|
|
@ -157,13 +157,15 @@ const CandleChart = forwardRef<CandleChartHandle, CandleChartProps>(
|
|||
(a) => a.label_type === 'break_up' || a.label_type === 'break_down'
|
||||
);
|
||||
|
||||
const markers = markerAnnotations.map((annotation) => ({
|
||||
time: annotation.timestamp as Time,
|
||||
position: annotation.label_type === 'break_up' ? ('belowBar' as const) : ('aboveBar' as const),
|
||||
color: annotation.label_type === 'break_up' ? '#22c55e' : '#ef4444',
|
||||
shape: annotation.label_type === 'break_up' ? ('arrowUp' as const) : ('arrowDown' as const),
|
||||
text: annotation.label_type === 'break_up' ? 'Break Up' : 'Break Down',
|
||||
}));
|
||||
const markers = markerAnnotations
|
||||
.map((annotation) => ({
|
||||
time: annotation.timestamp as Time,
|
||||
position: annotation.label_type === 'break_up' ? ('belowBar' as const) : ('aboveBar' as const),
|
||||
color: annotation.label_type === 'break_up' ? '#22c55e' : '#ef4444',
|
||||
shape: annotation.label_type === 'break_up' ? ('arrowUp' as const) : ('arrowDown' as const),
|
||||
text: annotation.label_type === 'break_up' ? 'Break Up' : 'Break Down',
|
||||
}))
|
||||
.sort((a, b) => (a.time as number) - (b.time as number));
|
||||
|
||||
seriesRef.current.setMarkers(markers);
|
||||
}, [annotations]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue