Flash Highlighting
Flash Highlighting
Section titled “Flash Highlighting”Cells flash green or red when numeric values change. Essential for real-time trading data.
Enable Flash
Section titled “Enable Flash”Add flashOnChange: true to column definitions:
const columns = [ { field: 'symbol', header: 'Symbol' }, { field: 'price', header: 'Price', flashOnChange: true }, { field: 'volume', header: 'Volume', flashOnChange: true },];How It Works
Section titled “How It Works”When a cell value changes:
- Increase: Cell flashes green
- Decrease: Cell flashes red
- Animation duration: 300ms
The grid tracks previous values by row key, so each row’s changes are detected independently.
Disable Globally
Section titled “Disable Globally”Disable all flash highlighting:
<DataGrid data={data} columns={columns} rowKey="id" disableFlash/>Useful for:
- Initial data load (avoid all cells flashing)
- Low-power mode
- Accessibility preferences
Adaptive Mode
Section titled “Adaptive Mode”Flash highlighting automatically disables when performance drops:
// The grid monitors FPS internally// When FPS drops below 55, flash effects are temporarily disabled// When FPS recovers above 58, flash effects resumeThis ensures smooth scrolling and interaction even with high update rates.
How Adaptive Mode Works
Section titled “How Adaptive Mode Works”- The
useAdaptiveFlashhook monitors frame rate - Uses
requestAnimationFrametiming for FPS calculation - Hysteresis prevents rapid toggling (55 FPS off, 58 FPS on)
Customize Flash Colors
Section titled “Customize Flash Colors”Use CSS variables:
:root { --grid-flash-up: rgba(34, 197, 94, 0.4); /* Green flash */ --grid-flash-down: rgba(239, 68, 68, 0.4); /* Red flash */}
/* Custom colors */.my-grid { --grid-flash-up: rgba(0, 255, 0, 0.3); --grid-flash-down: rgba(255, 0, 0, 0.3);}Flash Animation
Section titled “Flash Animation”The default animation:
@keyframes askturret-grid-flash-up { 0% { background-color: var(--grid-flash-up); } 100% { background-color: transparent; }}
@keyframes askturret-grid-flash-down { 0% { background-color: var(--grid-flash-down); } 100% { background-color: transparent; }}
.askturret-grid-flash-up { animation: askturret-grid-flash-up 300ms ease-out;}
.askturret-grid-flash-down { animation: askturret-grid-flash-down 300ms ease-out;}Override to customize duration or easing:
.askturret-grid-flash-up { animation-duration: 500ms; animation-timing-function: linear;}Performance Considerations
Section titled “Performance Considerations”Lazy Detection
Section titled “Lazy Detection”Flash detection only runs for visible rows. Rows outside the viewport don’t trigger comparisons.
Update Rate
Section titled “Update Rate”The grid handles high update rates efficiently:
- 100+ updates per second sustained
- Flash animations are batched per frame
- DOM updates are minimized
Best Practices
Section titled “Best Practices”-
Use row keys: Ensure
rowKeycorrectly identifies rows for accurate change detection -
Batch updates: If possible, batch multiple row updates into a single state update:
// Good - single state updatesetData(prev => updateMultipleRows(prev, updates));// Avoid - multiple state updatesupdates.forEach(update => {setData(prev => updateRow(prev, update));}); -
Immutable updates: Create new row objects when values change:
// Good - new object referencesetData(prev => prev.map(row =>row.id === id ? { ...row, price: newPrice } : row));// Bad - mutating existing objectdata.find(row => row.id === id).price = newPrice;setData([...data]);
Trading Component Flash
Section titled “Trading Component Flash”All trading components support flash highlighting:
OrderBook
Section titled “OrderBook”<OrderBook data={data} flashOnChange={true} // Default/>TimeSales
Section titled “TimeSales”<TimeSales trades={trades} flashOnNew={true} // Flash new trades/>PositionLadder
Section titled “PositionLadder”<PositionLadder levels={levels} tickSize={0.25} centerPrice={100} flashOnChange={true} // Default/>