HTMLGraph

Box Area Rendering

Instead of relying on the built-in virtual scroll, you can fine-tune your own virtual scroll implementation. This can be achieved by providing an EventSubject trigger for graph rendering within a bounded area using the enableBoxAreaRendering method of CanvasBuilder.

    
import { CanvasBuilder, EventSubject } from '@html-graph/html-graph';

const trigger = new EventSubject();
const element = document.getElementById('canvas');

const canvas = new CanvasBuilder()
  .setElement(element)
  .enableBoxAreaRendering(trigger)
  .build();

  

You can then trigger rendering within a specific bounded area:

    
trigger.emit({ x: 100, y: 100, width: 1200, height: 1200 });

  

EventSubject

EventSubject is a straightforward implementation of the Observer pattern.

EventSubject<T> provides the following methods:

NameArgumentsDescription
subscribefunction (payload: T) => voidAdds a function to call on emit
unsubscribefunction (payload: T) => voidRemoves a function to call on emit
emitTCalls all subscribed callbacks

When a box rendering trigger is specified, it becomes your responsibility to initiate rendering (unless you use the built-in virtual scroll).

Box Area Rendering