@equinor/videx-wellog
Version:
Visualisation components for wellbore log data
189 lines (188 loc) • 5.62 kB
TypeScript
import { ZoomBehavior } from 'd3-zoom';
import { DebounceFunction } from '../utils';
import { ScaleHandler } from '../scale-handlers';
import { Track } from '../tracks';
import { D3Selection, Domain, Scale } from '../common/interfaces';
import { LogControllerOptions } from './interfaces';
interface LegendMap {
elm: Element;
track: Track;
}
/**
* A container component for tracks, with track titles, legends,
* adding/removing tracks, resizing and user interaction.
*/
export default class LogController {
options: LogControllerOptions;
tracks: Track[];
container: D3Selection;
zoom: ZoomBehavior<Element, any>;
width: number;
height: number;
debounce: DebounceFunction;
legends: {
[propName: string]: LegendMap;
[propName: number]: LegendMap;
};
legendRows: number;
protected _trackHeight: number;
protected _uiScale: number;
protected _titleHeight: number;
protected _legendHeight: number;
protected _titleFontSize: number;
protected _initialized: boolean;
private _scaleHandler;
private _observer;
private _deferredUpdate;
constructor(options?: LogControllerOptions);
/**
* Simple creator function for minimal setup
* @param showTitles optional flag to show titles or not
*/
static basic(showTitles?: boolean): LogController;
/**
* Convenience method if used stand-alone. Wraps onMount and
* returns self for chaining.
* @param element HTML element to attach itself to
*/
init(element: HTMLElement): LogController;
/**
* Initialize the component and attach itself to the provided DOM element.
* @param element HTML element to attach itself to
*/
onMount(element: HTMLElement): void;
/**
* To unregister event listeners etc.
*/
onUnmount(): void;
/**
* Set the tracks for this controller, replacing any existing tracks
* @param tracks track or tracks to set
*/
setTracks(...track: Track[]): LogController;
setTracks(tracks: Track[]): LogController;
/**
* Adds a single track to the log controller
* @param track track to be added
*/
addTrack(track: Track): LogController;
/**
* Removes a track from the log controller component
* @param track track to be removed
*/
removeTrack(track: Track): LogController;
/**
* Rescale according to new container size
* @param force Set to true in order to force update even if size has not changed
*/
adjustToSize(force?: boolean): void;
zoomTo(domain: Domain, duration?: number, callback?: Function): LogController;
/**
* Notify all clients (tracks) on changes to domain/transform
* @param domain optional domain to scale to
* @param duration optional duration of transition effect, 0 = no transition
*/
rescale(): void;
/**
* Force a redraw
*/
refresh(): void;
/**
* Update track-elements based on current registered track instances
*/
updateTracks(): LogController;
/**
* Remove all tracks and update ui
*/
reset(): LogController;
/**
* Setup DOM elements, scale and behaviour
* @param element Html element to attach to
*/
protected setup(element: HTMLElement): void;
/**
* Processes track legend config object, creating the necessary DOM elements and
* hooking up callback functions etc.
* @param track Track to process
* @param element Legend element
*/
protected processLegendConfig(track: Track, element: Element): void;
/**
* Event handler for pan/zoom
*/
protected zoomed(event: any): void;
/**
* Recalculates transform based on new container size
*/
protected adjustZoomTransform(): void;
/**
* Determines the required number of rows in the legend section.
*/
protected updateLegendRows(): void;
/**
* Updates the legend for a specific track
* @param id Track id
*/
protected updateLegend(id: string | number): void;
/**
* Adjust track titles according to available space. Uses abbrievation
* istead of full label if not enough space.
*/
protected adjustTrackTitles(): void;
/**
* Trigger onUpdate event after tracks has been altered in size
*/
protected postUpdateTracks(): void;
/**
* Remove DOM-elements belonging to removed tracks
* @param selection exit selection
*/
private _trackExit;
/**
* Add DOM-elements for new tracks
* @param selection enter selection
*/
private _trackEnter;
/**
* Update DOM-elements for existing tracks
* @param selection update selection
*/
private _trackUpdate;
/**
* DOM element that has the zoom behaviour attached
*/
get zoomHandler(): any;
/**
* Get the track container's dimmensions, relative
* to orientation.
*/
get innerBounds(): {
length: number;
span: number;
};
/**
* Getter for (base) domain
* @returns {number[]}
*/
get domain(): Domain;
/**
* Setter for (base) domain
* @param {number[]} value
*/
set domain(value: Domain);
/**
* Getter for scaleHandler
* @returns {class} current scale handler
*/
get scaleHandler(): ScaleHandler;
/**
* Setter for scaleHandler
* @param newHandler new scale handler
*/
set scaleHandler(newHandler: ScaleHandler);
/**
* Getter for the component's internal scale
*/
get scale(): Scale;
}
export {};