Commit 280fbda1 authored by David Anderson's avatar David Anderson
Browse files

pushed with regenerated files

parent 7a14ef32
import { EventHandler } from '../types/eventHandler.interface';
import { GistBehavior } from './gistBehavior.class';
import { LimiterType } from "../types/limiterType.type";
export declare type supportedEventType = 'dblclick' | 'click' | 'mousedown' | 'mousemove' | 'mouseout' | 'mouseover' | 'mouseup';
/**
* Adds a mouse event to a gist chart that will fire when the given event name fires and will call a function with data at the point given
*
* @export
* @class GetDataAtMouseEvent
*/
export declare class GetDataAtMouseEvent extends GistBehavior {
/**
*Creates an instance of GetDataAtMouseEvent.
* @param {(supportedEventType | supportedEventType[])} 'dblclick' | 'click' | 'mousedown' | 'mousemove' | 'mouseout' | 'mouseover' | 'mouseup'
* @param {(EventHandler | EventHandler[])} eventHandlers Define what to do when the event happens
* @param {number} [throttleTime=250] How often this event can happen
* @param {LimiterType} [limiter='throttle'] 'throttle' will ensure the event will wait throttleTime, before firing again. 'debounce' will wait throttletime without a repeat event to fire.
* @memberof GetDataAtMouseEvent
*/
closeEnough: number;
constructor(eventNames: supportedEventType | supportedEventType[], eventHandlers: EventHandler | EventHandler[], closeEnough?: number, throttleTime?: number, limiter?: LimiterType);
_activate(): void;
}
import { EventHandler } from '../types/eventHandler.interface';
import { ChartCanvas } from '../classes/chartCanvas.class';
import { LimiterType } from "../types/limiterType.type";
import { IMap } from '../types/iMap.interface';
/**
* Base class for behaviors. This defines how they will manage being throttled or debounced;
*
* @export
* @class GetDataAtMouseEvent
*/
export declare abstract class GistBehavior {
/**
* The id of this behavior
*
* @memberof GistBehavior
*/
readonly id: number;
/**
* This will be set by the gistchart that this behavior is added to.
*
* @type {(number | undefined)}
* @memberof GistBehavior
*/
canvas: ChartCanvas;
/**
* Whether or not the behavior should prevent the default handler for the event(s)
*
* @type {boolean}
* @memberof GistBehavior
*/
preventDefault: boolean;
/**
* The list of event names that this behavior will fire on. While we accept any string, behavior implementations will specify what strings are actually valid.
*
* @type {string[]}
* @memberof GistBehavior
*/
readonly eventNames: string[];
/**
* If and how this behavior fire rate should be limitted. If undefined, will be fired on every call.
*
* @type {limiterType}
* @memberof GistBehavior
*/
readonly limiter: LimiterType;
/**
* how many milliseconds to for the limiter to wait
*
* @type {number}
* @memberof GistBehavior
*/
readonly throttleTime: number;
/**
* List of what configs, and how they should handle the behavior when it activates
*
* @type {EventHandler[]}
* @memberof GistBehavior
*/
readonly eventHandlers: EventHandler[];
/**
* GistCharts Only. We store all callbacks for each event that we need to call. We do not manage it ourselves, but its up to the chartcanvas to call, add or remove events as other it may have other behaviors.
*/
_listenerCallbacks: IMap<Array<EventListenerOrEventListenerObject>>;
cancelWaitForFire(shouldFireImmediate?: boolean): void;
/**
* setTimeout promise
*
* @protected
* @type {(number | undefined)}
* @memberof GistBehavior
*/
protected timer: number | undefined;
/**
* extra flag used in throttling
*
* @protected
* @type {boolean}
* @memberof GistBehavior
*/
protected isBusy: boolean;
/**
* the current X position of the mouse. updates on every event, even between limitted calls.
*
* @protected
* @type {number}
* @memberof GistBehavior
*/
protected currentX: number;
/**
* the current Y position of the mouse. updates on every event, even between limitted calls.
*
* @protected
* @type {number}
* @memberof GistBehavior
*/
protected currentY: number;
/**
* the current mouse event. updates on every event, even between limitted calls.
*
* @protected
* @type {number}
* @memberof GistBehavior
*/
protected currentEvent: MouseEvent;
constructor(eventNames: string | string[], eventHandlers: EventHandler | EventHandler[], throttleTime: number | undefined, limiter: LimiterType);
/**
* Defines how what this behavior does on the limited calls.
*
* @abstract
* @memberof GistBehavior
*/
protected _activate(): void;
/**
* Allows the implemented behaviors to do any clean up that they need
*
* @protected
* @memberof GistBehavior
*/
protected onDestroy: () => void;
/**
* GistCharts Only! What actually gets called when the handled events happen.
*
* @param {number} x
* @param {number} y
* @param {MouseEvent} event
* @memberof GistBehavior
*/
_fire(x: number, y: number, event: MouseEvent): boolean;
/**
* GistCharts Only! This will be called when the behavior is removed.
*
* @memberof GistBehavior
*/
_destroy(): void;
private throttle(x, y, event);
private debounce(x, y, event);
private callActivate();
private reset();
}
import { GistBehavior } from './gistBehavior.class';
import { SupportedPanEvent } from "../types/supportedPanEvent.type";
import { BaseAxis } from '../configs/axis/baseAxis.class';
/**
* Adds a mouse event to a gist chart that will fire when the given event name fires and will call a function with data at the point given
*
* @export
* @class GetDataAtMouseEvent
*/
export declare class PanBehavior extends GistBehavior {
private mousedown;
private lastPosition;
private maskingElement;
private userSelectValue;
private hasWarned;
/**
*Creates an instance of PanBehavior.
* @param {(SupportedPanEvent | SupportedPanEvent[])} [eventNames='mousedrag'] // mouse drag works by holding the mouse down and dragging, will stop when the mouse is released. Wheel works on scroll ( magic mouse compatible )
* @param {number} [throttleTime=15] // the delay on pans
* @memberof PanBehavior
*/
constructor(eventNames?: SupportedPanEvent | SupportedPanEvent[], throttleTime?: number);
/**
* BETA feature! still buggy
* Set the min and max pan value for the given axis. Values inside the pan limits will always be visible.
*
* @param {(BaseAxis | Array<BaseAxis>)} targets
* @param {number} minZoomLevel
* @param {number} maxZoomLevel
* @memberof ZoomBehavior
*/
limitPan(axis: BaseAxis, minValue: any, maxValue: any): void;
_togglepan(mouseEvent: MouseEvent): void;
_pan(mouseEvent: MouseEvent): void;
}
import { GistBehavior } from './gistBehavior.class';
import { ZoomMethod } from "../types/zoomMethod.type";
import { BaseAxis } from '../configs/axis/baseAxis.class';
/**
* Adds a mouse event to a gist chart that will fire when the given event name fires and will call a function with data at the point given
*
* @export
* @class GetDataAtMouseEvent
*/
export declare class ZoomBehavior extends GistBehavior {
private zoomConstant;
private zoomMethod;
private hasWarned;
/**
*Creates an instance of ZoomBehavior.
* @param {number} [zoomConstant=1.15] controls how strong the zoom step is
* @param {ZoomMethod} [zoomMethod='multiplication'] multiplication zoom steps are based on the current zoom level resulting in a smoother movement. addition will jump by steps
* @param {number} [throttleTime=50] how long in milliseconds to throttle the event
* @memberof ZoomBehavior
*/
constructor(zoomConstant?: number, zoomMethod?: ZoomMethod, throttleTime?: number);
/**
* BETA feature! still buggy
* Set the min and max zoom level for the given axis.
*
* @param {(BaseAxis | Array<BaseAxis>)} targets
* @param {number} minZoomLevel
* @param {number} maxZoomLevel
* @memberof ZoomBehavior
*/
limitZoom(targets: BaseAxis | Array<BaseAxis>, minZoomLevel: number, maxZoomLevel: number): void;
_zoom(mouseEvent: MouseEvent): void;
}
import { DebugLogger } from './debugLogger.class';
import { GistChartLayout } from './gistChartLayout.type';
import { BaseAxis } from '../configs/axis/baseAxis.class';
import { DataPoint } from './datapoint.class';
import { BaseChart } from '../configs/charts/baseChart.class';
import { GistBehavior } from '../behaviors/gistBehavior.class';
/**
* This is the base object to create when building a chart. All axis, and charts will be added and controlled via this class
*
* @export
* @class ChartCanvas
*/
export declare class ChartCanvas {
/**
* Unique identifier of this chart chart.
*
* @type {number}
* @memberof BaseChart
*/
readonly id: number;
/**
* The debug logger. To enable debugger, the isEnabled property must be set to true. It is also advised to set logPrefix to distinguish between different debuggers
*
* @memberof ChartCanvas
*/
readonly debugLogger: DebugLogger;
/**
* This is the element that the chart will display in. When this is told to render, it will draw to size of this element.
*
* @type {HTMLElement}
* @memberof ChartCanvas
*/
private contextEle;
/**
* Gist Charts only! Tracks the clickable space that can be panned via double clicks
*
* @type {{ x0: number, x1: number, y0: number, y1: number }}
* @memberof ChartCanvas
*/
_panClickSpace: {
x0: number;
x1: number;
y0: number;
y1: number;
};
/**
* Gist Charts only! Should only be changed through the zoom method. The current zoom level. Defaults to 1
*
* @type {number}
* @memberof ChartCanvas
*/
_currentZoomState: number;
/**
* The color of the background of the base canvas element in the ChartCanvas.
* undefined is transparent
*
* @type {string}
* @memberof ChartCanvas
*/
background: string | undefined;
layout: GistChartLayout;
private capturedEvents;
private canvas;
private chartList;
private axisList;
private currentBehaviors;
private renderedRatio;
private renderedSizes;
private animationFrame;
private _areRenderChartsShowing;
constructor(container: HTMLElement);
/**
* Add one or many charts to be rendered
*
* @param {(BaseChart<DataPoint> | BaseChart<DataPoint>[])} configs
* @memberof ChartCanvas
*/
addChart(configs: BaseChart<DataPoint> | BaseChart<DataPoint>[]): void;
/**
* Remove one or many charts to be rendered
*
* @param {(BaseChart<DataPoint> | BaseChart<DataPoint>[])} configs
* @memberof ChartCanvas
*/
removeChart(configs: BaseChart<DataPoint> | BaseChart<DataPoint>[]): void;
/**
* add one or many axis to be rendered
*
* @param {(BaseAxis | Array<BaseAxis>)} configs
* @memberof ChartCanvas
*/
addAxis(configs: BaseAxis | Array<BaseAxis>): void;
/**
* remove one or many axis, will disappear on next redraw
*
* @param {(BaseAxis | Array<BaseAxis>)} configs
* @memberof ChartCanvas
*/
removeAxis(configs: BaseAxis | Array<BaseAxis>): void;
/**
* updates the rendered chart
*
* @memberof ChartCanvas
*/
beginRender(): void;
/**
*
*
* @memberof ChartCanvas
*/
stopRender(): void;
/**
* Add behaviors to this chart.
*
* @param {(GistBehavior | GistBehavior[])} behavior
* @memberof ChartCanvas
*/
addBehavior(behavior: GistBehavior | GistBehavior[]): void;
/**
* Remove the given behaviors from this chart, this will cancel any throttled events
*
* @param {(GistBehavior | GistBehavior[])} behaviors
* @memberof ChartCanvas
*/
removeBehavior(behaviors: GistBehavior | GistBehavior[]): void;
/**
* Call this method to cancel all behaviors that are waiting to fire. This will be called automatically on mouse leave.
*
* @memberof ChartCanvas
*/
cancelBehaviorActivation(): void;
/**
* Set the current zoom level
* @param zoomLevel Target zoom level
*/
zoom(zoomLevel: number): void;
/**
* Pan the chart by the given x, y values
*
* @param {{ x: number, y: number }} panValue
* @memberof ChartCanvas
*/
pan(x: number, y: number): void;
/**
* Calls toDataUrl on this canvas displayed html canvas element
*
* @param {string} [type]
* @returns {string}
* @memberof ChartCanvas
*/
getDataUrl(type?: string): string;
getImageData(x?: number, y?: number, width?: number, height?: number): ImageData;
/**
*Tells axis to re render. As the axis update with this call, you should probably call renderCharts after this. Returns true if axis will render. false if they wont ( invalid canvas size )
*
* @private
* @returns {boolean}
* @memberof ChartCanvas
*/
private renderAxis();
/**
* Render the given charts. This will happen without updating axis, so would be used when you know the axis is stable.
*
* @private
* @memberof ChartCanvas
*/
private renderCharts();
private pollCharts();
private showCharts();
private drawGridLines();
private copyCharts();
private stabilizeSizes();
/**
* Calls getAxisSizes on all axis and places them on a TBLR
*
* @private
* @returns {TBLR<number>}
* @memberof ChartCanvas
*/
private getAxisSizes();
}
import { Extent } from './extent.class';
import { BaseChart } from '../configs/charts/baseChart.class';
export declare class DataPoint<T = any> {
/**
*The data you have assigned to this data point. It can be any object that you like.
*
* @type {(T | undefined)}
* @memberof DataPoint
*/
data: T | undefined;
/**
* Gist Chart use only.
* When a chart draws this data point, it will record its xy extents here
*
* @private
* @type {{ [ key: number ]: Extent }}
* @memberof DataPoint
*/
_chartIdToExtentMap: {
[key: number]: Extent;
};
_clearExtentForChart(chart: BaseChart): void;
/**
* Returns a MinMax for the x, y that are the pixels realtive to the top left corner of the canvas element
*
* @param {BaseChart} config
* @returns {Extent}
* @memberof DataPoint
*/
getExtent(chart: BaseChart): Extent;
constructor(d?: T);
}
/**
* This class is used to toggle debug messages on gist charts
*
* @export
* @class DebugLogger
*/
export declare class DebugLogger {
/**
*
* logPrefix will set as the first argument to any logs printed, defaults to undefined
*
* @type {(string | undefined)}
* @memberof DebugLogger
*/
logPrefix: string | undefined;
/**
* What function to call for printing? Defaults to window.console
*
* @type {Function}
* @memberof DebugLogger
*/
logMethod: Function;
/**
* Should debug messages be printed? Defaults to false
*
* @type {boolean}
* @memberof DebugLogger
*/
isEnabled: boolean;
constructor(logPrefix?: string | undefined, logMethod?: any, isEnabled?: boolean);
/**
* GIST CHARTS ONLY
* Calls the log method, if this debugger is enabled
*
* @param {...any[]} args
* @memberof DebugLogger
*/
_log(...args: any[]): void;
}
import { MinMax } from './minMax.class';
export declare class Extent {
x: MinMax;
y: MinMax;
isInExtent(xValue: number, yValue: number, closeEnough?: number): boolean;
}
export declare class GistCanvas {
/**
* The canvas element to be drawn to
*
* @type {HTMLCanvasElement}
* @memberof BaseAxis
*/
readonly canvasEle: HTMLCanvasElement;
/**
* Set the size of canvas element. Returns true if this canvas is big enough to draw on without throwing an error
*
* @param {number} width
* @param {number} height
* @returns {boolean}
* @memberof GistCanvas
*/
setSize(width: number, height: number): boolean;
/**
* Get the context of the canvas element
*
* @readonly
* @type {CanvasRenderingContext2D}
* @memberof GistCanvas
*/
readonly context: CanvasRenderingContext2D;
/**
* Clear out this canvas. If a color is provided, it will be filled with it
*
* @param {string} [background]
* @memberof GistCanvas
*/
clearCanvas(background?: string, margin?: number): void;
/**
* Draw this canvas on another canvas at the given offset
*
* @param {HTMLCanvasElement} dest
* @param {number} offsetLeft
* @param {number} offsetTop
* @memberof GistCanvas
*/
renderTo(dest: HTMLCanvasElement, offsetLeft: number, offsetTop: number): void;
/**
* Returns true if this canvas is big enough to draw on without throwing an error
*
* @param {HTMLCanvasElement} [ele]
* @returns {boolean}
* @memberof GistCanvas
*/
isSizeValid(ele?: HTMLCanvasElement): boolean;
}
import { MinMax } from './minMax.class';
import { TBLR } from './tblr.class';
export declare class GistChartLayout {
marginLimits: TBLR<MinMax>;
chartWidth: MinMax;
chartHeight: MinMax;
setAllMargins(value: number): void;
constructor();
}
export declare class MinMax {
min: number;
max: number;
/**
* Given number will be compared to the min and max, and will update those if it is not between them;
*
* @param {number} x
* @memberof MinMax
*/
compare(x: number): void;
/**
* Will compare x to the min and max values with a tolerance range of close enough
*
* @param {number} x
* @param {number} [closeEnough=0]
* @returns
* @memberof MinMax
*/
isBetween(x: number, closeEnough?: number): boolean;
}
export declare class TBLR<T> {
top: T;
bottom: T;
left: T;
right: T;
constructor(init: T | {
top: T;
bottom: T;
left: T;
right: T;
});
/**
* Returns true if all values match the given istance
* @param b
*/
isEqual(b: {
top: T;
bottom: T;
left: T;
right: T;
}): boolean;
/**
*If a single value is given; top, bottom, left and right will be set to it. If a tblr instance is given. the values will be set to match it
*
* @param {(T | { top: T, bottom: T, left: T, right: T })} val
* @memberof TBLR
*/