diff --git a/openspec/changes/span-annotation/tasks.md b/openspec/changes/span-annotation/tasks.md index 4292d7d..ef6eca4 100644 --- a/openspec/changes/span-annotation/tasks.md +++ b/openspec/changes/span-annotation/tasks.md @@ -21,12 +21,12 @@ ## 4. SpanRectanglePrimitive (Chart Rendering) -- [ ] 4.1 Create `SpanRectanglePrimitive.ts` implementing `ISeriesPrimitive` with data-space rectangle coordinates (start_time, end_time, max_high, min_low) -- [ ] 4.2 Implement `updateAllViews()` with a pane renderer that converts time/price to pixel coordinates and draws a filled semi-transparent rectangle using `useBitmapCoordinateSpace` -- [ ] 4.3 Implement label tag text rendering above the rectangle (pattern name) -- [ ] 4.4 Implement `hitTest()` to detect clicks within the rectangle bounds -- [ ] 4.5 Add highlight state (thicker border / increased opacity) for selected spans -- [ ] 4.6 Set `zOrder: 'bottom'` so rectangles render behind candlesticks +- [x] 4.1 Create `SpanRectanglePrimitive.ts` implementing `ISeriesPrimitive` with data-space rectangle coordinates (start_time, end_time, max_high, min_low) +- [x] 4.2 Implement `updateAllViews()` with a pane renderer that converts time/price to pixel coordinates and draws a filled semi-transparent rectangle using `useBitmapCoordinateSpace` +- [x] 4.3 Implement label tag text rendering above the rectangle (pattern name) +- [x] 4.4 Implement `hitTest()` to detect clicks within the rectangle bounds +- [x] 4.5 Add highlight state (thicker border / increased opacity) for selected spans +- [x] 4.6 Set `zOrder: 'bottom'` so rectangles render behind candlesticks ## 5. Span Tool State & Integration diff --git a/src/components/SpanRectanglePrimitive.ts b/src/components/SpanRectanglePrimitive.ts new file mode 100644 index 0000000..3714eb5 --- /dev/null +++ b/src/components/SpanRectanglePrimitive.ts @@ -0,0 +1,240 @@ +import { + ISeriesPrimitive, + ISeriesPrimitivePaneView, + SeriesAttachedParameter, + Time, + Logical, +} from 'lightweight-charts'; + +export interface SpanData { + id: number; + start_time: number; + end_time: number; + label: string; + color: string; + max_high: number; + min_low: number; +} + +export interface SpanRectanglePrimitiveOptions { + data: SpanData; + isSelected?: boolean; +} + +class SpanRectanglePaneView implements ISeriesPrimitivePaneView { + private _data: SpanData; + private _isSelected: boolean; + private _series: SeriesAttachedParameter