Skip to content

feat: add Rectangle and Price Range drawing tools + performance improvements + Storybook 8 + React 18 upgrades#720

Open
sgonzaloc wants to merge 127 commits into
react-financial:mainfrom
sgonzaloc:main
Open

feat: add Rectangle and Price Range drawing tools + performance improvements + Storybook 8 + React 18 upgrades#720
sgonzaloc wants to merge 127 commits into
react-financial:mainfrom
sgonzaloc:main

Conversation

@sgonzaloc
Copy link
Copy Markdown

Summary

This PR is a comprehensive update to the interactive components library, including new drawing tools, performance optimizations, and modern tooling upgrades.

Changes

New Components

  • Rectangle - Drawing tool for rectangular annotations and area highlighting
  • Price Range - Measurement tool for price differences (absolute change + percentage)

Performance Improvements

  • shouldComponentUpdate implemented on all interactive components to prevent unnecessary re-renders
  • Throttled canvas drawing for smoother resize operations
  • Optimized hover detection using bounding boxes
  • Fixed opacity accumulation issues on canvas redraws

Interactive Features

  • Selection support for all interactive objects (click to select)
  • Toggle selection (click again to deselect)
  • Drag & drop functionality improved
  • Resize using control points
  • Delete key support for removing selected objects

Components Updated

  • Trendline
  • Fibonacci Retracement
  • Gann Fan
  • Equidistant Channel
  • Rectangle (new)
  • Price Range (new)

Tooling & Dependencies

  • Upgraded to Storybook 8.6.18
  • React 19 compatibility
  • Updated all devDependencies to latest versions
  • TypeScript improvements
  • ESLint and Prettier updates

Documentation

  • Added Storybook stories for all interactive components
  • Updated README with new features
  • Improved inline documentation

Bug Fixes

  • Fixed duplicate rendering issues on interactive objects
  • Corrected hover behavior on Equidistant Channel
  • Fixed selection not working on some components
  • Resolved canvas opacity accumulation during drawing

Testing

All components tested locally with Storybook. Performance verified with React DevTools.

Related

Fixes issues with:

  • Selection not working on some components
  • Performance degradation with multiple objects
  • Canvas opacity accumulation during drawing

sgonzaloc and others added 30 commits February 4, 2024 16:18
…ted node:internal/crypto/hash:68 error. Also install react for devDependencies to be able to fix error Failed to load preset: Cannot find module 'react/package.json'
Add react and react dom 19 to peer dependencies
- Updated all packages to support React 16.x || 17.x || 18.x || 19.x
- Upgraded @types/react and @types/react-dom to version 19
- Updated Storybook from 6.x to 8.x for React 19 compatibility
- Migrated all tsconfig.json to use 'react-jsx' transform
- Fixed TypeScript strict type checking issues for React 19
- Added explicit context type declarations for class components
- Updated useRef calls to include initial values (React 19 requirement)
- Added type safety for SVG attributes and optional function calls
- Removed unused React imports with new JSX transform
- All packages build successfully

See REACT_19_MIGRATION.md for detailed migration guide.
…nk, overlapping text selection priority, and editing index management
…ing selection to existing text tool, refactor interactive actions stories
- Move clearThreeCanvas() inside setState callbacks to prevent blank frames
- Update handleZoom, handlePinchZoomEnd, xAxisZoom, yAxisZoom, resetYDomain, handlePanEnd
- Remove redundant clearThreeCanvas from redraw() to avoid double cleaning
- Add explicit draw({ force: true }) after clearing within callbacks

This ensures canvas is never empty between state updates and redraws,
eliminating the visual flicker that occurred during interactive operations.
The Y-axis zoom was not working because chartId could be string while each.id
was number (or vice versa), causing strict equality to fail and preventing
the chart from being found.

Convert each.id to string before comparison to ensure the chart is always
found regardless of type mismatch.

This fixes the Y-axis drag/zoom functionality without affecting existing behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants