From 1a48a541a4133a36204cce8fabcb1f36935fc500 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Mon, 28 Sep 2015 10:00:49 +0200 Subject: [PATCH 01/19] Add key function to Dataset --- src/core/dataset.ts | 27 +++++++++++++++++++++++++++ src/drawers/drawer.ts | 10 +++++++++- src/plots/scatterPlot.ts | 6 ------ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index e9e9118756..921b3d9ee7 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -4,9 +4,18 @@ module Plottable { export type DatasetCallback = (dataset: Dataset) => void; + +export class KeyFunctions { + protected static counter: number = 0; + public static NoConstancy: (d: any, i: number) => any = (d: any) => { return KeyFunctions.counter++; }; + public static ByIndex: (d: any, i: number) => any = (d: any, i: number) => { return i; }; +} + + export class Dataset { private _data: any[]; private _metadata: any; + private _key: (datum: any, index: number) => any = KeyFunctions.NoConstancy; private _callbacks: Utils.CallbackSet; /** @@ -90,5 +99,23 @@ export class Dataset { return this; } } + + public key(): (datum: any, index: number) => any; + /** + * Sets the key. + * + * @param { (d: any, i: number) => any} key + * @returns {Dataset} The calling Dataset. + */ + public key(key: (datum: any, index: number) => any): Dataset; + public key(key?: (datum: any, index: number) => any): any { + if (key == null) { + return this._key; + } else { + this._key = key; + this._callbacks.callCallbacks(this); + return this; + } + } } } diff --git a/src/drawers/drawer.ts b/src/drawers/drawer.ts index 1f5fe45dc5..e4b95e02d9 100644 --- a/src/drawers/drawer.ts +++ b/src/drawers/drawer.ts @@ -76,7 +76,15 @@ export class Drawer { * @param{any[]} data The data to be drawn */ private _bindSelectionData(data: any[]) { - let dataElements = this.selection().data(data); + // if the dataset has a key, use it when binding the data + var dataElements: d3.selection.Update; + if (this._dataset && this._dataset.key) { + dataElements = this.selection().data(data, this._dataset.key()); + } + else { + dataElements = this.selection().data(data); + } + dataElements.enter().append(this._svgElementName); dataElements.exit().remove(); this._applyDefaultAttributes(dataElements); diff --git a/src/plots/scatterPlot.ts b/src/plots/scatterPlot.ts index 94c55d8bd4..c5cd209ec7 100644 --- a/src/plots/scatterPlot.ts +++ b/src/plots/scatterPlot.ts @@ -83,12 +83,6 @@ export module Plots { protected _generateDrawSteps(): Drawers.DrawStep[] { let drawSteps: Drawers.DrawStep[] = []; - if (this._animateOnNextRender()) { - let resetAttrToProjector = this._generateAttrToProjector(); - resetAttrToProjector["d"] = () => ""; - drawSteps.push({attrToProjector: resetAttrToProjector, animator: this._getAnimator(Plots.Animator.RESET)}); - } - drawSteps.push({attrToProjector: this._generateAttrToProjector(), animator: this._getAnimator(Plots.Animator.MAIN)}); return drawSteps; } From cd39443d6cbcfb7897b980ee98afb0bbc320f435 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Mon, 28 Sep 2015 10:01:30 +0200 Subject: [PATCH 02/19] Dataset key function tests --- test/core/datasetTests.ts | 19 ++++++++++++++++++ test/core/keyTests.ts | 41 +++++++++++++++++++++++++++++++++++++++ test/testReference.ts | 1 + 3 files changed, 61 insertions(+) create mode 100644 test/core/keyTests.ts diff --git a/test/core/datasetTests.ts b/test/core/datasetTests.ts index 5119ab7bd5..2fd2db5e6a 100644 --- a/test/core/datasetTests.ts +++ b/test/core/datasetTests.ts @@ -56,4 +56,23 @@ describe("Dataset", () => { ds.data(newData2); assert.isFalse(callbackCalled, "callback was called when the data was changed"); }); + describe("key", () => { + it("Updates listeners when the key is changed", () => { + let ds = new Plottable.Dataset(); + + let newKey = (d: any, i: number) => { return i * i; }; + + let callbackCalled = false; + let callback = (listenable: Plottable.Dataset) => { + assert.strictEqual(listenable, ds, "Callback received the Dataset as the first argument"); + assert.deepEqual(ds.key(), newKey, "Dataset arrives with correct key"); + callbackCalled = true; + }; + ds.onUpdate(callback); + + ds.key(newKey); + assert.isTrue(callbackCalled, "callback was called when the key was changed"); + }); + + }); }); diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts new file mode 100644 index 0000000000..115d2d10be --- /dev/null +++ b/test/core/keyTests.ts @@ -0,0 +1,41 @@ +/// + +describe("DatasetKey", () => { + it(" is passed to Dataset", () => { + let ds: Plottable.Dataset = new Plottable.Dataset(); + let key: (d: any, i: number) => number = (d: any, i: number) => { return i }; + ds.key(key); + assert.deepEqual(ds.key(),key,"key is passed to dataset"); + }); + it(" may accept NoConstancy predefined key function", () => { + let ds: Plottable.Dataset = new Plottable.Dataset(); + ds.key(Plottable.KeyFunctions.NoConstancy); + let d: any = { foo: "bar" }; + let a: number = ds.key()(d, 1); + let b: number = ds.key()(d, 1); + assert.isTrue(b - a == 1, "invocations give numerically increasing results"); + }); + it(" defaults to NoConstancy predefined key function", () => { + let ds: Plottable.Dataset = new Plottable.Dataset(); + assert.isTrue(ds.key() === Plottable.KeyFunctions.NoConstancy, "NoConstancy is default"); + }); + it(" may accept ByIndex predefined key function", () => { + let ds: Plottable.Dataset = new Plottable.Dataset(); + ds.key(Plottable.KeyFunctions.ByIndex); + let d: any = { foo: "bar" }; + let a: number = ds.key()(d, 1); + let b: number = ds.key()(d, 2); + assert.isTrue(a == 1, "invocations return index"); + assert.isTrue(b == 2, "invocations return index"); + }); + describe("DatasetKey NoConstancy", () => { + it("generates a different value each time invoked", () => { + let key = Plottable.KeyFunctions.NoConstancy; + let d: any = { foo: "bar" }; + let a: number = key(d, 1); + let b: number = key(d, 1); + + assert.isTrue(b - a == 1, "invocations give numerically increasing results"); + }); + }); +}); diff --git a/test/testReference.ts b/test/testReference.ts index 3c22a1d2c6..8ced9583fc 100644 --- a/test/testReference.ts +++ b/test/testReference.ts @@ -49,6 +49,7 @@ /// /// /// +/// /// /// From 5defba07661e6ce3d6693f0ba1062b3108c13400 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 08:51:13 +1000 Subject: [PATCH 03/19] tslint cleanups on dataset key --- src/core/dataset.ts | 6 ++---- src/drawers/drawer.ts | 5 ++--- test/core/keyTests.ts | 18 +++++++++--------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 921b3d9ee7..c5e07ff051 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -4,14 +4,12 @@ module Plottable { export type DatasetCallback = (dataset: Dataset) => void; - export class KeyFunctions { protected static counter: number = 0; - public static NoConstancy: (d: any, i: number) => any = (d: any) => { return KeyFunctions.counter++; }; - public static ByIndex: (d: any, i: number) => any = (d: any, i: number) => { return i; }; + public static noConstancy: (d: any, i: number) => any = (d: any) => { return KeyFunctions.counter++; }; + public static byIndex: (d: any, i: number) => any = (d: any, i: number) => { return i; }; } - export class Dataset { private _data: any[]; private _metadata: any; diff --git a/src/drawers/drawer.ts b/src/drawers/drawer.ts index e4b95e02d9..81f93502a9 100644 --- a/src/drawers/drawer.ts +++ b/src/drawers/drawer.ts @@ -77,11 +77,10 @@ export class Drawer { */ private _bindSelectionData(data: any[]) { // if the dataset has a key, use it when binding the data - var dataElements: d3.selection.Update; + let dataElements: d3.selection.Update; if (this._dataset && this._dataset.key) { dataElements = this.selection().data(data, this._dataset.key()); - } - else { + } else { dataElements = this.selection().data(data); } diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts index 115d2d10be..e72fc1f3db 100644 --- a/test/core/keyTests.ts +++ b/test/core/keyTests.ts @@ -3,30 +3,30 @@ describe("DatasetKey", () => { it(" is passed to Dataset", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - let key: (d: any, i: number) => number = (d: any, i: number) => { return i }; + let key: (d: any, i: number) => number = (d: any, i: number) => { return i; }; ds.key(key); - assert.deepEqual(ds.key(),key,"key is passed to dataset"); + assert.deepEqual(ds.key(), key, "key is passed to dataset"); }); it(" may accept NoConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - ds.key(Plottable.KeyFunctions.NoConstancy); + ds.key(Plottable.KeyFunctions.noConstancy); let d: any = { foo: "bar" }; let a: number = ds.key()(d, 1); let b: number = ds.key()(d, 1); - assert.isTrue(b - a == 1, "invocations give numerically increasing results"); + assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); it(" defaults to NoConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - assert.isTrue(ds.key() === Plottable.KeyFunctions.NoConstancy, "NoConstancy is default"); + assert.isTrue(ds.key() === Plottable.KeyFunctions.noConstancy, "NoConstancy is default"); }); it(" may accept ByIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - ds.key(Plottable.KeyFunctions.ByIndex); + ds.key(Plottable.KeyFunctions.byIndex); let d: any = { foo: "bar" }; let a: number = ds.key()(d, 1); let b: number = ds.key()(d, 2); - assert.isTrue(a == 1, "invocations return index"); - assert.isTrue(b == 2, "invocations return index"); + assert.isTrue(a === 1, "invocations return index"); + assert.isTrue(b === 2, "invocations return index"); }); describe("DatasetKey NoConstancy", () => { it("generates a different value each time invoked", () => { @@ -35,7 +35,7 @@ describe("DatasetKey", () => { let a: number = key(d, 1); let b: number = key(d, 1); - assert.isTrue(b - a == 1, "invocations give numerically increasing results"); + assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); }); }); From b012683fbabdf34a6db2708d42a28a4c0fc0de0a Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 09:07:57 +1000 Subject: [PATCH 04/19] fix after travis ci test --- src/core/dataset.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index c5e07ff051..d979d77968 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -13,7 +13,7 @@ export class KeyFunctions { export class Dataset { private _data: any[]; private _metadata: any; - private _key: (datum: any, index: number) => any = KeyFunctions.NoConstancy; + private _key: (datum: any, index: number) => any = KeyFunctions.noConstancy; private _callbacks: Utils.CallbackSet; /** From aba60667b42b7e58b816457e800ab906eb5b97f7 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 09:13:22 +1000 Subject: [PATCH 05/19] fix case --- test/core/keyTests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts index e72fc1f3db..8d894b697d 100644 --- a/test/core/keyTests.ts +++ b/test/core/keyTests.ts @@ -7,7 +7,7 @@ describe("DatasetKey", () => { ds.key(key); assert.deepEqual(ds.key(), key, "key is passed to dataset"); }); - it(" may accept NoConstancy predefined key function", () => { + it(" may accept noConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); ds.key(Plottable.KeyFunctions.noConstancy); let d: any = { foo: "bar" }; @@ -15,9 +15,9 @@ describe("DatasetKey", () => { let b: number = ds.key()(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); - it(" defaults to NoConstancy predefined key function", () => { + it(" defaults to noConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - assert.isTrue(ds.key() === Plottable.KeyFunctions.noConstancy, "NoConstancy is default"); + assert.isTrue(ds.key() === Plottable.KeyFunctions.noConstancy, "noConstancy is default"); }); it(" may accept ByIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); @@ -28,9 +28,9 @@ describe("DatasetKey", () => { assert.isTrue(a === 1, "invocations return index"); assert.isTrue(b === 2, "invocations return index"); }); - describe("DatasetKey NoConstancy", () => { + describe("DatasetKey noConstancy", () => { it("generates a different value each time invoked", () => { - let key = Plottable.KeyFunctions.NoConstancy; + let key = Plottable.KeyFunctions.noConstancy; let d: any = { foo: "bar" }; let a: number = key(d, 1); let b: number = key(d, 1); From b6cc5afdb4ed7aefb0a2855ae4f66f588151966a Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 10:11:34 +1000 Subject: [PATCH 06/19] compiled outputs --- plottable.d.ts | 9731 ++++++++++++++++++++++++------------------------ plottable.js | 34 +- 2 files changed, 4959 insertions(+), 4806 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index 7f28dd38f6..765d4f2c23 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -1,4800 +1,4931 @@ - -declare module Plottable { - module Utils { - module Math { - /** - * Checks if x is between a and b. - * - * @param {number} x The value to test if in range - * @param {number} a The beginning of the (inclusive) range - * @param {number} b The ending of the (inclusive) range - * @return {boolean} Whether x is in [a, b] - */ - function inRange(x: number, a: number, b: number): boolean; - /** - * Clamps x to the range [min, max]. - * - * @param {number} x The value to be clamped. - * @param {number} min The minimum value. - * @param {number} max The maximum value. - * @return {number} A clamped value in the range [min, max]. - */ - function clamp(x: number, min: number, max: number): number; - /** - * Applies the accessor, if provided, to each element of `array` and returns the maximum value. - * If no maximum value can be computed, returns defaultValue. - */ - function max(array: C[], defaultValue: C): C; - function max(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; - /** - * Applies the accessor, if provided, to each element of `array` and returns the minimum value. - * If no minimum value can be computed, returns defaultValue. - */ - function min(array: C[], defaultValue: C): C; - function min(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; - /** - * Returns true **only** if x is NaN - */ - function isNaN(n: any): boolean; - /** - * Returns true if the argument is a number, which is not NaN - * Numbers represented as strings do not pass this function - */ - function isValidNumber(n: any): boolean; - /** - * Generates an array of consecutive, strictly increasing numbers - * in the range [start, stop) separeted by step - */ - function range(start: number, stop: number, step?: number): number[]; - /** - * Returns the square of the distance between two points - * - * @param {Point} p1 - * @param {Point} p2 - * @return {number} dist(p1, p2)^2 - */ - function distanceSquared(p1: Point, p2: Point): number; - function degreesToRadians(degree: number): number; - } - } -} - - -declare module Plottable { - module Utils { - /** - * Shim for ES6 map. - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map - */ - class Map { - constructor(); - set(key: K, value: V): Map; - get(key: K): V; - has(key: K): boolean; - forEach(callbackFn: (value: V, key: K, map: Map) => void, thisArg?: any): void; - delete(key: K): boolean; - } - } -} - - -declare module Plottable { - module Utils { - /** - * Shim for ES6 set. - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set - */ - class Set { - size: number; - constructor(); - add(value: T): Set; - delete(value: T): boolean; - has(value: T): boolean; - forEach(callback: (value: T, value2: T, set: Set) => void, thisArg?: any): void; - } - } -} - - -declare module Plottable { - module Utils { - module DOM { - /** - * Gets the bounding box of an element. - * @param {d3.Selection} element - * @returns {SVGRed} The bounding box. - */ - function elementBBox(element: d3.Selection): SVGRect; - /** - * Screen refresh rate which is assumed to be 60fps - */ - var SCREEN_REFRESH_RATE_MILLISECONDS: number; - /** - * Polyfill for `window.requestAnimationFrame`. - * If the function exists, then we use the function directly. - * Otherwise, we set a timeout on `SCREEN_REFRESH_RATE_MILLISECONDS` and then perform the function. - * - * @param {() => void} callback The callback to call in the next animation frame - */ - function requestAnimationFramePolyfill(callback: () => void): void; - /** - * Calculates the width of the element. - * The width includes the padding and the border on the element's left and right sides. - * - * @param {Element} element The element to query - * @returns {number} The width of the element. - */ - function elementWidth(element: Element): number; - /** - * Calculates the height of the element. - * The height includes the padding the and the border on the element's top and bottom sides. - * - * @param {Element} element The element to query - * @returns {number} The height of the element - */ - function elementHeight(element: Element): number; - /** - * Retrieves the number array representing the translation for the selection - * - * @param {d3.Selection} selection The selection to query - * @returns {[number, number]} The number array representing the translation - */ - function translate(selection: d3.Selection): [number, number]; - /** - * Translates the given selection by the input x / y pixel amounts. - * - * @param {d3.Selection} selection The selection to translate - * @param {number} x The amount to translate in the x direction - * @param {number} y The amount to translate in the y direction - * @returns {d3.Selection} The input selection - */ - function translate(selection: d3.Selection, x: number, y: number): d3.Selection; - /** - * Checks if the first ClientRect overlaps the second. - * - * @param {ClientRect} clientRectA The first ClientRect - * @param {ClientRect} clientRectB The second ClientRect - * @returns {boolean} If the ClientRects overlap each other. - */ - function clientRectsOverlap(clientRectA: ClientRect, clientRectB: ClientRect): boolean; - /** - * Returns true if and only if innerClientRect is inside outerClientRect. - * - * @param {ClientRect} innerClientRect The first ClientRect - * @param {ClientRect} outerClientRect The second ClientRect - * @returns {boolean} If and only if the innerClientRect is inside outerClientRect. - */ - function clientRectInside(innerClientRect: ClientRect, outerClientRect: ClientRect): boolean; - /** - * Retrieves the bounding svg of the input element - * - * @param {SVGElement} element The element to query - * @returns {SVGElement} The bounding svg - */ - function boundingSVG(element: SVGElement): SVGElement; - /** - * Generates a ClipPath ID that is unique for this instance of Plottable - */ - function generateUniqueClipPathId(): string; - /** - * Returns true if the supplied coordinates or Ranges intersect or are contained by bbox. - * - * @param {number | Range} xValOrRange The x coordinate or Range to test - * @param {number | Range} yValOrRange The y coordinate or Range to test - * @param {SVGRect} bbox The bbox - * @param {number} tolerance Amount by which to expand bbox, in each dimension, before - * testing intersection - * - * @returns {boolean} True if the supplied coordinates or Ranges intersect or are - * contained by bbox, false otherwise. - */ - function intersectsBBox(xValOrRange: number | Range, yValOrRange: number | Range, bbox: SVGRect, tolerance?: number): boolean; - } - } -} - - -declare module Plottable { - module Utils { - module Color { - /** - * Return contrast ratio between two colors - * Based on implementation from chroma.js by Gregor Aisch (gka) (licensed under BSD) - * chroma.js may be found here: https://github.com/gka/chroma.js - * License may be found here: https://github.com/gka/chroma.js/blob/master/LICENSE - * see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef - */ - function contrast(a: string, b: string): number; - /** - * Returns a brighter copy of this color. Each channel is multiplied by 0.7 ^ -factor. - * Channel values are capped at the maximum value of 255, and the minimum value of 30. - */ - function lightenColor(color: string, factor: number): string; - /** - * Gets the Hex Code of the color resulting by applying the className CSS class to the - * colorTester selection. Returns null if the tester is transparent. - * - * @param {d3.Selection} colorTester The d3 selection to apply the CSS class to - * @param {string} className The name of the class to be applied - * @return {string} The hex code of the computed color - */ - function colorTest(colorTester: d3.Selection, className: string): string; - } - } -} - - -declare module Plottable { - module Utils { - module Array { - /** - * Takes two arrays of numbers and adds them together - * - * @param {number[]} aList The first array of numbers - * @param {number[]} bList The second array of numbers - * @return {number[]} An array of numbers where x[i] = aList[i] + bList[i] - */ - function add(aList: number[], bList: number[]): number[]; - /** - * Take an array of values, and return the unique values. - * Will work iff ∀ a, b, a.toString() == b.toString() => a == b; will break on Object inputs - * - * @param {T[]} values The values to find uniqueness for - * @return {T[]} The unique values - */ - function uniq(arr: T[]): T[]; - /** - * @param {T[][]} a The 2D array that will have its elements joined together. - * @return {T[]} Every array in a, concatenated together in the order they appear. - */ - function flatten(a: T[][]): T[]; - /** - * Creates an array of length `count`, filled with value or (if value is a function), value() - * - * @param {T | ((index?: number) => T)} value The value to fill the array with or a value generator (called with index as arg) - * @param {number} count The length of the array to generate - * @return {any[]} - */ - function createFilledArray(value: T | ((index?: number) => T), count: number): T[]; - } - } -} - - -declare module Plottable { - module Utils { - /** - * A set of callbacks which can be all invoked at once. - * Each callback exists at most once in the set (based on reference equality). - * All callbacks should have the same signature. - */ - class CallbackSet extends Set { - callCallbacks(...args: any[]): CallbackSet; - } - } -} - - -declare module Plottable { - module Utils { - module Stacking { - type StackedDatum = { - value: number; - offset: number; - }; - type StackingResult = Utils.Map>; - /** - * Computes the StackingResult (value and offset) for each data point in each Dataset. - * - * @param {Dataset[]} datasets The Datasets to be stacked on top of each other in the order of stacking - * @param {Accessor} keyAccessor Accessor for the key of the data - * @param {Accessor} valueAccessor Accessor for the value of the data - * @return {StackingResult} value and offset for each datapoint in each Dataset - */ - function stack(datasets: Dataset[], keyAccessor: Accessor, valueAccessor: Accessor): StackingResult; - /** - * Computes the total extent over all data points in all Datasets, taking stacking into consideration. - * - * @param {StackingResult} stackingResult The value and offset information for each datapoint in each dataset - * @oaram {Accessor} keyAccessor Accessor for the key of the data existent in the stackingResult - * @param {Accessor} filter A filter for data to be considered when computing the total extent - * @return {[number, number]} The total extent - */ - function stackedExtent(stackingResult: StackingResult, keyAccessor: Accessor, filter: Accessor): number[]; - /** - * Normalizes a key used for stacking - * - * @param {any} key The key to be normalized - * @return {string} The stringified key - */ - function normalizeKey(key: any): string; - } - } -} - - -declare module Plottable { - module Utils { - module Window { - /** - * Print a warning message to the console, if it is available. - * - * @param {string} The warnings to print - */ - function warn(warning: string): void; - /** - * Is like setTimeout, but activates synchronously if time=0 - * We special case 0 because of an observed issue where calling setTimeout causes visible flickering. - * We believe this is because when requestAnimationFrame calls into the paint function, as soon as that function finishes - * evaluating, the results are painted to the screen. As a result, if we want something to occur immediately but call setTimeout - * with time=0, then it is pushed to the call stack and rendered in the next frame, so the component that was rendered via - * setTimeout appears out-of-sync with the rest of the plot. - */ - function setTimeout(f: Function, time: number, ...args: any[]): number; - /** - * Sends a deprecation warning to the console. The warning includes the name of the deprecated method, - * version number of the deprecation, and an optional message. - * - * To be used in the first line of a deprecated method. - * - * @param {string} callingMethod The name of the method being deprecated - * @param {string} version The version when the tagged method became obsolete - * @param {string?} message Optional message to be shown with the warning - */ - function deprecated(callingMethod: string, version: string, message?: string): void; - } - } -} - - -declare module Plottable { - module Utils { - class ClientToSVGTranslator { - /** - * Returns the ClientToSVGTranslator for the containing elem. - * If one already exists on that , it will be returned; otherwise, a new one will be created. - */ - static getTranslator(elem: SVGElement): ClientToSVGTranslator; - constructor(svg: SVGElement); - /** - * Computes the position relative to the in svg-coordinate-space. - */ - computePosition(clientX: number, clientY: number): Point; - /** - * Checks whether event happened inside element. - */ - insideSVG(e: Event): boolean; - } - } -} - - -declare module Plottable { - module Configs { - /** - * Specifies if Plottable should show warnings. - */ - var SHOW_WARNINGS: boolean; - /** - * Specifies if Plottable should add elements to text. - */ - var ADD_TITLE_ELEMENTS: boolean; - } -} - - -declare module Plottable { - var version: string; -} - - -declare module Plottable { - type DatasetCallback = (dataset: Dataset) => void; - class Dataset { - /** - * A Dataset contains an array of data and some metadata. - * Changes to the data or metadata will cause anything subscribed to the Dataset to update. - * - * @constructor - * @param {any[]} [data=[]] The data for this Dataset. - * @param {any} [metadata={}] An object containing additional information. - */ - constructor(data?: any[], metadata?: any); - /** - * Adds a callback to be called when the Dataset updates. - * - * @param {DatasetCallback} callback. - * @returns {Dataset} The calling Dataset. - */ - onUpdate(callback: DatasetCallback): Dataset; - /** - * Removes a callback that would be called when the Dataset updates. - * - * @param {DatasetCallback} callback - * @returns {Dataset} The calling Dataset. - */ - offUpdate(callback: DatasetCallback): Dataset; - /** - * Gets the data. - * - * @returns {any[]} - */ - data(): any[]; - /** - * Sets the data. - * - * @param {any[]} data - * @returns {Dataset} The calling Dataset. - */ - data(data: any[]): Dataset; - /** - * Gets the metadata. - * - * @returns {any} - */ - metadata(): any; - /** - * Sets the metadata. - * - * @param {any} metadata - * @returns {Dataset} The calling Dataset. - */ - metadata(metadata: any): Dataset; - } -} - - -declare module Plottable { - module RenderPolicies { - /** - * A policy for rendering Components. - */ - interface RenderPolicy { - render(): any; - } - /** - * Renders Components immediately after they are enqueued. - * Useful for debugging, horrible for performance. - */ - class Immediate implements RenderPolicy { - render(): void; - } - /** - * The default way to render, which only tries to render every frame - * (usually, 1/60th of a second). - */ - class AnimationFrame implements RenderPolicy { - render(): void; - } - /** - * Renders with `setTimeout()`. - * Generally an inferior way to render compared to `requestAnimationFrame`, - * but useful for browsers that don't suppoort `requestAnimationFrame`. - */ - class Timeout implements RenderPolicy { - render(): void; - } - } -} - - -declare module Plottable { - /** - * The RenderController is responsible for enqueueing and synchronizing - * layout and render calls for Components. - * - * Layout and render calls occur inside an animation callback - * (window.requestAnimationFrame if available). - * - * RenderController.flush() immediately lays out and renders all Components currently enqueued. - * - * To always have immediate rendering (useful for debugging), call - * ```typescript - * Plottable.RenderController.setRenderPolicy( - * new Plottable.RenderPolicies.Immediate() - * ); - * ``` - */ - module RenderController { - module Policy { - var IMMEDIATE: string; - var ANIMATION_FRAME: string; - var TIMEOUT: string; - } - function renderPolicy(): RenderPolicies.RenderPolicy; - function renderPolicy(renderPolicy: string): void; - /** - * Enqueues the Component for rendering. - * - * @param {Component} component - */ - function registerToRender(component: Component): void; - /** - * Enqueues the Component for layout and rendering. - * - * @param {Component} component - */ - function registerToComputeLayout(component: Component): void; - /** - * Renders all Components waiting to be rendered immediately - * instead of waiting until the next frame. - * - * Useful to call when debugging. - */ - function flush(): void; - } -} - -declare module Plottable { - /** - * Accesses a specific datum property. - */ - interface Accessor { - (datum: any, index: number, dataset: Dataset): T; - } - /** - * Retrieves a scaled datum property. - * Essentially passes the result of an Accessor through a Scale. - */ - type Projector = (datum: any, index: number, dataset: Dataset) => any; - /** - * A mapping from attributes ("x", "fill", etc.) to the functions that get - * that information out of the data. - */ - type AttributeToProjector = { - [attr: string]: Projector; - }; - /** - * A function that generates attribute values from the datum and index. - * Essentially a Projector with a particular Dataset rolled in. - */ - type AppliedProjector = (datum: any, index: number) => any; - /** - * A mapping from attributes to the AppliedProjectors used to generate them. - */ - type AttributeToAppliedProjector = { - [attr: string]: AppliedProjector; - }; - /** - * Space request used during layout negotiation. - * - * @member {number} minWidth The minimum acceptable width given the offered space. - * @member {number} minHeight the minimum acceptable height given the offered space. - */ - type SpaceRequest = { - minWidth: number; - minHeight: number; - }; - /** - * Min and max values for a particular property. - */ - type Range = { - min: number; - max: number; - }; - /** - * A location in pixel-space. - */ - type Point = { - x: number; - y: number; - }; - /** - * The corners of a box. - */ - type Bounds = { - topLeft: Point; - bottomRight: Point; - }; - /** - * An object representing a data-backed visual entity inside a Component. - */ - interface Entity { - datum: any; - position: Point; - selection: d3.Selection; - component: C; - } -} - - -declare module Plottable { - type Formatter = (d: any) => string; - /** - * This field is deprecated and will be removed in v2.0.0. - * - * The number of milliseconds between midnight one day and the next is - * not a fixed quantity. - * - * Use date.setDate(date.getDate() + number_of_days) instead. - * - */ - var MILLISECONDS_IN_ONE_DAY: number; - module Formatters { - /** - * Creates a formatter for currency values. - * - * @param {number} [precision] The number of decimal places to show (default 2). - * @param {string} [symbol] The currency symbol to use (default "$"). - * @param {boolean} [prefix] Whether to prepend or append the currency symbol (default true). - * - * @returns {Formatter} A formatter for currency values. - */ - function currency(precision?: number, symbol?: string, prefix?: boolean): (d: any) => string; - /** - * Creates a formatter that displays exactly [precision] decimal places. - * - * @param {number} [precision] The number of decimal places to show (default 3). - * - * @returns {Formatter} A formatter that displays exactly [precision] decimal places. - */ - function fixed(precision?: number): (d: any) => string; - /** - * Creates a formatter that formats numbers to show no more than - * [maxNumberOfDecimalPlaces] decimal places. All other values are stringified. - * - * @param {number} [maxNumberOfDecimalPlaces] The number of decimal places to show (default 3). - * - * @returns {Formatter} A formatter for general values. - */ - function general(maxNumberOfDecimalPlaces?: number): (d: any) => string; - /** - * Creates a formatter that stringifies its input. - * - * @returns {Formatter} A formatter that stringifies its input. - */ - function identity(): (d: any) => string; - /** - * Creates a formatter for percentage values. - * Multiplies the input by 100 and appends "%". - * - * @param {number} [precision] The number of decimal places to show (default 0). - * - * @returns {Formatter} A formatter for percentage values. - */ - function percentage(precision?: number): (d: any) => string; - /** - * Creates a formatter for values that displays [numberOfSignificantFigures] significant figures - * and puts SI notation. - * - * @param {number} [numberOfSignificantFigures] The number of significant figures to show (default 3). - * - * @returns {Formatter} A formatter for SI values. - */ - function siSuffix(numberOfSignificantFigures?: number): (d: any) => string; - /** - * Creates a formatter for values that displays abbreviated values - * and uses standard short scale suffixes - * - K - thousands - 10 ^ 3 - * - M - millions - 10 ^ 6 - * - B - billions - 10 ^ 9 - * - T - trillions - 10 ^ 12 - * - Q - quadrillions - 10 ^ 15 - * - * Numbers with a magnitude outside of (10 ^ (-precision), 10 ^ 15) are shown using - * scientific notation to avoid creating extremely long decimal strings. - * - * @param {number} [precision] the number of decimal places to show (default 3) - * @returns {Formatter} A formatter with short scale formatting - */ - function shortScale(precision?: number): (num: number) => string; - /** - * Creates a multi time formatter that displays dates. - * - * @returns {Formatter} A formatter for time/date values. - */ - function multiTime(): (d: any) => string; - /** - * Creates a time formatter that displays time/date using given specifier. - * - * List of directives can be found on: https://github.com/mbostock/d3/wiki/Time-Formatting#format - * - * @param {string} [specifier] The specifier for the formatter. - * - * @returns {Formatter} A formatter for time/date values. - */ - function time(specifier: string): Formatter; - /** - * @deprecated As of release v1.3.0, not safe for use with time zones. - * - * Creates a formatter for relative dates. - * - * @param {number} baseValue The start date (as epoch time) used in computing relative dates (default 0) - * @param {number} increment The unit used in calculating relative date values (default MILLISECONDS_IN_ONE_DAY) - * @param {string} label The label to append to the formatted string (default "") - * - * @returns {Formatter} A formatter for time/date values. - */ - function relativeDate(baseValue?: number, increment?: number, label?: string): (d: any) => string; - } -} - - -declare module Plottable { - /** - * A SymbolFactory is a function that takes in a symbolSize which is the edge length of the render area - * and returns a string representing the 'd' attribute of the resultant 'path' element - */ - type SymbolFactory = (symbolSize: number) => string; - module SymbolFactories { - function circle(): SymbolFactory; - function square(): SymbolFactory; - function cross(): SymbolFactory; - function diamond(): SymbolFactory; - function triangleUp(): SymbolFactory; - function triangleDown(): SymbolFactory; - } -} - - -declare module Plottable { - interface ScaleCallback> { - (scale: S): any; - } - module Scales { - /** - * A function that supplies domain values to be included into a Scale. - * - * @param {Scale} scale - * @returns {D[]} An array of values that should be included in the Scale. - */ - interface IncludedValuesProvider { - (scale: Scale): D[]; - } - /** - * A function that supplies padding exception values for the Scale. - * If one end of the domain is set to an excepted value as a result of autoDomain()-ing, - * that end of the domain will not be padded. - * - * @param {QuantitativeScale} scale - * @returns {D[]} An array of values that should not be padded. - */ - interface PaddingExceptionsProvider { - (scale: QuantitativeScale): D[]; - } - } - class Scale { - /** - * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. - * - * @constructor - */ - constructor(); - /** - * Given an array of potential domain values, computes the extent of those values. - * - * @param {D[]} values - * @returns {D[]} The extent of the input values. - */ - extentOfValues(values: D[]): D[]; - protected _getAllIncludedValues(): D[]; - protected _getExtent(): D[]; - /** - * Adds a callback to be called when the Scale updates. - * - * @param {ScaleCallback} callback. - * @returns {Scale} The calling Scale. - */ - onUpdate(callback: ScaleCallback>): Scale; - /** - * Removes a callback that would be called when the Scale updates. - * - * @param {ScaleCallback} callback. - * @returns {Scale} The calling Scale. - */ - offUpdate(callback: ScaleCallback>): Scale; - protected _dispatchUpdate(): void; - /** - * Sets the Scale's domain so that it spans the Extents of all its ExtentsProviders. - * - * @returns {Scale} The calling Scale. - */ - autoDomain(): Scale; - protected _autoDomainIfAutomaticMode(): void; - /** - * Computes the range value corresponding to a given domain value. - * - * @param {D} value - * @returns {R} The range value corresponding to the supplied domain value. - */ - scale(value: D): R; - /** - * Gets the domain. - * - * @returns {D[]} The current domain. - */ - domain(): D[]; - /** - * Sets the domain. - * - * @param {D[]} values - * @returns {Scale} The calling Scale. - */ - domain(values: D[]): Scale; - protected _getDomain(): void; - protected _setDomain(values: D[]): void; - protected _setBackingScaleDomain(values: D[]): void; - /** - * Gets the range. - * - * @returns {R[]} The current range. - */ - range(): R[]; - /** - * Sets the range. - * - * @param {R[]} values - * @returns {Scale} The calling Scale. - */ - range(values: R[]): Scale; - protected _getRange(): void; - protected _setRange(values: R[]): void; - /** - * Adds an IncludedValuesProvider to the Scale. - * - * @param {Scales.IncludedValuesProvider} provider - * @returns {Scale} The calling Scale. - */ - addIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; - /** - * Removes the IncludedValuesProvider from the Scale. - * - * @param {Scales.IncludedValuesProvider} provider - * @returns {Scale} The calling Scale. - */ - removeIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; - } -} - - -declare module Plottable { - class QuantitativeScale extends Scale { - protected static _DEFAULT_NUM_TICKS: number; - /** - * A QuantitativeScale is a Scale that maps number-like values to numbers. - * It is invertible and continuous. - * - * @constructor - */ - constructor(); - autoDomain(): QuantitativeScale; - protected _autoDomainIfAutomaticMode(): void; - protected _getExtent(): D[]; - /** - * Adds a padding exception provider. - * If one end of the domain is set to an excepted value as a result of autoDomain()-ing, - * that end of the domain will not be padded. - * - * @param {Scales.PaddingExceptionProvider} provider The provider function. - * @returns {QuantitativeScale} The calling QuantitativeScale. - */ - addPaddingExceptionsProvider(provider: Scales.PaddingExceptionsProvider): QuantitativeScale; - /** - * Removes the padding exception provider. - * - * @param {Scales.PaddingExceptionProvider} provider The provider function. - * @returns {QuantitativeScale} The calling QuantitativeScale. - */ - removePaddingExceptionsProvider(provider: Scales.PaddingExceptionsProvider): QuantitativeScale; - /** - * Gets the padding proportion. - */ - padProportion(): number; - /** - * Sets the padding porportion. - * When autoDomain()-ing, the computed domain will be expanded by this proportion, - * then rounded to human-readable values. - * - * @param {number} padProportion The padding proportion. Passing 0 disables padding. - * @returns {QuantitativeScale} The calling QuantitativeScale. - */ - padProportion(padProportion: number): QuantitativeScale; - /** - * Gets whether or not the scale snaps its domain to nice values. - */ - snappingDomainEnabled(): boolean; - /** - * Sets whether or not the scale snaps its domain to nice values. - */ - snappingDomainEnabled(snappingDomainEnabled: boolean): QuantitativeScale; - protected _expandSingleValueDomain(singleValueDomain: D[]): D[]; - /** - * Computes the domain value corresponding to a supplied range value. - * - * @param {number} value: A value from the Scale's range. - * @returns {D} The domain value corresponding to the supplied range value. - */ - invert(value: number): D; - domain(): D[]; - domain(values: D[]): QuantitativeScale; - /** - * Gets the lower end of the domain. - * - * @return {D} - */ - domainMin(): D; - /** - * Sets the lower end of the domain. - * - * @return {QuantitativeScale} The calling QuantitativeScale. - */ - domainMin(domainMin: D): QuantitativeScale; - /** - * Gets the upper end of the domain. - * - * @return {D} - */ - domainMax(): D; - /** - * Sets the upper end of the domain. - * - * @return {QuantitativeScale} The calling QuantitativeScale. - */ - domainMax(domainMax: D): QuantitativeScale; - extentOfValues(values: D[]): D[]; - protected _setDomain(values: D[]): void; - /** - * Gets the array of tick values generated by the default algorithm. - */ - defaultTicks(): D[]; - /** - * Gets an array of tick values spanning the domain. - * - * @returns {D[]} - */ - ticks(): D[]; - /** - * Given a domain, expands its domain onto "nice" values, e.g. whole - * numbers. - */ - protected _niceDomain(domain: D[], count?: number): D[]; - protected _defaultExtent(): D[]; - /** - * Gets the TickGenerator. - */ - tickGenerator(): Scales.TickGenerators.TickGenerator; - /** - * Sets the TickGenerator - * - * @param {TickGenerator} generator - * @return {QuantitativeScale} The calling QuantitativeScale. - */ - tickGenerator(generator: Scales.TickGenerators.TickGenerator): QuantitativeScale; - } -} - - -declare module Plottable { - module Scales { - class Linear extends QuantitativeScale { - /** - * @constructor - */ - constructor(); - protected _defaultExtent(): number[]; - protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; - scale(value: number): number; - protected _getDomain(): number[]; - protected _setBackingScaleDomain(values: number[]): void; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - invert(value: number): number; - defaultTicks(): number[]; - protected _niceDomain(domain: number[], count?: number): number[]; - } - } -} - - -declare module Plottable { - module Scales { - class ModifiedLog extends QuantitativeScale { - /** - * A ModifiedLog Scale acts as a regular log scale for large numbers. - * As it approaches 0, it gradually becomes linear. - * Consequently, a ModifiedLog Scale can process 0 and negative numbers. - * - * @constructor - * @param {number} [base=10] - * The base of the log. Must be > 1. - * - * For x <= base, scale(x) = log(x). - * - * For 0 < x < base, scale(x) will become more and more - * linear as it approaches 0. - * - * At x == 0, scale(x) == 0. - * - * For negative values, scale(-x) = -scale(x). - */ - constructor(base?: number); - scale(x: number): number; - invert(x: number): number; - protected _getDomain(): number[]; - protected _setDomain(values: number[]): void; - protected _setBackingScaleDomain(values: number[]): void; - ticks(): number[]; - protected _niceDomain(domain: number[], count?: number): number[]; - protected _defaultExtent(): number[]; - protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - defaultTicks(): number[]; - } - } -} - - -declare module Plottable { - module Scales { - class Category extends Scale { - /** - * A Category Scale maps strings to numbers. - * - * @constructor - */ - constructor(); - extentOfValues(values: string[]): string[]; - protected _getExtent(): string[]; - domain(): string[]; - domain(values: string[]): Category; - protected _setDomain(values: string[]): void; - range(): [number, number]; - range(values: [number, number]): Category; - /** - * Returns the width of the range band. - * - * @returns {number} The range band width - */ - rangeBand(): number; - /** - * Returns the step width of the scale. - * - * The step width is the pixel distance between adjacent values in the domain. - * - * @returns {number} - */ - stepWidth(): number; - /** - * Gets the inner padding. - * - * The inner padding is defined as the padding in between bands on the scale, - * expressed as a multiple of the rangeBand(). - * - * @returns {number} - */ - innerPadding(): number; - /** - * Sets the inner padding. - * - * The inner padding is defined as the padding in between bands on the scale, - * expressed as a multiple of the rangeBand(). - * - * @returns {Category} The calling Category Scale. - */ - innerPadding(innerPadding: number): Category; - /** - * Gets the outer padding. - * - * The outer padding is the padding in between the outer bands and the edges of the range, - * expressed as a multiple of the rangeBand(). - * - * @returns {number} - */ - outerPadding(): number; - /** - * Sets the outer padding. - * - * The outer padding is the padding in between the outer bands and the edges of the range, - * expressed as a multiple of the rangeBand(). - * - * @returns {Category} The calling Category Scale. - */ - outerPadding(outerPadding: number): Category; - scale(value: string): number; - protected _getDomain(): string[]; - protected _setBackingScaleDomain(values: string[]): void; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - } - } -} - - -declare module Plottable { - module Scales { - class Color extends Scale { - /** - * A Color Scale maps string values to color hex values expressed as a string. - * - * @constructor - * @param {string} [scaleType] One of "Category10"/"Category20"/"Category20b"/"Category20c". - * (see https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors) - * If not supplied, reads the colors defined using CSS -- see plottable.css. - */ - constructor(scaleType?: string); - extentOfValues(values: string[]): string[]; - protected _getExtent(): string[]; - static invalidateColorCache(): void; - /** - * Returns the color-string corresponding to a given string. - * If there are not enough colors in the range(), a lightened version of an existing color will be used. - * - * @param {string} value - * @returns {string} - */ - scale(value: string): string; - protected _getDomain(): string[]; - protected _setBackingScaleDomain(values: string[]): void; - protected _getRange(): string[]; - protected _setRange(values: string[]): void; - } - } -} - - -declare module Plottable { - module Scales { - class Time extends QuantitativeScale { - /** - * A Time Scale maps Date objects to numbers. - * - * @constructor - */ - constructor(); - /** - * Returns an array of ticks values separated by the specified interval. - * - * @param {string} interval A string specifying the interval unit. - * @param {number?} [step] The number of multiples of the interval between consecutive ticks. - * @return {Date[]} - */ - tickInterval(interval: string, step?: number): Date[]; - protected _setDomain(values: Date[]): void; - protected _defaultExtent(): Date[]; - protected _expandSingleValueDomain(singleValueDomain: Date[]): Date[]; - scale(value: Date): number; - protected _getDomain(): Date[]; - protected _setBackingScaleDomain(values: Date[]): void; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - invert(value: number): Date; - defaultTicks(): Date[]; - protected _niceDomain(domain: Date[]): Date[]; - /** - * Transforms the Plottable TimeInterval string into a d3 time interval equivalent. - * If the provided TimeInterval is incorrect, the default is d3.time.year - */ - static timeIntervalToD3Time(timeInterval: string): d3.time.Interval; - } - } -} - - -declare module Plottable { - module Scales { - class InterpolatedColor extends Scale { - static REDS: string[]; - static BLUES: string[]; - static POSNEG: string[]; - /** - * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. - * - * @param {string} [scaleType="linear"] One of "linear"/"log"/"sqrt"/"pow". - */ - constructor(scaleType?: string); - extentOfValues(values: number[]): number[]; - autoDomain(): InterpolatedColor; - scale(value: number): string; - protected _getDomain(): number[]; - protected _setBackingScaleDomain(values: number[]): void; - protected _getRange(): string[]; - protected _setRange(range: string[]): void; - } - } -} - - -declare module Plottable { - module Scales { - module TickGenerators { - /** - * Generates an array of tick values for the specified scale. - * - * @param {QuantitativeScale} scale - * @returns {D[]} - */ - interface TickGenerator { - (scale: Plottable.QuantitativeScale): D[]; - } - /** - * Creates a TickGenerator using the specified interval. - * - * Generates ticks at multiples of the interval while also including the domain boundaries. - * - * @param {number} interval - * @returns {TickGenerator} - */ - function intervalTickGenerator(interval: number): TickGenerator; - /** - * Creates a TickGenerator returns only integer tick values. - * - * @returns {TickGenerator} - */ - function integerTickGenerator(): TickGenerator; - } - } -} - - -declare module Plottable { - module Drawers { - /** - * A step for the drawer to draw. - * - * Specifies how AttributeToProjector needs to be animated. - */ - type DrawStep = { - attrToProjector: AttributeToProjector; - animator: Animator; - }; - /** - * A DrawStep that carries an AttributeToAppliedProjector map. - */ - type AppliedDrawStep = { - attrToAppliedProjector: AttributeToAppliedProjector; - animator: Animator; - }; - } - class Drawer { - protected _svgElementName: string; - protected _className: string; - /** - * A Drawer draws svg elements based on the input Dataset. - * - * @constructor - * @param {Dataset} dataset The dataset associated with this Drawer - */ - constructor(dataset: Dataset); - /** - * Retrieves the renderArea selection for the Drawer. - */ - renderArea(): d3.Selection; - /** - * Sets the renderArea selection for the Drawer. - * - * @param {d3.Selection} Selection containing the to render to. - * @returns {Drawer} The calling Drawer. - */ - renderArea(area: d3.Selection): Drawer; - /** - * Removes the Drawer and its renderArea - */ - remove(): void; - protected _applyDefaultAttributes(selection: d3.Selection): void; - /** - * Calculates the total time it takes to use the input drawSteps to draw the input data - * - * @param {any[]} data The data that would have been drawn - * @param {Drawers.DrawStep[]} drawSteps The DrawSteps to use - * @returns {number} The total time it takes to draw - */ - totalDrawTime(data: any[], drawSteps: Drawers.DrawStep[]): number; - /** - * Draws the data into the renderArea using the spefic steps and metadata - * - * @param{any[]} data The data to be drawn - * @param{DrawStep[]} drawSteps The list of steps, which needs to be drawn - */ - draw(data: any[], drawSteps: Drawers.DrawStep[]): Drawer; - selection(): d3.Selection; - /** - * Returns the CSS selector for this Drawer's visual elements. - */ - selector(): string; - /** - * Returns the D3 selection corresponding to the datum with the specified index. - */ - selectionForIndex(index: number): d3.Selection; - } -} - - -declare module Plottable { - module Drawers { - class Line extends Drawer { - constructor(dataset: Dataset); - protected _applyDefaultAttributes(selection: d3.Selection): void; - selectionForIndex(index: number): d3.Selection; - } - } -} - - -declare module Plottable { - module Drawers { - class Area extends Drawer { - constructor(dataset: Dataset); - protected _applyDefaultAttributes(selection: d3.Selection): void; - selectionForIndex(index: number): d3.Selection; - } - } -} - - -declare module Plottable { - module Drawers { - class Rectangle extends Drawer { - constructor(dataset: Dataset); - } - } -} - - -declare module Plottable { - module Drawers { - class Arc extends Drawer { - constructor(dataset: Dataset); - protected _applyDefaultAttributes(selection: d3.Selection): void; - } - } -} - - -declare module Plottable { - module Drawers { - class ArcOutline extends Drawer { - constructor(dataset: Dataset); - protected _applyDefaultAttributes(selection: d3.Selection): void; - } - } -} - - -declare module Plottable { - module Drawers { - class Symbol extends Drawer { - constructor(dataset: Dataset); - } - } -} - - -declare module Plottable { - module Drawers { - class Segment extends Drawer { - constructor(dataset: Dataset); - } - } -} - - -declare module Plottable { - type ComponentCallback = (component: Component) => void; - module Components { - class Alignment { - static TOP: string; - static BOTTOM: string; - static LEFT: string; - static RIGHT: string; - static CENTER: string; - } - } - class Component { - protected _boundingBox: d3.Selection; - protected _clipPathEnabled: boolean; - protected _isSetup: boolean; - protected _isAnchored: boolean; - constructor(); - /** - * Attaches the Component as a child of a given d3 Selection. - * - * @param {d3.Selection} selection. - * @returns {Component} The calling Component. - */ - anchor(selection: d3.Selection): Component; - /** - * Adds a callback to be called on anchoring the Component to the DOM. - * If the Component is already anchored, the callback is called immediately. - * - * @param {ComponentCallback} callback - * @return {Component} - */ - onAnchor(callback: ComponentCallback): Component; - /** - * Removes a callback that would be called on anchoring the Component to the DOM. - * The callback is identified by reference equality. - * - * @param {ComponentCallback} callback - * @return {Component} - */ - offAnchor(callback: ComponentCallback): Component; - /** - * Creates additional elements as necessary for the Component to function. - * Called during anchor() if the Component's element has not been created yet. - * Override in subclasses to provide additional functionality. - */ - protected _setup(): void; - /** - * Given available space in pixels, returns the minimum width and height this Component will need. - * - * @param {number} availableWidth - * @param {number} availableHeight - * @returns {SpaceRequest} - */ - requestedSpace(availableWidth: number, availableHeight: number): SpaceRequest; - /** - * Computes and sets the size, position, and alignment of the Component from the specified values. - * If no parameters are supplied and the Component is a root node, - * they are inferred from the size of the Component's element. - * - * @param {Point} [origin] Origin of the space offered to the Component. - * @param {number} [availableWidth] Available width in pixels. - * @param {number} [availableHeight] Available height in pixels. - * @returns {Component} The calling Component. - */ - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Component; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - /** - * Queues the Component for rendering. - * - * @returns {Component} The calling Component. - */ - render(): Component; - /** - * Renders the Component without waiting for the next frame. - */ - renderImmediately(): Component; - /** - * Causes the Component to re-layout and render. - * - * This function should be called when a CSS change has occured that could - * influence the layout of the Component, such as changing the font size. - * - * @returns {Component} The calling Component. - */ - redraw(): Component; - /** - * Renders the Component to a given . - * - * @param {String|d3.Selection} element A selector-string for the , or a d3 selection containing an . - * @returns {Component} The calling Component. - */ - renderTo(element: String | Element | d3.Selection): Component; - /** - * Gets the x alignment of the Component. - */ - xAlignment(): string; - /** - * Sets the x alignment of the Component. - * - * @param {string} xAlignment The x alignment of the Component ("left"/"center"/"right"). - * @returns {Component} The calling Component. - */ - xAlignment(xAlignment: string): Component; - /** - * Gets the y alignment of the Component. - */ - yAlignment(): string; - /** - * Sets the y alignment of the Component. - * - * @param {string} yAlignment The y alignment of the Component ("top"/"center"/"bottom"). - * @returns {Component} The calling Component. - */ - yAlignment(yAlignment: string): Component; - /** - * Checks if the Component has a given CSS class. - * - * @param {string} cssClass The CSS class to check for. - */ - hasClass(cssClass: string): boolean; - /** - * Adds a given CSS class to the Component. - * - * @param {string} cssClass The CSS class to add. - * @returns {Component} The calling Component. - */ - addClass(cssClass: string): Component; - /** - * Removes a given CSS class from the Component. - * - * @param {string} cssClass The CSS class to remove. - * @returns {Component} The calling Component. - */ - removeClass(cssClass: string): Component; - /** - * Checks if the Component has a fixed width or if it grows to fill available space. - * Returns false by default on the base Component class. - */ - fixedWidth(): boolean; - /** - * Checks if the Component has a fixed height or if it grows to fill available space. - * Returns false by default on the base Component class. - */ - fixedHeight(): boolean; - /** - * Detaches a Component from the DOM. The Component can be reused. - * - * This should only be used if you plan on reusing the calling Component. Otherwise, use destroy(). - * - * @returns The calling Component. - */ - detach(): Component; - /** - * Adds a callback to be called when the Component is detach()-ed. - * - * @param {ComponentCallback} callback - * @return {Component} The calling Component. - */ - onDetach(callback: ComponentCallback): Component; - /** - * Removes a callback to be called when the Component is detach()-ed. - * The callback is identified by reference equality. - * - * @param {ComponentCallback} callback - * @return {Component} The calling Component. - */ - offDetach(callback: ComponentCallback): Component; - /** - * Gets the parent ComponentContainer for this Component. - */ - parent(): ComponentContainer; - /** - * Sets the parent ComponentContainer for this Component. - * An error will be thrown if the parent does not contain this Component. - * Adding a Component to a ComponentContainer should be done - * using the appropriate method on the ComponentContainer. - */ - parent(parent: ComponentContainer): Component; - /** - * Removes a Component from the DOM and disconnects all listeners. - */ - destroy(): void; - /** - * Gets the width of the Component in pixels. - */ - width(): number; - /** - * Gets the height of the Component in pixels. - */ - height(): number; - /** - * Gets the origin of the Component relative to its parent. - * - * @return {Point} - */ - origin(): Point; - /** - * Gets the origin of the Component relative to the root . - * - * @return {Point} - */ - originToSVG(): Point; - /** - * Gets the Selection containing the in front of the visual elements of the Component. - * - * Will return undefined if the Component has not been anchored. - * - * @return {d3.Selection} - */ - foreground(): d3.Selection; - /** - * Gets a Selection containing a that holds the visual elements of the Component. - * - * Will return undefined if the Component has not been anchored. - * - * @return {d3.Selection} content selection for the Component - */ - content(): d3.Selection; - /** - * Gets the Selection containing the behind the visual elements of the Component. - * - * Will return undefined if the Component has not been anchored. - * - * @return {d3.Selection} background selection for the Component - */ - background(): d3.Selection; - } -} - - -declare module Plottable { - class ComponentContainer extends Component { - constructor(); - anchor(selection: d3.Selection): ComponentContainer; - render(): ComponentContainer; - /** - * Checks whether the specified Component is in the ComponentContainer. - */ - has(component: Component): boolean; - protected _adoptAndAnchor(component: Component): void; - /** - * Removes the specified Component from the ComponentContainer. - */ - remove(component: Component): ComponentContainer; - /** - * Carry out the actual removal of a Component. - * Implementation dependent on the type of container. - * - * @return {boolean} true if the Component was successfully removed, false otherwise. - */ - protected _remove(component: Component): boolean; - /** - * Invokes a callback on each Component in the ComponentContainer. - */ - protected _forEach(callback: (component: Component) => void): void; - /** - * Destroys the ComponentContainer and all Components within it. - */ - destroy(): void; - } -} - - -declare module Plottable { - module Components { - class Group extends ComponentContainer { - /** - * Constructs a Group. - * - * A Group contains Components that will be rendered on top of each other. - * Components added later will be rendered above Components already in the Group. - * - * @constructor - * @param {Component[]} [components=[]] Components to be added to the Group. - */ - constructor(components?: Component[]); - protected _forEach(callback: (component: Component) => any): void; - /** - * Checks whether the specified Component is in the Group. - */ - has(component: Component): boolean; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Group; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - fixedWidth(): boolean; - fixedHeight(): boolean; - /** - * @return {Component[]} The Components in this Group. - */ - components(): Component[]; - /** - * Adds a Component to this Group. - * The added Component will be rendered above Components already in the Group. - */ - append(component: Component): Group; - protected _remove(component: Component): boolean; - } - } -} - - -declare module Plottable { - class Axis extends Component { - /** - * The css class applied to each end tick mark (the line on the end tick). - */ - static END_TICK_MARK_CLASS: string; - /** - * The css class applied to each tick mark (the line on the tick). - */ - static TICK_MARK_CLASS: string; - /** - * The css class applied to each tick label (the text associated with the tick). - */ - static TICK_LABEL_CLASS: string; - /** - * The css class applied to each annotation line, which extends from the axis to the rect. - */ - static ANNOTATION_LINE_CLASS: string; - /** - * The css class applied to each annotation rect, which surrounds the annotation label. - */ - static ANNOTATION_RECT_CLASS: string; - /** - * The css class applied to each annotation circle, which denotes which tick is being annotated. - */ - static ANNOTATION_CIRCLE_CLASS: string; - /** - * The css class applied to each annotation label, which shows the formatted annotation text. - */ - static ANNOTATION_LABEL_CLASS: string; - protected _tickMarkContainer: d3.Selection; - protected _tickLabelContainer: d3.Selection; - protected _baseline: d3.Selection; - protected _scale: Scale; - protected _computedWidth: number; - protected _computedHeight: number; - /** - * Constructs an Axis. - * An Axis is a visual representation of a Scale. - * - * @constructor - * @param {Scale} scale - * @param {string} orientation One of "top"/"bottom"/"left"/"right". - */ - constructor(scale: Scale, orientation: string); - destroy(): void; - protected _isHorizontal(): boolean; - protected _computeWidth(): number; - protected _computeHeight(): number; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - fixedHeight(): boolean; - fixedWidth(): boolean; - protected _rescale(): void; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; - protected _setup(): void; - protected _getTickValues(): D[]; - renderImmediately(): Axis; - /** - * Gets the annotated ticks. - */ - annotatedTicks(): D[]; - /** - * Sets the annotated ticks. - * - * @returns {Axis} The calling Axis. - */ - annotatedTicks(annotatedTicks: D[]): Axis; - /** - * Gets the Formatter for the annotations. - */ - annotationFormatter(): Formatter; - /** - * Sets the Formatter for the annotations. - * - * @returns {Axis} The calling Axis. - */ - annotationFormatter(annotationFormatter: Formatter): Axis; - /** - * Gets if annotations are enabled. - */ - annotationsEnabled(): boolean; - /** - * Sets if annotations are enabled. - * - * @returns {Axis} The calling Axis. - */ - annotationsEnabled(annotationsEnabled: boolean): Axis; - /** - * Gets the count of annotation tiers to render. - */ - annotationTierCount(): number; - /** - * Sets the count of annotation tiers to render. - * - * @returns {Axis} The calling Axis. - */ - annotationTierCount(annotationTierCount: number): Axis; - protected _drawAnnotations(): void; - /** - * Retrieves the size of the core pieces. - * - * The core pieces include the labels, the end tick marks, the inner tick marks, and the tick label padding. - */ - protected _coreSize(): number; - protected _annotationTierHeight(): number; - protected _removeAnnotations(): void; - protected _generateBaselineAttrHash(): { - [key: string]: number; - }; - protected _generateTickMarkAttrHash(isEndTickMark?: boolean): { - [key: string]: number | ((d: any) => number); - }; - redraw(): Component; - protected _setDefaultAlignment(): void; - /** - * Gets the Formatter on the Axis. Tick values are passed through the - * Formatter before being displayed. - */ - formatter(): Formatter; - /** - * Sets the Formatter on the Axis. Tick values are passed through the - * Formatter before being displayed. - * - * @param {Formatter} formatter - * @returns {Axis} The calling Axis. - */ - formatter(formatter: Formatter): Axis; - /** - * @deprecated As of release v1.3.0, replaced by innerTickLength() - * - * Gets the tick mark length in pixels. - */ - tickLength(): number; - /** - * Sets the tick mark length in pixels. - * - * @param {number} length - * @returns {Axis} The calling Axis. - */ - tickLength(length: number): Axis; - /** - * Gets the tick mark length in pixels. - */ - innerTickLength(): number; - /** - * Sets the tick mark length in pixels. - * - * @param {number} length - * @returns {Axis} The calling Axis. - */ - innerTickLength(length: number): Axis; - /** - * Gets the end tick mark length in pixels. - */ - endTickLength(): number; - /** - * Sets the end tick mark length in pixels. - * - * @param {number} length - * @returns {Axis} The calling Axis. - */ - endTickLength(length: number): Axis; - protected _maxLabelTickLength(): number; - /** - * Gets the padding between each tick mark and its associated label in pixels. - */ - tickLabelPadding(): number; - /** - * Sets the padding between each tick mark and its associated label in pixels. - * - * @param {number} padding - * @returns {Axis} The calling Axis. - */ - tickLabelPadding(padding: number): Axis; - /** - * Gets the margin in pixels. - * The margin is the amount of space between the tick labels and the outer edge of the Axis. - * The margin also determines the space that annotations will reside in if annotations are enabled. - */ - margin(): number; - /** - * Sets the margin in pixels. - * The margin is the amount of space between the tick labels and the outer edge of the Axis. - * The margin also determines the space that annotations will reside in if annotations are enabled. - * - * @param {number} size - * @returns {Axis} The calling Axis. - */ - margin(size: number): Axis; - /** - * Gets the orientation of the Axis. - */ - orientation(): string; - /** - * Sets the orientation of the Axis. - * - * @param {number} orientation One of "top"/"bottom"/"left"/"right". - * @returns {Axis} The calling Axis. - */ - orientation(orientation: string): Axis; - /** - * Gets whether the Axis shows the end tick labels. - */ - showEndTickLabels(): boolean; - /** - * Sets whether the Axis shows the end tick labels. - * - * @param {boolean} show - * @returns {Axis} The calling Axis. - */ - showEndTickLabels(show: boolean): Axis; - } -} - - -declare module Plottable { - module TimeInterval { - var second: string; - var minute: string; - var hour: string; - var day: string; - var week: string; - var month: string; - var year: string; - } - module Axes { - /** - * Defines a configuration for a Time Axis tier. - * For details on how ticks are generated see: https://github.com/mbostock/d3/wiki/Time-Scales#ticks - * interval - A time unit associated with this configuration (seconds, minutes, hours, etc). - * step - number of intervals between each tick. - * formatter - formatter used to format tick labels. - */ - type TimeAxisTierConfiguration = { - interval: string; - step: number; - formatter: Formatter; - }; - /** - * An array of linked TimeAxisTierConfigurations. - * Each configuration will be shown on a different tier. - * Currently, up to two tiers are supported. - */ - type TimeAxisConfiguration = TimeAxisTierConfiguration[]; - class Time extends Axis { - /** - * The CSS class applied to each Time Axis tier - */ - static TIME_AXIS_TIER_CLASS: string; - /** - * Constructs a Time Axis. - * - * A Time Axis is a visual representation of a Time Scale. - * - * @constructor - * @param {Scales.Time} scale - * @param {string} orientation One of "top"/"bottom". - */ - constructor(scale: Scales.Time, orientation: string); - /** - * Gets the label positions for each tier. - */ - tierLabelPositions(): string[]; - /** - * Sets the label positions for each tier. - * - * @param {string[]} newPositions The positions for each tier. "bottom" and "center" are the only supported values. - * @returns {Axes.Time} The calling Time Axis. - */ - tierLabelPositions(newPositions: string[]): Time; - /** - * Gets the possible TimeAxisConfigurations. - */ - axisConfigurations(): TimeAxisConfiguration[]; - /** - * Sets the possible TimeAxisConfigurations. - * The Time Axis will choose the most precise configuration that will display in the available space. - * - * @param {TimeAxisConfiguration[]} configurations - * @returns {Axes.Time} The calling Time Axis. - */ - axisConfigurations(configurations: TimeAxisConfiguration[]): Time; - orientation(): string; - orientation(orientation: string): Time; - protected _computeHeight(): number; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - protected _setup(): void; - protected _getTickValues(): any[]; - renderImmediately(): Time; - } - } -} - - -declare module Plottable { - module Axes { - class Numeric extends Axis { - /** - * Constructs a Numeric Axis. - * - * A Numeric Axis is a visual representation of a QuantitativeScale. - * - * @constructor - * @param {QuantitativeScale} scale - * @param {string} orientation One of "top"/"bottom"/"left"/"right". - */ - constructor(scale: QuantitativeScale, orientation: string); - protected _setup(): void; - protected _computeWidth(): number; - protected _computeHeight(): number; - protected _getTickValues(): number[]; - protected _rescale(): void; - renderImmediately(): Numeric; - /** - * Gets the tick label position relative to the tick marks. - * - * @returns {string} The current tick label position. - */ - tickLabelPosition(): string; - /** - * Sets the tick label position relative to the tick marks. - * - * @param {string} position "top"/"center"/"bottom" for a vertical Numeric Axis, - * "left"/"center"/"right" for a horizontal Numeric Axis. - * @returns {Numeric} The calling Numeric Axis. - */ - tickLabelPosition(position: string): Numeric; - /** - * Gets the approximate text width setting. - * - * @returns {boolean} The current text width approximation setting. - */ - usesTextWidthApproximation(): boolean; - /** - * Sets the approximate text width setting. Approximating text width - * measurements can drastically speed up plot rendering, but the plot may - * have extra white space that would be eliminated by exact measurements. - * Additionally, very abnormal fonts may not approximate reasonably. - * - * @param {boolean} The new text width approximation setting. - * @returns {Axes.Numeric} The calling Axes.Numeric. - */ - usesTextWidthApproximation(enable: boolean): Axes.Numeric; - } - } -} - - -declare module Plottable { - module Axes { - class Category extends Axis { - /** - * Constructs a Category Axis. - * - * A Category Axis is a visual representation of a Category Scale. - * - * @constructor - * @param {Scales.Category} scale - * @param {string} [orientation="bottom"] One of "top"/"bottom"/"left"/"right". - */ - constructor(scale: Scales.Category, orientation: string); - protected _setup(): void; - protected _rescale(): Component; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - protected _coreSize(): number; - protected _getTickValues(): string[]; - /** - * Gets the tick label angle in degrees. - */ - tickLabelAngle(): number; - /** - * Sets the tick label angle in degrees. - * Right now only -90/0/90 are supported. 0 is horizontal. - * - * @param {number} angle - * @returns {Category} The calling Category Axis. - */ - tickLabelAngle(angle: number): Category; - renderImmediately(): Category; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; - } - } -} - - -declare module Plottable { - module Components { - class Label extends Component { - /** - * A Label is a Component that displays a single line of text. - * - * @constructor - * @param {string} [displayText=""] The text of the Label. - * @param {number} [angle=0] The angle of the Label in degrees (-90/0/90). 0 is horizontal. - */ - constructor(displayText?: string, angle?: number); - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - protected _setup(): void; - /** - * Gets the Label's text. - */ - text(): string; - /** - * Sets the Label's text. - * - * @param {string} displayText - * @returns {Label} The calling Label. - */ - text(displayText: string): Label; - /** - * Gets the angle of the Label in degrees. - */ - angle(): number; - /** - * Sets the angle of the Label in degrees. - * - * @param {number} angle One of -90/0/90. 0 is horizontal. - * @returns {Label} The calling Label. - */ - angle(angle: number): Label; - /** - * Gets the amount of padding around the Label in pixels. - */ - padding(): number; - /** - * Sets the amount of padding around the Label in pixels. - * - * @param {number} padAmount - * @returns {Label} The calling Label. - */ - padding(padAmount: number): Label; - fixedWidth(): boolean; - fixedHeight(): boolean; - renderImmediately(): Label; - } - class TitleLabel extends Label { - static TITLE_LABEL_CLASS: string; - /** - * @constructor - * @param {string} [text] - * @param {number} [angle] One of -90/0/90. 0 is horizontal. - */ - constructor(text?: string, angle?: number); - } - class AxisLabel extends Label { - static AXIS_LABEL_CLASS: string; - /** - * @constructor - * @param {string} [text] - * @param {number} [angle] One of -90/0/90. 0 is horizontal. - */ - constructor(text?: string, angle?: number); - } - } -} - - -declare module Plottable { - module Components { - class Legend extends Component { - /** - * The css class applied to each legend row - */ - static LEGEND_ROW_CLASS: string; - /** - * The css class applied to each legend entry - */ - static LEGEND_ENTRY_CLASS: string; - /** - * The css class applied to each legend symbol - */ - static LEGEND_SYMBOL_CLASS: string; - /** - * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. - * - * @constructor - * @param {Scale.Color} scale - */ - constructor(colorScale: Scales.Color); - protected _setup(): void; - /** - * Gets the Formatter for the entry texts. - */ - formatter(): Formatter; - /** - * Sets the Formatter for the entry texts. - * - * @param {Formatter} formatter - * @returns {Legend} The calling Legend. - */ - formatter(formatter: Formatter): Legend; - /** - * Gets the maximum number of entries per row. - * - * @returns {number} - */ - maxEntriesPerRow(): number; - /** - * Sets the maximum number of entries perrow. - * - * @param {number} maxEntriesPerRow - * @returns {Legend} The calling Legend. - */ - maxEntriesPerRow(maxEntriesPerRow: number): Legend; - /** - * Gets the current comparator for the Legend's entries. - * - * @returns {(a: string, b: string) => number} - */ - comparator(): (a: string, b: string) => number; - /** - * Sets a new comparator for the Legend's entries. - * The comparator is used to set the display order of the entries. - * - * @param {(a: string, b: string) => number} comparator - * @returns {Legend} The calling Legend. - */ - comparator(comparator: (a: string, b: string) => number): Legend; - /** - * Gets the Color Scale. - * - * @returns {Scales.Color} - */ - colorScale(): Scales.Color; - /** - * Sets the Color Scale. - * - * @param {Scales.Color} scale - * @returns {Legend} The calling Legend. - */ - colorScale(colorScale: Scales.Color): Legend; - destroy(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - /** - * Gets the Entities (representing Legend entries) at a particular point. - * Returns an empty array if no Entities are present at that location. - * - * @param {Point} p - * @returns {Entity[]} - */ - entitiesAt(p: Point): Entity[]; - renderImmediately(): Legend; - /** - * Gets the function determining the symbols of the Legend. - * - * @returns {(datum: any, index: number) => symbolFactory} - */ - symbol(): (datum: any, index: number) => SymbolFactory; - /** - * Sets the function determining the symbols of the Legend. - * - * @param {(datum: any, index: number) => SymbolFactory} symbol - * @returns {Legend} The calling Legend - */ - symbol(symbol: (datum: any, index: number) => SymbolFactory): Legend; - /** - * Gets the opacity of the symbols of the Legend. - * - * @returns {(datum: any, index: number) => number} - */ - symbolOpacity(): (datum: any, index: number) => number; - /** - * Sets the opacity of the symbols of the Legend. - * - * @param {number | ((datum: any, index: number) => number)} symbolOpacity - * @returns {Legend} The calling Legend - */ - symbolOpacity(symbolOpacity: number | ((datum: any, index: number) => number)): Legend; - fixedWidth(): boolean; - fixedHeight(): boolean; - } - } -} - - -declare module Plottable { - module Components { - class InterpolatedColorLegend extends Component { - /** - * The css class applied to the legend labels. - */ - static LEGEND_LABEL_CLASS: string; - /** - * Creates an InterpolatedColorLegend. - * - * The InterpolatedColorLegend consists of a sequence of swatches that show the - * associated InterpolatedColor Scale sampled at various points. - * Two labels show the maximum and minimum values of the InterpolatedColor Scale. - * - * @constructor - * @param {Scales.InterpolatedColor} interpolatedColorScale - */ - constructor(interpolatedColorScale: Scales.InterpolatedColor); - destroy(): void; - /** - * Gets the Formatter for the labels. - */ - formatter(): Formatter; - /** - * Sets the Formatter for the labels. - * - * @param {Formatter} formatter - * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. - */ - formatter(formatter: Formatter): InterpolatedColorLegend; - /** - * Gets whether the InterpolatedColorLegend expands to occupy all offered space in the long direction - */ - expands(): boolean; - /** - * Sets whether the InterpolatedColorLegend expands to occupy all offered space in the long direction - * - * @param {expands} boolean - * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. - */ - expands(expands: boolean): InterpolatedColorLegend; - /** - * Gets the orientation. - */ - orientation(): string; - /** - * Sets the orientation. - * - * @param {string} orientation One of "horizontal"/"left"/"right". - * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. - */ - orientation(orientation: string): InterpolatedColorLegend; - fixedWidth(): boolean; - fixedHeight(): boolean; - protected _setup(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - renderImmediately(): InterpolatedColorLegend; - } - } -} - - -declare module Plottable { - module Components { - class Gridlines extends Component { - /** - * @constructor - * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. - * @param {QuantitativeScale} yScale The scale to base the y gridlines on. Pass null if no gridlines are desired. - */ - constructor(xScale: QuantitativeScale, yScale: QuantitativeScale); - destroy(): Gridlines; - protected _setup(): void; - renderImmediately(): Gridlines; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; - } - } -} - - -declare module Plottable { - module Components { - class Table extends ComponentContainer { - /** - * A Table combines Components in the form of a grid. A - * common case is combining a y-axis, x-axis, and the plotted data via - * ```typescript - * new Table([[yAxis, plot], - * [null, xAxis]]); - * ``` - * - * @constructor - * @param {Component[][]} [rows=[]] A 2-D array of Components to be added to the Table. - * null can be used if a cell is empty. - */ - constructor(rows?: Component[][]); - protected _forEach(callback: (component: Component) => any): void; - /** - * Checks whether the specified Component is in the Table. - */ - has(component: Component): boolean; - /** - * Adds a Component in the specified row and column position. - * - * For example, instead of calling `new Table([[a, b], [null, c]])`, you - * could call - * var table = new Plottable.Components.Table(); - * table.add(a, 0, 0); - * table.add(b, 0, 1); - * table.add(c, 1, 1); - * - * @param {Component} component The Component to be added. - * @param {number} row - * @param {number} col - * @returns {Table} The calling Table. - */ - add(component: Component, row: number, col: number): Table; - protected _remove(component: Component): boolean; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; - /** - * Gets the padding above and below each row in pixels. - */ - rowPadding(): number; - /** - * Sets the padding above and below each row in pixels. - * - * @param {number} rowPadding - * @returns {Table} The calling Table. - */ - rowPadding(rowPadding: number): Table; - /** - * Gets the padding to the left and right of each column in pixels. - */ - columnPadding(): number; - /** - * Sets the padding to the left and right of each column in pixels. - * - * @param {number} columnPadding - * @returns {Table} The calling Table. - */ - columnPadding(columnPadding: number): Table; - /** - * Gets the weight of the specified row. - * - * @param {number} index - */ - rowWeight(index: number): number; - /** - * Sets the weight of the specified row. - * Space is allocated to rows based on their weight. Rows with higher weights receive proportionally more space. - * - * A common case would be to have one row take up 2/3rds of the space, - * and the other row take up 1/3rd. - * - * Example: - * - * ```JavaScript - * plot = new Plottable.Component.Table([ - * [row1], - * [row2] - * ]); - * - * // assign twice as much space to the first row - * plot - * .rowWeight(0, 2) - * .rowWeight(1, 1) - * ``` - * - * @param {number} index - * @param {number} weight - * @returns {Table} The calling Table. - */ - rowWeight(index: number, weight: number): Table; - /** - * Gets the weight of the specified column. - * - * @param {number} index - */ - columnWeight(index: number): number; - /** - * Sets the weight of the specified column. - * Space is allocated to columns based on their weight. Columns with higher weights receive proportionally more space. - * - * Please see `rowWeight` docs for an example. - * - * @param {number} index - * @param {number} weight - * @returns {Table} The calling Table. - */ - columnWeight(index: number, weight: number): Table; - fixedWidth(): boolean; - fixedHeight(): boolean; - } - } -} - - -declare module Plottable { - module Components { - enum PropertyMode { - VALUE = 0, - PIXEL = 1, - } - class SelectionBoxLayer extends Component { - protected _box: d3.Selection; - protected _xBoundsMode: PropertyMode; - protected _yBoundsMode: PropertyMode; - constructor(); - protected _setup(): void; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - /** - * Gets the Bounds of the box. - */ - bounds(): Bounds; - /** - * Sets the Bounds of the box. - * - * @param {Bounds} newBounds - * @return {SelectionBoxLayer} The calling SelectionBoxLayer. - */ - bounds(newBounds: Bounds): SelectionBoxLayer; - protected _setBounds(newBounds: Bounds): void; - renderImmediately(): SelectionBoxLayer; - /** - * Gets whether the box is being shown. - */ - boxVisible(): boolean; - /** - * Shows or hides the selection box. - * - * @param {boolean} show Whether or not to show the box. - * @return {SelectionBoxLayer} The calling SelectionBoxLayer. - */ - boxVisible(show: boolean): SelectionBoxLayer; - fixedWidth(): boolean; - fixedHeight(): boolean; - /** - * Gets the x scale for this SelectionBoxLayer. - */ - xScale(): QuantitativeScale; - /** - * Sets the x scale for this SelectionBoxLayer. - * - * @returns {SelectionBoxLayer} The calling SelectionBoxLayer. - */ - xScale(xScale: QuantitativeScale): SelectionBoxLayer; - /** - * Gets the y scale for this SelectionBoxLayer. - */ - yScale(): QuantitativeScale; - /** - * Sets the y scale for this SelectionBoxLayer. - * - * @returns {SelectionBoxLayer} The calling SelectionBoxLayer. - */ - yScale(yScale: QuantitativeScale): SelectionBoxLayer; - /** - * Gets the data values backing the left and right edges of the box. - * - * Returns an undefined array if the edges are not backed by a scale. - */ - xExtent(): (number | { - valueOf(): number; - })[]; - /** - * Sets the data values backing the left and right edges of the box. - */ - xExtent(xExtent: (number | { - valueOf(): number; - })[]): SelectionBoxLayer; - protected _setXExtent(xExtent: (number | { - valueOf(): number; - })[]): void; - /** - * Gets the data values backing the top and bottom edges of the box. - * - * Returns an undefined array if the edges are not backed by a scale. - */ - yExtent(): (number | { - valueOf(): number; - })[]; - /** - * Sets the data values backing the top and bottom edges of the box. - */ - yExtent(yExtent: (number | { - valueOf(): number; - })[]): SelectionBoxLayer; - protected _setYExtent(yExtent: (number | { - valueOf(): number; - })[]): void; - destroy(): void; - } - } -} - - -declare module Plottable { - module Components { - class GuideLineLayer extends Component { - static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; - constructor(orientation: string); - protected _setup(): void; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - protected _isVertical(): boolean; - fixedWidth(): boolean; - fixedHeight(): boolean; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): GuideLineLayer; - renderImmediately(): GuideLineLayer; - protected _setPixelPositionWithoutChangingMode(pixelPosition: number): void; - /** - * Gets the QuantitativeScale on the GuideLineLayer. - * - * @return {QuantitativeScale} - */ - scale(): QuantitativeScale; - /** - * Sets the QuantitativeScale on the GuideLineLayer. - * If value() was the last property set, pixelPosition() will be updated according to the new scale. - * If pixelPosition() was the last property set, value() will be updated according to the new scale. - * - * @param {QuantitativeScale} scale - * @return {GuideLineLayer} The calling GuideLineLayer. - */ - scale(scale: QuantitativeScale): GuideLineLayer; - /** - * Gets the value of the guide line in data-space. - * - * @return {D} - */ - value(): D; - /** - * Sets the value of the guide line in data-space. - * If the GuideLineLayer has a scale, pixelPosition() will be updated now and whenever the scale updates. - * - * @param {D} value - * @return {GuideLineLayer} The calling GuideLineLayer. - */ - value(value: D): GuideLineLayer; - /** - * Gets the position of the guide line in pixel-space. - * - * @return {number} - */ - pixelPosition(): number; - /** - * Sets the position of the guide line in pixel-space. - * If the GuideLineLayer has a scale, the value() will be updated now and whenever the scale updates. - * - * @param {number} pixelPosition - * @return {GuideLineLayer} The calling GuideLineLayer. - */ - pixelPosition(pixelPosition: number): GuideLineLayer; - destroy(): void; - } - } -} - - -declare module Plottable { - module Plots { - interface PlotEntity extends Entity { - dataset: Dataset; - index: number; - component: Plot; - } - interface AccessorScaleBinding { - accessor: Accessor; - scale?: Scale; - } - module Animator { - var MAIN: string; - var RESET: string; - } - } - class Plot extends Component { - protected static _ANIMATION_MAX_DURATION: number; - protected _renderArea: d3.Selection; - protected _renderCallback: ScaleCallback>; - protected _propertyExtents: d3.Map; - protected _propertyBindings: d3.Map>; - /** - * A Plot draws some visualization of the inputted Datasets. - * - * @constructor - */ - constructor(); - anchor(selection: d3.Selection): Plot; - protected _setup(): void; - destroy(): void; - protected _createNodesForDataset(dataset: Dataset): Drawer; - protected _createDrawer(dataset: Dataset): Drawer; - protected _getAnimator(key: string): Animator; - protected _onDatasetUpdate(): void; - /** - * Gets the AccessorScaleBinding for a particular attribute. - * - * @param {string} attr - */ - attr(attr: string): Plots.AccessorScaleBinding; - /** - * Sets a particular attribute to a constant value or the result of an Accessor. - * - * @param {string} attr - * @param {number|string|Accessor|Accessor} attrValue - * @returns {Plot} The calling Plot. - */ - attr(attr: string, attrValue: number | string | Accessor | Accessor): Plot; - /** - * Sets a particular attribute to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the attribute values when autoDomain()-ing. - * - * @param {string} attr - * @param {A|Accessor} attrValue - * @param {Scale} scale The Scale used to scale the attrValue. - * @returns {Plot} The calling Plot. - */ - attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; - protected _bindProperty(property: string, value: any, scale: Scale): void; - protected _generateAttrToProjector(): AttributeToProjector; - renderImmediately(): Plot; - /** - * Returns whether the plot will be animated. - */ - animated(): boolean; - /** - * Enables or disables animation. - */ - animated(willAnimate: boolean): Plot; - detach(): Plot; - /** - * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. - */ - protected _updateExtents(): void; - protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): Accessor; - /** - * Override in subclass to add special extents, such as included values - */ - protected _extentsForProperty(property: string): any[]; - /** - * Get the Animator associated with the specified Animator key. - * - * @return {Animator} - */ - animator(animatorKey: string): Animator; - /** - * Set the Animator associated with the specified Animator key. - * - * @param {string} animatorKey - * @param {Animator} animator - * @returns {Plot} The calling Plot. - */ - animator(animatorKey: string, animator: Animator): Plot; - /** - * Adds a Dataset to the Plot. - * - * @param {Dataset} dataset - * @returns {Plot} The calling Plot. - */ - addDataset(dataset: Dataset): Plot; - protected _addDataset(dataset: Dataset): Plot; - /** - * Removes a Dataset from the Plot. - * - * @param {Dataset} dataset - * @returns {Plot} The calling Plot. - */ - removeDataset(dataset: Dataset): Plot; - protected _removeDataset(dataset: Dataset): Plot; - protected _removeDatasetNodes(dataset: Dataset): void; - datasets(): Dataset[]; - datasets(datasets: Dataset[]): Plot; - protected _getDrawersInOrder(): Drawer[]; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _additionalPaint(time: number): void; - protected _getDataToDraw(): Utils.Map; - /** - * Retrieves Selections of this Plot for the specified Datasets. - * - * @param {Dataset[]} [datasets] The Datasets to retrieve the Selections for. - * If not provided, Selections will be retrieved for all Datasets on the Plot. - * @returns {d3.Selection} - */ - selections(datasets?: Dataset[]): d3.Selection; - /** - * Gets the Entities associated with the specified Datasets. - * - * @param {dataset[]} datasets The Datasets to retrieve the Entities for. - * If not provided, returns defaults to all Datasets on the Plot. - * @return {Plots.PlotEntity[]} - */ - entities(datasets?: Dataset[]): Plots.PlotEntity[]; - /** - * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. - * - * @param {Point} queryPoint - * @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. - */ - entityNearest(queryPoint: Point): Plots.PlotEntity; - /** - * @deprecated As of release v1.1.0, replaced by _entityVisibleOnPlot() - */ - protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; - protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; - protected _uninstallScaleForKey(scale: Scale, key: string): void; - protected _installScaleForKey(scale: Scale, key: string): void; - protected _propertyProjectors(): AttributeToProjector; - protected static _scaledAccessor(binding: Plots.AccessorScaleBinding): Accessor; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - protected _animateOnNextRender(): boolean; - } -} - - -declare module Plottable { - module Plots { - class Pie extends Plot { - /** - * @constructor - */ - constructor(); - protected _setup(): void; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Pie; - addDataset(dataset: Dataset): Pie; - protected _addDataset(dataset: Dataset): Pie; - removeDataset(dataset: Dataset): Pie; - protected _removeDatasetNodes(dataset: Dataset): void; - protected _removeDataset(dataset: Dataset): Pie; - selections(datasets?: Dataset[]): d3.Selection; - protected _onDatasetUpdate(): void; - protected _createDrawer(dataset: Dataset): Drawers.Arc; - entities(datasets?: Dataset[]): PlotEntity[]; - /** - * Gets the AccessorScaleBinding for the sector value. - */ - sectorValue(): AccessorScaleBinding; - /** - * Sets the sector value to a constant number or the result of an Accessor. - * - * @param {number|Accessor} sectorValue - * @returns {Pie} The calling Pie Plot. - */ - sectorValue(sectorValue: number | Accessor): Plots.Pie; - /** - * Sets the sector value to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {S|Accessor} sectorValue - * @param {Scale} scale - * @returns {Pie} The calling Pie Plot. - */ - sectorValue(sectorValue: S | Accessor, scale: Scale): Plots.Pie; - /** - * Gets the AccessorScaleBinding for the inner radius. - */ - innerRadius(): AccessorScaleBinding; - /** - * Sets the inner radius to a constant number or the result of an Accessor. - * - * @param {number|Accessor} innerRadius - * @returns {Pie} The calling Pie Plot. - */ - innerRadius(innerRadius: number | Accessor): Plots.Pie; - /** - * Sets the inner radius to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {R|Accessor} innerRadius - * @param {Scale} scale - * @returns {Pie} The calling Pie Plot. - */ - innerRadius(innerRadius: R | Accessor, scale: Scale): Plots.Pie; - /** - * Gets the AccessorScaleBinding for the outer radius. - */ - outerRadius(): AccessorScaleBinding; - /** - * Sets the outer radius to a constant number or the result of an Accessor. - * - * @param {number|Accessor} outerRadius - * @returns {Pie} The calling Pie Plot. - */ - outerRadius(outerRadius: number | Accessor): Plots.Pie; - /** - * Sets the outer radius to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {R|Accessor} outerRadius - * @param {Scale} scale - * @returns {Pie} The calling Pie Plot. - */ - outerRadius(outerRadius: R | Accessor, scale: Scale): Plots.Pie; - /** - * Get whether slice labels are enabled. - * - * @returns {boolean} Whether slices should display labels or not. - */ - labelsEnabled(): boolean; - /** - * Sets whether labels are enabled. - * - * @param {boolean} labelsEnabled - * @returns {Pie} The calling Pie Plot. - */ - labelsEnabled(enabled: boolean): Pie; - /** - * Gets the Formatter for the labels. - */ - labelFormatter(): Formatter; - /** - * Sets the Formatter for the labels. - * - * @param {Formatter} formatter - * @returns {Pie} The calling Pie Plot. - */ - labelFormatter(formatter: Formatter): Pie; - entitiesAt(queryPoint: Point): PlotEntity[]; - protected _propertyProjectors(): AttributeToProjector; - protected _getDataToDraw(): Utils.Map; - protected static _isValidData(value: any): boolean; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): { - x: number; - y: number; - }; - protected _additionalPaint(time: number): void; - } - } -} - - -declare module Plottable { - class XYPlot extends Plot { - protected static _X_KEY: string; - protected static _Y_KEY: string; - /** - * An XYPlot is a Plot that displays data along two primary directions, X and Y. - * - * @constructor - * @param {Scale} xScale The x scale to use. - * @param {Scale} yScale The y scale to use. - */ - constructor(); - /** - * Returns the whether or not the rendering is deferred for performance boost. - * @return {boolean} The deferred rendering option - */ - deferredRendering(): boolean; - /** - * Sets / unsets the deferred rendering option - * Activating this option improves the performance of plot interaction (pan / zoom) by - * performing lazy renders, only after the interaction has stopped. Because re-rendering - * is no longer performed during the interaction, the zooming might experience a small - * resolution degradation, before the lazy re-render is performed. - * - * This option is intended for cases where performance is an issue. - */ - deferredRendering(deferredRendering: boolean): XYPlot; - /** - * Gets the AccessorScaleBinding for X. - */ - x(): Plots.AccessorScaleBinding; - /** - * Sets X to a constant number or the result of an Accessor. - * - * @param {number|Accessor} x - * @returns {XYPlot} The calling XYPlot. - */ - x(x: number | Accessor): XYPlot; - /** - * Sets X to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {X|Accessor} x - * @param {Scale} xScale - * @returns {XYPlot} The calling XYPlot. - */ - x(x: X | Accessor, xScale: Scale): XYPlot; - /** - * Gets the AccessorScaleBinding for Y. - */ - y(): Plots.AccessorScaleBinding; - /** - * Sets Y to a constant number or the result of an Accessor. - * - * @param {number|Accessor} y - * @returns {XYPlot} The calling XYPlot. - */ - y(y: number | Accessor): XYPlot; - /** - * Sets Y to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {Y|Accessor} y - * @param {Scale} yScale - * @returns {XYPlot} The calling XYPlot. - */ - y(y: Y | Accessor, yScale: Scale): XYPlot; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; - protected _uninstallScaleForKey(scale: Scale, key: string): void; - protected _installScaleForKey(scale: Scale, key: string): void; - destroy(): XYPlot; - /** - * Gets the automatic domain adjustment mode for visible points. - */ - autorangeMode(): string; - /** - * Sets the automatic domain adjustment mode for visible points to operate against the X Scale, Y Scale, or neither. - * If "x" or "y" is specified the adjustment is immediately performed. - * - * @param {string} autorangeMode One of "x"/"y"/"none". - * "x" will adjust the x Scale in relation to changes in the y domain. - * "y" will adjust the y Scale in relation to changes in the x domain. - * "none" means neither Scale will change automatically. - * @returns {XYPlot} The calling XYPlot. - */ - autorangeMode(autorangeMode: string): XYPlot; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; - /** - * Adjusts the domains of both X and Y scales to show all data. - * This call does not override the autorange() behavior. - * - * @returns {XYPlot} The calling XYPlot. - */ - showAllData(): XYPlot; - protected _projectorsReady(): boolean; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - protected _getDataToDraw(): Utils.Map; - } -} - - -declare module Plottable { - module Plots { - class Rectangle extends XYPlot { - /** - * A Rectangle Plot displays rectangles based on the data. - * The left and right edges of each rectangle can be set with x() and x2(). - * If only x() is set the Rectangle Plot will attempt to compute the correct left and right edge positions. - * The top and bottom edges of each rectangle can be set with y() and y2(). - * If only y() is set the Rectangle Plot will attempt to compute the correct top and bottom edge positions. - * - * @constructor - * @param {Scale.Scale} xScale - * @param {Scale.Scale} yScale - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawers.Rectangle; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; - /** - * Gets the AccessorScaleBinding for X. - */ - x(): AccessorScaleBinding; - /** - * Sets X to a constant number or the result of an Accessor. - * - * @param {number|Accessor} x - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - x(x: number | Accessor): Plots.Rectangle; - /** - * Sets X to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {X|Accessor} x - * @param {Scale} xScale - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - x(x: X | Accessor, xScale: Scale): Plots.Rectangle; - /** - * Gets the AccessorScaleBinding for X2. - */ - x2(): AccessorScaleBinding; - /** - * Sets X2 to a constant number or the result of an Accessor. - * If a Scale has been set for X, it will also be used to scale X2. - * - * @param {number|Accessor|X|Accessor} x2 - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - x2(x2: number | Accessor | X | Accessor): Plots.Rectangle; - /** - * Gets the AccessorScaleBinding for Y. - */ - y(): AccessorScaleBinding; - /** - * Sets Y to a constant number or the result of an Accessor. - * - * @param {number|Accessor} y - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - y(y: number | Accessor): Plots.Rectangle; - /** - * Sets Y to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {Y|Accessor} y - * @param {Scale} yScale - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - y(y: Y | Accessor, yScale: Scale): Plots.Rectangle; - /** - * Gets the AccessorScaleBinding for Y2. - */ - y2(): AccessorScaleBinding; - /** - * Sets Y2 to a constant number or the result of an Accessor. - * If a Scale has been set for Y, it will also be used to scale Y2. - * - * @param {number|Accessor|Y|Accessor} y2 - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - y2(y2: number | Accessor | Y | Accessor): Plots.Rectangle; - /** - * Gets the PlotEntities at a particular Point. - * - * @param {Point} point The point to query. - * @returns {PlotEntity[]} The PlotEntities at the particular point - */ - entitiesAt(point: Point): PlotEntity[]; - /** - * Gets the Entities that intersect the Bounds. - * - * @param {Bounds} bounds - * @returns {PlotEntity[]} - */ - entitiesIn(bounds: Bounds): PlotEntity[]; - /** - * Gets the Entities that intersect the area defined by the ranges. - * - * @param {Range} xRange - * @param {Range} yRange - * @returns {PlotEntity[]} - */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; - /** - * Gets the accessor for labels. - * - * @returns {Accessor} - */ - label(): Accessor; - /** - * Sets the text of labels to the result of an Accessor. - * - * @param {Accessor} label - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - label(label: Accessor): Plots.Rectangle; - /** - * Gets whether labels are enabled. - * - * @returns {boolean} - */ - labelsEnabled(): boolean; - /** - * Sets whether labels are enabled. - * Labels too big to be contained in the rectangle, cut off by edges, or blocked by other rectangles will not be shown. - * - * @param {boolean} labelsEnabled - * @returns {Rectangle} The calling Rectangle Plot. - */ - labelsEnabled(enabled: boolean): Plots.Rectangle; - protected _propertyProjectors(): AttributeToProjector; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): { - x: any; - y: any; - }; - protected _getDataToDraw(): Utils.Map; - protected _additionalPaint(time: number): void; - } - } -} - - -declare module Plottable { - module Plots { - class Scatter extends XYPlot { - /** - * A Scatter Plot draws a symbol at each data point. - * - * @constructor - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawers.Symbol; - /** - * Gets the AccessorScaleBinding for the size property of the plot. - * The size property corresponds to the area of the symbol. - */ - size(): AccessorScaleBinding; - /** - * Sets the size property to a constant number or the result of an Accessor. - * - * @param {number|Accessor} size - * @returns {Plots.Scatter} The calling Scatter Plot. - */ - size(size: number | Accessor): Plots.Scatter; - /** - * Sets the size property to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {S|Accessor} sectorValue - * @param {Scale} scale - * @returns {Plots.Scatter} The calling Scatter Plot. - */ - size(size: S | Accessor, scale: Scale): Plots.Scatter; - /** - * Gets the AccessorScaleBinding for the symbol property of the plot. - * The symbol property corresponds to how the symbol will be drawn. - */ - symbol(): AccessorScaleBinding; - /** - * Sets the symbol property to an Accessor. - * - * @param {Accessor} symbol - * @returns {Plots.Scatter} The calling Scatter Plot. - */ - symbol(symbol: Accessor): Plots.Scatter; - protected _generateDrawSteps(): Drawers.DrawStep[]; - /** - * @deprecated As of release v1.1.0, replaced by _entityVisibleOnPlot() - */ - protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; - protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; - protected _propertyProjectors(): AttributeToProjector; - /** - * Gets the Entities that intersect the Bounds. - * - * @param {Bounds} bounds - * @returns {PlotEntity[]} - */ - entitiesIn(bounds: Bounds): PlotEntity[]; - /** - * Gets the Entities that intersect the area defined by the ranges. - * - * @param {Range} xRange - * @param {Range} yRange - * @returns {PlotEntity[]} - */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; - /** - * Gets the Entities at a particular Point. - * - * @param {Point} p - * @returns {PlotEntity[]} - */ - entitiesAt(p: Point): PlotEntity[]; - } - } -} - - -declare module Plottable { - module Plots { - class Bar extends XYPlot { - static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; - protected _isVertical: boolean; - /** - * A Bar Plot draws bars growing out from a baseline to some value - * - * @constructor - * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". - */ - constructor(orientation?: string); - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): Bar; - x(x: X | Accessor, xScale: Scale): Bar; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): Bar; - y(y: Y | Accessor, yScale: Scale): Bar; - /** - * Gets the orientation of the plot - * - * @return "vertical" | "horizontal" - */ - orientation(): string; - render(): Bar; - protected _createDrawer(dataset: Dataset): Drawers.Rectangle; - protected _setup(): void; - /** - * Gets the baseline value. - * The baseline is the line that the bars are drawn from. - * - * @returns {X|Y} - */ - baselineValue(): X | Y; - /** - * Sets the baseline value. - * The baseline is the line that the bars are drawn from. - * - * @param {X|Y} value - * @returns {Bar} The calling Bar Plot. - */ - baselineValue(value: X | Y): Bar; - addDataset(dataset: Dataset): Bar; - protected _addDataset(dataset: Dataset): Bar; - removeDataset(dataset: Dataset): Bar; - protected _removeDataset(dataset: Dataset): Bar; - datasets(): Dataset[]; - datasets(datasets: Dataset[]): Plot; - /** - * Get whether bar labels are enabled. - * - * @returns {boolean} Whether bars should display labels or not. - */ - labelsEnabled(): boolean; - /** - * Sets whether labels are enabled. - * - * @param {boolean} labelsEnabled - * @returns {Bar} The calling Bar Plot. - */ - labelsEnabled(enabled: boolean): Bar; - /** - * Gets the Formatter for the labels. - */ - labelFormatter(): Formatter; - /** - * Sets the Formatter for the labels. - * - * @param {Formatter} formatter - * @returns {Bar} The calling Bar Plot. - */ - labelFormatter(formatter: Formatter): Bar; - protected _createNodesForDataset(dataset: Dataset): Drawer; - protected _removeDatasetNodes(dataset: Dataset): void; - /** - * Returns the PlotEntity nearest to the query point according to the following algorithm: - * - If the query point is inside a bar, returns the PlotEntity for that bar. - * - Otherwise, gets the nearest PlotEntity by the primary direction (X for vertical, Y for horizontal), - * breaking ties with the secondary direction. - * Returns undefined if no PlotEntity can be found. - * - * @param {Point} queryPoint - * @returns {PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. - */ - entityNearest(queryPoint: Point): PlotEntity; - /** - * @deprecated As of release v1.1.0, replaced by _entityVisibleOnPlot() - */ - protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; - protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; - /** - * Gets the Entities at a particular Point. - * - * @param {Point} p - * @returns {PlotEntity[]} - */ - entitiesAt(p: Point): PlotEntity[]; - /** - * Gets the Entities that intersect the Bounds. - * - * @param {Bounds} bounds - * @returns {PlotEntity[]} - */ - entitiesIn(bounds: Bounds): PlotEntity[]; - /** - * Gets the Entities that intersect the area defined by the ranges. - * - * @param {Range} xRange - * @param {Range} yRange - * @returns {PlotEntity[]} - */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; - protected _additionalPaint(time: number): void; - /** - * Makes sure the extent takes into account the widths of the bars - */ - protected _extentsForProperty(property: string): any[]; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - /** - * Computes the barPixelWidth of all the bars in the plot. - * - * If the position scale of the plot is a CategoryScale and in bands mode, then the rangeBands function will be used. - * If the position scale of the plot is a QuantitativeScale, then the bar width is equal to the smallest distance between - * two adjacent data points, padded for visualisation. - */ - protected _getBarPixelWidth(): number; - entities(datasets?: Dataset[]): PlotEntity[]; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - protected _uninstallScaleForKey(scale: Scale, key: string): void; - protected _getDataToDraw(): Utils.Map; - } - } -} - - -declare module Plottable { - module Plots { - class Line extends XYPlot { - /** - * A Line Plot draws line segments starting from the first data point to the next. - * - * @constructor - */ - constructor(); - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): Line; - x(x: X | Accessor, xScale: Scale): Line; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): Line; - y(y: number | Accessor, yScale: Scale): Line; - autorangeMode(): string; - autorangeMode(autorangeMode: string): Line; - /** - * Gets whether or not the autoranging is done smoothly. - */ - autorangeSmooth(): boolean; - /** - * Sets whether or not the autorange is done smoothly. - * - * Smooth autoranging is done by making sure lines always exit on the left / right side of the plot - * and deactivating the nice domain feature on the scales - */ - autorangeSmooth(autorangeSmooth: boolean): Plots.Line; - /** - * Gets the interpolation function associated with the plot. - * - * @return {string | (points: Array<[number, number]>) => string)} - */ - interpolator(): string | ((points: Array<[number, number]>) => string); - /** - * Sets the interpolation function associated with the plot. - * - * @param {string | points: Array<[number, number]>) => string} interpolator Interpolation function - * @return Plots.Line - */ - interpolator(interpolator: string | ((points: Array<[number, number]>) => string)): Plots.Line; - interpolator(interpolator: "linear"): Line; - interpolator(interpolator: "linear-closed"): Line; - interpolator(interpolator: "step"): Line; - interpolator(interpolator: "step-before"): Line; - interpolator(interpolator: "step-after"): Line; - interpolator(interpolator: "basis"): Line; - interpolator(interpolator: "basis-open"): Line; - interpolator(interpolator: "basis-closed"): Line; - interpolator(interpolator: "bundle"): Line; - interpolator(interpolator: "cardinal"): Line; - interpolator(interpolator: "cardinal-open"): Line; - interpolator(interpolator: "cardinal-closed"): Line; - interpolator(interpolator: "monotone"): Line; - protected _createDrawer(dataset: Dataset): Drawer; - protected _extentsForProperty(property: string): any[]; - protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - /** - * Returns the PlotEntity nearest to the query point by X then by Y, or undefined if no PlotEntity can be found. - * - * @param {Point} queryPoint - * @returns {PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. - */ - entityNearest(queryPoint: Point): PlotEntity; - protected _propertyProjectors(): AttributeToProjector; - protected _constructLineProjector(xProjector: Projector, yProjector: Projector): (datum: any, index: number, dataset: Dataset) => string; - protected _getDataToDraw(): Utils.Map; - } - } -} - - -declare module Plottable { - module Plots { - class Area extends Line { - /** - * An Area Plot draws a filled region (area) between Y and Y0. - * - * @constructor - */ - constructor(); - protected _setup(): void; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): Area; - y(y: number | Accessor, yScale: QuantitativeScale): Area; - /** - * Gets the AccessorScaleBinding for Y0. - */ - y0(): Plots.AccessorScaleBinding; - /** - * Sets Y0 to a constant number or the result of an Accessor. - * If a Scale has been set for Y, it will also be used to scale Y0. - * - * @param {number|Accessor} y0 - * @returns {Area} The calling Area Plot. - */ - y0(y0: number | Accessor): Area; - protected _onDatasetUpdate(): void; - addDataset(dataset: Dataset): Area; - protected _addDataset(dataset: Dataset): Area; - protected _removeDatasetNodes(dataset: Dataset): void; - protected _additionalPaint(): void; - protected _createDrawer(dataset: Dataset): Drawers.Area; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _updateYScale(): void; - protected _getResetYFunction(): Accessor; - protected _propertyProjectors(): AttributeToProjector; - selections(datasets?: Dataset[]): d3.Selection; - protected _constructAreaProjector(xProjector: Projector, yProjector: Projector, y0Projector: Projector): (datum: any[], index: number, dataset: Dataset) => string; - } - } -} - - -declare module Plottable { - module Plots { - class ClusteredBar extends Bar { - /** - * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. - * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. - * On a horizontal ClusteredBar Plot, the bars with the same Y value are grouped. - * - * @constructor - * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". - */ - constructor(orientation?: string); - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _getDataToDraw(): Utils.Map; - } - } -} - - -declare module Plottable { - module Plots { - class StackedArea extends Area { - /** - * @constructor - */ - constructor(); - protected _getAnimator(key: string): Animator; - protected _setup(): void; - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): StackedArea; - x(x: X | Accessor, xScale: Scale): StackedArea; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): StackedArea; - y(y: number | Accessor, yScale: QuantitativeScale): StackedArea; - protected _additionalPaint(): void; - protected _updateYScale(): void; - protected _onDatasetUpdate(): StackedArea; - protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; - protected _propertyProjectors(): AttributeToProjector; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - } - } -} - - -declare module Plottable { - module Plots { - class StackedBar extends Bar { - /** - * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. - * On a vertical StackedBar Plot, the bars with the same X value are stacked. - * On a horizontal StackedBar Plot, the bars with the same Y value are stacked. - * - * @constructor - * @param {Scale} xScale - * @param {Scale} yScale - * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". - */ - constructor(orientation?: string); - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): StackedBar; - x(x: X | Accessor, xScale: Scale): StackedBar; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): StackedBar; - y(y: Y | Accessor, yScale: Scale): StackedBar; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _onDatasetUpdate(): StackedBar; - protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; - } - } -} - - -declare module Plottable { - module Plots { - class Segment extends XYPlot { - /** - * A Segment Plot displays line segments based on the data. - * - * @constructor - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawers.Segment; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; - /** - * Gets the AccessorScaleBinding for X - */ - x(): AccessorScaleBinding; - /** - * Sets X to a constant value or the result of an Accessor. - * - * @param {X|Accessor} x - * @returns {Plots.Segment} The calling Segment Plot. - */ - x(x: number | Accessor): Plots.Segment; - /** - * Sets X to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {X|Accessor} x - * @param {Scale} xScale - * @returns {Plots.Segment} The calling Segment Plot. - */ - x(x: X | Accessor, xScale: Scale): Plots.Segment; - /** - * Gets the AccessorScaleBinding for X2 - */ - x2(): AccessorScaleBinding; - /** - * Sets X2 to a constant number or the result of an Accessor. - * If a Scale has been set for X, it will also be used to scale X2. - * - * @param {number|Accessor|Y|Accessor} y2 - * @returns {Plots.Segment} The calling Segment Plot - */ - x2(x2: number | Accessor | X | Accessor): Plots.Segment; - /** - * Gets the AccessorScaleBinding for Y - */ - y(): AccessorScaleBinding; - /** - * Sets Y to a constant value or the result of an Accessor. - * - * @param {Y|Accessor} y - * @returns {Plots.Segment} The calling Segment Plot. - */ - y(y: number | Accessor): Plots.Segment; - /** - * Sets Y to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {Y|Accessor} y - * @param {Scale} yScale - * @returns {Plots.Segment} The calling Segment Plot. - */ - y(y: Y | Accessor, yScale: Scale): Plots.Segment; - /** - * Gets the AccessorScaleBinding for Y2. - */ - y2(): AccessorScaleBinding; - /** - * Sets Y2 to a constant number or the result of an Accessor. - * If a Scale has been set for Y, it will also be used to scale Y2. - * - * @param {number|Accessor|Y|Accessor} y2 - * @returns {Plots.Segment} The calling Segment Plot. - */ - y2(y2: number | Accessor | Y | Accessor): Plots.Segment; - protected _propertyProjectors(): AttributeToProjector; - /** - * Gets the Entities that intersect the Bounds. - * - * @param {Bounds} bounds - * @returns {PlotEntity[]} - */ - entitiesIn(bounds: Bounds): PlotEntity[]; - /** - * Gets the Entities that intersect the area defined by the ranges. - * - * @param {Range} xRange - * @param {Range} yRange - * @returns {PlotEntity[]} - */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; - } - } -} - - -declare module Plottable { - module Plots { - class Waterfall extends Bar { - constructor(); - /** - * Gets whether connectors are enabled. - * - * @returns {boolean} Whether connectors should be shown or not. - */ - connectorsEnabled(): boolean; - /** - * Sets whether connectors are enabled. - * - * @param {boolean} enabled - * @returns {Plots.Waterfall} The calling Waterfall Plot. - */ - connectorsEnabled(enabled: boolean): Waterfall; - /** - * Gets the AccessorScaleBinding for whether a bar represents a total or a delta. - */ - total(): Plots.AccessorScaleBinding; - /** - * Sets total to a constant number or the result of an Accessor - * - * @param {Accessor} - * @returns {Plots.Waterfall} The calling Waterfall Plot. - */ - total(total: Accessor): Waterfall; - protected _additionalPaint(time: number): void; - protected _createNodesForDataset(dataset: Dataset): Drawer; - protected _extentsForProperty(attr: string): any[]; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _onDatasetUpdate(): Waterfall; - } - } -} - - -declare module Plottable { - module Plots { - class Wheel extends Plot { - /** - * @constructor - */ - constructor(); - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Wheel; - protected _createDrawer(dataset: Dataset): Drawers.Arc; - entities(datasets?: Dataset[]): PlotEntity[]; - protected _getDataToDraw(): Utils.Map; - protected _propertyProjectors(): AttributeToProjector; - /** - * Gets the AccessorScaleBinding for t in degrees. - */ - t(): AccessorScaleBinding; - /** - * Sets t to a constant number or the result of an Accessor in degrees. - * - * @param {number|Accessor} t - * @returns {Wheel} The calling Wheel Plot. - */ - t(t: number | Accessor): Plots.Wheel; - /** - * Sets t to a scaled constant value or scaled result of an Accessor in degrees. - * The supplied Scale will also be used for t2(). - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {T|Accessor} t - * @param {QuantitativeScale} scale - * @returns {Wheel} The calling Wheel Plot. - */ - t(t: T | Accessor, scale: QuantitativeScale): Plots.Wheel; - /** - * Gets the AccessorScaleBinding for t2 in degrees. - */ - t2(): AccessorScaleBinding; - /** - * Sets t2 to a constant number or the result of an Accessor in degrees. - * If a Scale has been set for t, it will also be used to scale t2. - * - * @param {number|Accessor>} t2 - * @returns {Wheel} The calling Wheel Plot. - */ - t2(t2: number | Accessor | T | Accessor): Plots.Wheel; - /** - * Gets the AccessorScaleBinding for r. - */ - r(): AccessorScaleBinding; - /** - * Sets r to a constant number or the result of an Accessor. - * - * @param {number|Accessor} r - * @returns {Wheel} The calling Wheel Plot. - */ - r(r: number | Accessor): Plots.Wheel; - /** - * Sets r to a scaled constant value or scaled result of an Accessor. - * The supplied Scale will also be used for r2(). - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {R|Accessor} r - * @param {QuantitativeScale} scale - * @returns {Wheel} The calling Wheel Plot. - */ - r(r: R | Accessor, scale: QuantitativeScale): Plots.Wheel; - /** - * Gets the AccessorScaleBinding for r2. - */ - r2(): AccessorScaleBinding; - /** - * Sets r2 to a constant number or the result of an Accessor. - * If a Scale has been set for r, it will also be used to scale r2. - * - * @param {number|Accessor|R|Accessor} r2 - * @returns {Wheel} The calling Wheel Plot. - */ - r2(r2: number | Accessor | R | Accessor): Plots.Wheel; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): { - x: number; - y: number; - }; - } - } -} - - -declare module Plottable { - interface Animator { - /** - * Applies the supplied attributes to a d3.Selection with some animation. - * - * @param {d3.Selection} selection The update selection or transition selection that we wish to animate. - * @param {AttributeToAppliedProjector} attrToAppliedProjector The set of - * AppliedProjectors that we will use to set attributes on the selection. - * @return {any} Animators should return the selection or - * transition object so that plots may chain the transitions between - * animators. - */ - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection | d3.Transition; - /** - * Given the number of elements, return the total time the animation requires - * - * @param {number} numberofIterations The number of elements that will be drawn - * @returns {number} - */ - totalTime(numberOfIterations: number): number; - } -} - - -declare module Plottable { - module Animators { - /** - * An animator implementation with no animation. The attributes are - * immediately set on the selection. - */ - class Null implements Animator { - totalTime(selection: any): number; - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection; - } - } -} - - -declare module Plottable { - module Animators { - /** - * An Animator with easing and configurable durations and delays. - */ - class Easing implements Animator { - /** - * Constructs the default animator - * - * @constructor - */ - constructor(); - totalTime(numberOfSteps: number): number; - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Transition; - /** - * Gets the start delay of the animation in milliseconds. - * - * @returns {number} The current start delay. - */ - startDelay(): number; - /** - * Sets the start delay of the animation in milliseconds. - * - * @param {number} startDelay The start delay in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - startDelay(startDelay: number): Easing; - /** - * Gets the duration of one animation step in milliseconds. - * - * @returns {number} The current duration. - */ - stepDuration(): number; - /** - * Sets the duration of one animation step in milliseconds. - * - * @param {number} stepDuration The duration in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - stepDuration(stepDuration: number): Easing; - /** - * Gets the maximum start delay between animation steps in milliseconds. - * - * @returns {number} The current maximum iterative delay. - */ - stepDelay(): number; - /** - * Sets the maximum start delay between animation steps in milliseconds. - * - * @param {number} stepDelay The maximum iterative delay in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - stepDelay(stepDelay: number): Easing; - /** - * Gets the maximum total animation duration constraint in milliseconds. - * - * If the animation time would exceed the specified time, the duration of each step - * and the delay between each step will be reduced until the animation fits within - * the specified time. - * - * @returns {number} The current maximum total animation duration. - */ - maxTotalDuration(): number; - /** - * Sets the maximum total animation duration constraint in miliseconds. - * - * If the animation time would exceed the specified time, the duration of each step - * and the delay between each step will be reduced until the animation fits within - * the specified time. - * - * @param {number} maxTotalDuration The maximum total animation duration in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - maxTotalDuration(maxTotalDuration: number): Easing; - /** - * Gets the current easing mode of the animation. - * - * @returns {string} the current easing mode. - */ - easingMode(): string; - /** - * Sets the easing mode of the animation. - * - * @param {string} easingMode The desired easing mode. - * @returns {Easing} The calling Easing Animator. - */ - easingMode(easingMode: string): Easing; - } - } -} - - -declare module Plottable { - class Dispatcher { - protected _eventToCallback: { - [eventName: string]: (e: Event) => any; - }; - protected _callbacks: Utils.CallbackSet[]; - protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; - protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; - } -} - - -declare module Plottable { - module Dispatchers { - type MouseCallback = (p: Point, event: MouseEvent) => void; - class Mouse extends Dispatcher { - /** - * Get a Mouse Dispatcher for the containing elem. - * If one already exists on that , it will be returned; otherwise, a new one will be created. - * - * @param {SVGElement} elem - * @return {Dispatchers.Mouse} - */ - static getDispatcher(elem: SVGElement): Dispatchers.Mouse; - /** - * This constructor not be invoked directly. - * - * @constructor - * @param {SVGElement} svg The root to attach to. - */ - constructor(svg: SVGElement); - /** - * Registers a callback to be called when the mouse position changes. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onMouseMove(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when the mouse position changes. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offMouseMove(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a mousedown occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onMouseDown(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a mousedown occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offMouseDown(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a mouseup occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onMouseUp(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a mouseup occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offMouseUp(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a wheel event occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onWheel(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a wheel event occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offWheel(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a dblClick occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onDblClick(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a dblClick occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offDblClick(callback: MouseCallback): Dispatchers.Mouse; - eventInsideSVG(event: MouseEvent): boolean; - /** - * Returns the last computed mouse position in coordinate space. - * - * @return {Point} - */ - lastMousePosition(): Point; - } - } -} - - -declare module Plottable { - module Dispatchers { - type TouchCallback = (ids: number[], idToPoint: { - [id: number]: Point; - }, event: TouchEvent) => void; - class Touch extends Dispatcher { - /** - * Gets a Touch Dispatcher for the containing elem. - * If one already exists on that , it will be returned; otherwise, a new one will be created. - * - * @param {SVGElement} elem - * @return {Dispatchers.Touch} - */ - static getDispatcher(elem: SVGElement): Dispatchers.Touch; - /** - * This constructor should not be invoked directly. - * - * @constructor - * @param {SVGElement} svg The root to attach to. - */ - constructor(svg: SVGElement); - /** - * Registers a callback to be called when a touch starts. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchStart(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when a touch starts. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchStart(callback: TouchCallback): Dispatchers.Touch; - /** - * Registers a callback to be called when the touch position changes. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchMove(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when the touch position changes. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchMove(callback: TouchCallback): Dispatchers.Touch; - /** - * Registers a callback to be called when a touch ends. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchEnd(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when a touch ends. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchEnd(callback: TouchCallback): Dispatchers.Touch; - /** - * Registers a callback to be called when a touch is cancelled. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchCancel(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when a touch is cancelled. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchCancel(callback: TouchCallback): Dispatchers.Touch; - eventInsideSVG(event: TouchEvent): boolean; - } - } -} - - -declare module Plottable { - module Dispatchers { - type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; - class Key extends Dispatcher { - /** - * Gets a Key Dispatcher. If one already exists it will be returned; - * otherwise, a new one will be created. - * - * @return {Dispatchers.Key} - */ - static getDispatcher(): Dispatchers.Key; - /** - * This constructor should not be invoked directly. - * - * @constructor - */ - constructor(); - /** - * Registers a callback to be called whenever a key is pressed. - * - * @param {KeyCallback} callback - * @return {Dispatchers.Key} The calling Key Dispatcher. - */ - onKeyDown(callback: KeyCallback): Key; - /** - * Removes the callback to be called whenever a key is pressed. - * - * @param {KeyCallback} callback - * @return {Dispatchers.Key} The calling Key Dispatcher. - */ - offKeyDown(callback: KeyCallback): Key; - /** Registers a callback to be called whenever a key is released. - * - * @param {KeyCallback} callback - * @return {Dispatchers.Key} The calling Key Dispatcher. - */ - onKeyUp(callback: KeyCallback): Key; - /** - * Removes the callback to be called whenever a key is released. - * - * @param {KeyCallback} callback - * @return {Dispatchers.Key} The calling Key Dispatcher. - */ - offKeyUp(callback: KeyCallback): Key; - } - } -} - - -declare module Plottable { - class Interaction { - protected _componentAttachedTo: Component; - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Attaches this Interaction to a Component. - * If the Interaction was already attached to a Component, it first detaches itself from the old Component. - * - * @param {Component} component - * @returns {Interaction} The calling Interaction. - */ - attachTo(component: Component): Interaction; - /** - * Detaches this Interaction from the Component. - * This Interaction can be reused. - * - * @param {Component} component - * @returns {Interaction} The calling Interaction. - */ - detachFrom(component: Component): Interaction; - /** - * Gets whether this Interaction is enabled. - */ - enabled(): boolean; - /** - * Enables or disables this Interaction. - * - * @param {boolean} enabled Whether the Interaction should be enabled. - * @return {Interaction} The calling Interaction. - */ - enabled(enabled: boolean): Interaction; - /** - * Translates an -coordinate-space point to Component-space coordinates. - * - * @param {Point} p A Point in -space coordinates. - * @return {Point} The same location in Component-space coordinates. - */ - protected _translateToComponentSpace(p: Point): Point; - /** - * Checks whether a Component-coordinate-space Point is inside the Component. - * - * @param {Point} p A Point in Compoennt-space coordinates. - * @return {boolean} Whether or not the point is inside the Component. - */ - protected _isInsideComponent(p: Point): boolean; - } -} - - -declare module Plottable { - type ClickCallback = (point: Point) => void; - module Interactions { - class Click extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the Component is clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.Click} The calling Click Interaction. - */ - onClick(callback: ClickCallback): Click; - /** - * Removes a callback that would be called when the Component is clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.Click} The calling Click Interaction. - */ - offClick(callback: ClickCallback): Click; - } - } -} - - -declare module Plottable { - module Interactions { - class DoubleClick extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the Component is double-clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.DoubleClick} The calling DoubleClick Interaction. - */ - onDoubleClick(callback: ClickCallback): DoubleClick; - /** - * Removes a callback that would be called when the Component is double-clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.DoubleClick} The calling DoubleClick Interaction. - */ - offDoubleClick(callback: ClickCallback): DoubleClick; - } - } -} - - -declare module Plottable { - type KeyCallback = (keyCode: number) => void; - module Interactions { - class Key extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the key with the given keyCode is - * pressed and the user is moused over the Component. - * - * @param {number} keyCode - * @param {KeyCallback} callback - * @returns {Interactions.Key} The calling Key Interaction. - */ - onKeyPress(keyCode: number, callback: KeyCallback): Key; - /** - * Removes a callback that would be called when the key with the given keyCode is - * pressed and the user is moused over the Component. - * - * @param {number} keyCode - * @param {KeyCallback} callback - * @returns {Interactions.Key} The calling Key Interaction. - */ - offKeyPress(keyCode: number, callback: KeyCallback): Key; - /** - * Adds a callback to be called when the key with the given keyCode is - * released if the key was pressed with the mouse inside of the Component. - * - * @param {number} keyCode - * @param {KeyCallback} callback - * @returns {Interactions.Key} The calling Key Interaction. - */ - onKeyRelease(keyCode: number, callback: KeyCallback): Key; - /** - * Removes a callback that would be called when the key with the given keyCode is - * released if the key was pressed with the mouse inside of the Component. - * - * @param {number} keyCode - * @param {KeyCallback} callback - * @returns {Interactions.Key} The calling Key Interaction. - */ - offKeyRelease(keyCode: number, callback: KeyCallback): Key; - } - } -} - - -declare module Plottable { - type PointerCallback = (point: Point) => void; - module Interactions { - class Pointer extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the pointer enters the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - onPointerEnter(callback: PointerCallback): Pointer; - /** - * Removes a callback that would be called when the pointer enters the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - offPointerEnter(callback: PointerCallback): Pointer; - /** - * Adds a callback to be called when the pointer moves within the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - onPointerMove(callback: PointerCallback): Pointer; - /** - * Removes a callback that would be called when the pointer moves within the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - offPointerMove(callback: PointerCallback): Pointer; - /** - * Adds a callback to be called when the pointer exits the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - onPointerExit(callback: PointerCallback): Pointer; - /** - * Removes a callback that would be called when the pointer exits the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - offPointerExit(callback: PointerCallback): Pointer; - } - } -} - - -declare module Plottable { - module Interactions { - class PanZoom extends Interaction { - /** - * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale - * in response to the user panning or zooming. - * - * @constructor - * @param {QuantitativeScale} [xScale] The x-scale to update on panning/zooming. - * @param {QuantitativeScale} [yScale] The y-scale to update on panning/zooming. - */ - constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Gets the x scales for this PanZoom Interaction. - */ - xScales(): QuantitativeScale[]; - /** - * Sets the x scales for this PanZoom Interaction. - * - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - xScales(xScales: QuantitativeScale[]): Interactions.PanZoom; - /** - * Gets the y scales for this PanZoom Interaction. - */ - yScales(): QuantitativeScale[]; - /** - * Sets the y scales for this PanZoom Interaction. - * - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - yScales(yScales: QuantitativeScale[]): Interactions.PanZoom; - /** - * Adds an x scale to this PanZoom Interaction - * - * @param {QuantitativeScale} An x scale to add - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - addXScale(xScale: QuantitativeScale): PanZoom; - /** - * Removes an x scale from this PanZoom Interaction - * - * @param {QuantitativeScale} An x scale to remove - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - removeXScale(xScale: QuantitativeScale): PanZoom; - /** - * Adds a y scale to this PanZoom Interaction - * - * @param {QuantitativeScale} A y scale to add - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - addYScale(yScale: QuantitativeScale): PanZoom; - /** - * Removes a y scale from this PanZoom Interaction - * - * @param {QuantitativeScale} A y scale to remove - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - removeYScale(yScale: QuantitativeScale): PanZoom; - /** - * Gets the minimum domain extent for the scale, specifying the minimum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @returns {D} The minimum domain extent for the scale. - */ - minDomainExtent(quantitativeScale: QuantitativeScale): D; - /** - * Sets the minimum domain extent for the scale, specifying the minimum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @param {D} minDomainExtent The minimum domain extent for the scale. - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - minDomainExtent(quantitativeScale: QuantitativeScale, minDomainExtent: D): Interactions.PanZoom; - /** - * Gets the maximum domain extent for the scale, specifying the maximum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @returns {D} The maximum domain extent for the scale. - */ - maxDomainExtent(quantitativeScale: QuantitativeScale): D; - /** - * Sets the maximum domain extent for the scale, specifying the maximum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @param {D} minDomainExtent The maximum domain extent for the scale. - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - maxDomainExtent(quantitativeScale: QuantitativeScale, maxDomainExtent: D): Interactions.PanZoom; - } - } -} - - -declare module Plottable { - type DragCallback = (start: Point, end: Point) => void; - module Interactions { - class Drag extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Gets whether the Drag Interaction constrains Points passed to its - * callbacks to lie inside its Component. - * - * If true, when the user drags outside of the Component, the closest Point - * inside the Component will be passed to the callback instead of the actual - * cursor position. - * - * @return {boolean} - */ - constrainedToComponent(): boolean; - /** - * Sets whether the Drag Interaction constrains Points passed to its - * callbacks to lie inside its Component. - * - * If true, when the user drags outside of the Component, the closest Point - * inside the Component will be passed to the callback instead of the actual - * cursor position. - * - * @param {boolean} - * @return {Interactions.Drag} The calling Drag Interaction. - */ - constrainedToComponent(constrainedToComponent: boolean): Drag; - /** - * Adds a callback to be called when dragging starts. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - onDragStart(callback: DragCallback): Drag; - /** - * Removes a callback that would be called when dragging starts. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - offDragStart(callback: DragCallback): Drag; - /** - * Adds a callback to be called during dragging. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - onDrag(callback: DragCallback): Drag; - /** - * Removes a callback that would be called during dragging. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - offDrag(callback: DragCallback): Drag; - /** - * Adds a callback to be called when dragging ends. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - onDragEnd(callback: DragCallback): Drag; - /** - * Removes a callback that would be called when dragging ends. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - offDragEnd(callback: DragCallback): Drag; - } - } -} - - -declare module Plottable { - type DragBoxCallback = (bounds: Bounds) => void; - module Components { - class DragBoxLayer extends Components.SelectionBoxLayer { - protected _hasCorners: boolean; - /** - * Constructs a DragBoxLayer. - * - * A DragBoxLayer is a SelectionBoxLayer with a built-in Drag Interaction. - * A drag gesture will set the Bounds of the box. - * If resizing is enabled using resizable(true), the edges of box can be repositioned. - * - * @constructor - */ - constructor(); - protected _setup(): void; - renderImmediately(): DragBoxLayer; - /** - * Gets the detection radius of the drag box in pixels. - */ - detectionRadius(): number; - /** - * Sets the detection radius of the drag box in pixels. - * - * @param {number} r - * @return {DragBoxLayer} The calling DragBoxLayer. - */ - detectionRadius(r: number): DragBoxLayer; - /** - * Gets whether or not the drag box is resizable. - */ - resizable(): boolean; - /** - * Sets whether or not the drag box is resizable. - * - * @param {boolean} canResize - * @return {DragBoxLayer} The calling DragBoxLayer. - */ - resizable(canResize: boolean): DragBoxLayer; - protected _setResizableClasses(canResize: boolean): void; - /** - * Gets whether or not the drag box is movable. - */ - movable(): boolean; - /** - * Sets whether or not the drag box is movable. - * - * @param {boolean} movable - * @return {DragBoxLayer} The calling DragBoxLayer. - */ - movable(movable: boolean): DragBoxLayer; - /** - * Sets the callback to be called when dragging starts. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - onDragStart(callback: DragBoxCallback): DragBoxLayer; - /** - * Removes a callback to be called when dragging starts. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - offDragStart(callback: DragBoxCallback): DragBoxLayer; - /** - * Sets a callback to be called during dragging. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - onDrag(callback: DragBoxCallback): DragBoxLayer; - /** - * Removes a callback to be called during dragging. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - offDrag(callback: DragBoxCallback): DragBoxLayer; - /** - * Sets a callback to be called when dragging ends. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - onDragEnd(callback: DragBoxCallback): DragBoxLayer; - /** - * Removes a callback to be called when dragging ends. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - offDragEnd(callback: DragBoxCallback): DragBoxLayer; - /** - * Gets the internal Interactions.Drag of the DragBoxLayer. - */ - dragInteraction(): Interactions.Drag; - /** - * Enables or disables the interaction and drag box. - */ - enabled(enabled: boolean): DragBoxLayer; - /** - * Gets the enabled state. - */ - enabled(): boolean; - destroy(): void; - detach(): Component; - anchor(selection: d3.Selection): Component; - } - } -} - - -declare module Plottable { - module Components { - class XDragBoxLayer extends DragBoxLayer { - /** - * An XDragBoxLayer is a DragBoxLayer whose size can only be set in the X-direction. - * The y-values of the bounds() are always set to 0 and the height() of the XDragBoxLayer. - * - * @constructor - */ - constructor(); - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XDragBoxLayer; - protected _setBounds(newBounds: Bounds): void; - protected _setResizableClasses(canResize: boolean): void; - yScale(): QuantitativeScale; - yScale(yScale: QuantitativeScale): SelectionBoxLayer; - yExtent(): (number | { - valueOf(): number; - })[]; - yExtent(yExtent: (number | { - valueOf(): number; - })[]): SelectionBoxLayer; - } - } -} - - -declare module Plottable { - module Components { - class YDragBoxLayer extends DragBoxLayer { - /** - * A YDragBoxLayer is a DragBoxLayer whose size can only be set in the Y-direction. - * The x-values of the bounds() are always set to 0 and the width() of the YDragBoxLayer. - * - * @constructor - */ - constructor(); - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): YDragBoxLayer; - protected _setBounds(newBounds: Bounds): void; - protected _setResizableClasses(canResize: boolean): void; - xScale(): QuantitativeScale; - xScale(xScale: QuantitativeScale): SelectionBoxLayer; - xExtent(): (number | { - valueOf(): number; - })[]; - xExtent(xExtent: (number | { - valueOf(): number; - })[]): SelectionBoxLayer; - } - } -} - - -declare module Plottable { - interface DragLineCallback { - (dragLineLayer: Components.DragLineLayer): void; - } - module Components { - class DragLineLayer extends GuideLineLayer { - constructor(orientation: string); - protected _setup(): void; - renderImmediately(): DragLineLayer; - /** - * Gets the detection radius of the drag line in pixels. - */ - detectionRadius(): number; - /** - * Sets the detection radius of the drag line in pixels. - * - * @param {number} detectionRadius - * @return {DragLineLayer} The calling DragLineLayer. - */ - detectionRadius(detectionRadius: number): DragLineLayer; - /** - * Gets whether the DragLineLayer is enabled. - */ - enabled(): boolean; - /** - * Enables or disables the DragLineLayer. - * - * @param {boolean} enabled - * @return {DragLineLayer} The calling DragLineLayer. - */ - enabled(enabled: boolean): DragLineLayer; - /** - * Sets the callback to be called when dragging starts. - * The callback will be passed the calling DragLineLayer. - * - * @param {DragLineCallback} callback - * @returns {DragLineLayer} The calling DragLineLayer. - */ - onDragStart(callback: DragLineCallback): DragLineLayer; - /** - * Removes a callback that would be called when dragging starts. - * - * @param {DragLineCallback} callback - * @returns {DragLineLayer} The calling DragLineLayer. - */ - offDragStart(callback: DragLineCallback): DragLineLayer; - /** - * Sets a callback to be called during dragging. - * The callback will be passed the calling DragLineLayer. - * - * @param {DragLineCallback} callback - * @returns {DragLineLayer} The calling DragLineLayer. - */ - onDrag(callback: DragLineCallback): DragLineLayer; - /** - * Removes a callback that would be called during dragging. - * - * @param {DragLineCallback} callback - * @returns {DragLineLayer} The calling DragLineLayer. - */ - offDrag(callback: DragLineCallback): DragLineLayer; - /** - * Sets a callback to be called when dragging ends. - * The callback will be passed the calling DragLineLayer. - * - * @param {DragLineCallback} callback - * @returns {DragLineLayer} The calling DragLineLayer. - */ - onDragEnd(callback: DragLineCallback): DragLineLayer; - /** - * Removes a callback that would be called when dragging ends. - * - * @param {DragLineCallback} callback - * @returns {DragLineLayer} The calling DragLineLayer. - */ - offDragEnd(callback: DragLineCallback): DragLineLayer; - destroy(): void; - } - } -} + +declare module Plottable { + module Utils { + module Math { + /** + * Checks if x is between a and b. + * + * @param {number} x The value to test if in range + * @param {number} a The beginning of the (inclusive) range + * @param {number} b The ending of the (inclusive) range + * @return {boolean} Whether x is in [a, b] + */ + function inRange(x: number, a: number, b: number): boolean; + /** + * Clamps x to the range [min, max]. + * + * @param {number} x The value to be clamped. + * @param {number} min The minimum value. + * @param {number} max The maximum value. + * @return {number} A clamped value in the range [min, max]. + */ + function clamp(x: number, min: number, max: number): number; + /** + * Applies the accessor, if provided, to each element of `array` and returns the maximum value. + * If no maximum value can be computed, returns defaultValue. + */ + function max(array: C[], defaultValue: C): C; + function max(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; + /** + * Applies the accessor, if provided, to each element of `array` and returns the minimum value. + * If no minimum value can be computed, returns defaultValue. + */ + function min(array: C[], defaultValue: C): C; + function min(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; + /** + * Returns true **only** if x is NaN + */ + function isNaN(n: any): boolean; + /** + * Returns true if the argument is a number, which is not NaN + * Numbers represented as strings do not pass this function + */ + function isValidNumber(n: any): boolean; + /** + * Generates an array of consecutive, strictly increasing numbers + * in the range [start, stop) separeted by step + */ + function range(start: number, stop: number, step?: number): number[]; + /** + * Returns the square of the distance between two points + * + * @param {Point} p1 + * @param {Point} p2 + * @return {number} dist(p1, p2)^2 + */ + function distanceSquared(p1: Point, p2: Point): number; + function degreesToRadians(degree: number): number; + } + } +} + + +declare module Plottable { + module Utils { + /** + * Shim for ES6 map. + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + */ + class Map { + constructor(); + set(key: K, value: V): Map; + get(key: K): V; + has(key: K): boolean; + forEach(callbackFn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + delete(key: K): boolean; + } + } +} + + +declare module Plottable { + module Utils { + /** + * Shim for ES6 set. + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set + */ + class Set { + size: number; + constructor(); + add(value: T): Set; + delete(value: T): boolean; + has(value: T): boolean; + forEach(callback: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + } + } +} + + +declare module Plottable { + module Utils { + module DOM { + /** + * Gets the bounding box of an element. + * @param {d3.Selection} element + * @returns {SVGRed} The bounding box. + */ + function elementBBox(element: d3.Selection): SVGRect; + /** + * Screen refresh rate which is assumed to be 60fps + */ + var SCREEN_REFRESH_RATE_MILLISECONDS: number; + /** + * Polyfill for `window.requestAnimationFrame`. + * If the function exists, then we use the function directly. + * Otherwise, we set a timeout on `SCREEN_REFRESH_RATE_MILLISECONDS` and then perform the function. + * + * @param {() => void} callback The callback to call in the next animation frame + */ + function requestAnimationFramePolyfill(callback: () => void): void; + /** + * Calculates the width of the element. + * The width includes the padding and the border on the element's left and right sides. + * + * @param {Element} element The element to query + * @returns {number} The width of the element. + */ + function elementWidth(element: Element): number; + /** + * Calculates the height of the element. + * The height includes the padding the and the border on the element's top and bottom sides. + * + * @param {Element} element The element to query + * @returns {number} The height of the element + */ + function elementHeight(element: Element): number; + /** + * Retrieves the number array representing the translation for the selection + * + * @param {d3.Selection} selection The selection to query + * @returns {[number, number]} The number array representing the translation + */ + function translate(selection: d3.Selection): [number, number]; + /** + * Translates the given selection by the input x / y pixel amounts. + * + * @param {d3.Selection} selection The selection to translate + * @param {number} x The amount to translate in the x direction + * @param {number} y The amount to translate in the y direction + * @returns {d3.Selection} The input selection + */ + function translate(selection: d3.Selection, x: number, y: number): d3.Selection; + /** + * Checks if the first ClientRect overlaps the second. + * + * @param {ClientRect} clientRectA The first ClientRect + * @param {ClientRect} clientRectB The second ClientRect + * @returns {boolean} If the ClientRects overlap each other. + */ + function clientRectsOverlap(clientRectA: ClientRect, clientRectB: ClientRect): boolean; + /** + * Returns true if and only if innerClientRect is inside outerClientRect. + * + * @param {ClientRect} innerClientRect The first ClientRect + * @param {ClientRect} outerClientRect The second ClientRect + * @returns {boolean} If and only if the innerClientRect is inside outerClientRect. + */ + function clientRectInside(innerClientRect: ClientRect, outerClientRect: ClientRect): boolean; + /** + * Retrieves the bounding svg of the input element + * + * @param {SVGElement} element The element to query + * @returns {SVGElement} The bounding svg + */ + function boundingSVG(element: SVGElement): SVGElement; + /** + * Generates a ClipPath ID that is unique for this instance of Plottable + */ + function generateUniqueClipPathId(): string; + /** + * Returns true if the supplied coordinates or Ranges intersect or are contained by bbox. + * + * @param {number | Range} xValOrRange The x coordinate or Range to test + * @param {number | Range} yValOrRange The y coordinate or Range to test + * @param {SVGRect} bbox The bbox + * @param {number} tolerance Amount by which to expand bbox, in each dimension, before + * testing intersection + * + * @returns {boolean} True if the supplied coordinates or Ranges intersect or are + * contained by bbox, false otherwise. + */ + function intersectsBBox(xValOrRange: number | Range, yValOrRange: number | Range, bbox: SVGRect, tolerance?: number): boolean; + } + } +} + + +declare module Plottable { + module Utils { + module Color { + /** + * Return contrast ratio between two colors + * Based on implementation from chroma.js by Gregor Aisch (gka) (licensed under BSD) + * chroma.js may be found here: https://github.com/gka/chroma.js + * License may be found here: https://github.com/gka/chroma.js/blob/master/LICENSE + * see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef + */ + function contrast(a: string, b: string): number; + /** + * Returns a brighter copy of this color. Each channel is multiplied by 0.7 ^ -factor. + * Channel values are capped at the maximum value of 255, and the minimum value of 30. + */ + function lightenColor(color: string, factor: number): string; + /** + * Gets the Hex Code of the color resulting by applying the className CSS class to the + * colorTester selection. Returns null if the tester is transparent. + * + * @param {d3.Selection} colorTester The d3 selection to apply the CSS class to + * @param {string} className The name of the class to be applied + * @return {string} The hex code of the computed color + */ + function colorTest(colorTester: d3.Selection, className: string): string; + } + } +} + + +declare module Plottable { + module Utils { + module Array { + /** + * Takes two arrays of numbers and adds them together + * + * @param {number[]} aList The first array of numbers + * @param {number[]} bList The second array of numbers + * @return {number[]} An array of numbers where x[i] = aList[i] + bList[i] + */ + function add(aList: number[], bList: number[]): number[]; + /** + * Take an array of values, and return the unique values. + * Will work iff ∀ a, b, a.toString() == b.toString() => a == b; will break on Object inputs + * + * @param {T[]} values The values to find uniqueness for + * @return {T[]} The unique values + */ + function uniq(arr: T[]): T[]; + /** + * @param {T[][]} a The 2D array that will have its elements joined together. + * @return {T[]} Every array in a, concatenated together in the order they appear. + */ + function flatten(a: T[][]): T[]; + /** + * Creates an array of length `count`, filled with value or (if value is a function), value() + * + * @param {T | ((index?: number) => T)} value The value to fill the array with or a value generator (called with index as arg) + * @param {number} count The length of the array to generate + * @return {any[]} + */ + function createFilledArray(value: T | ((index?: number) => T), count: number): T[]; + } + } +} + + +declare module Plottable { + module Utils { + /** + * A set of callbacks which can be all invoked at once. + * Each callback exists at most once in the set (based on reference equality). + * All callbacks should have the same signature. + */ + class CallbackSet extends Set { + callCallbacks(...args: any[]): CallbackSet; + } + } +} + + +declare module Plottable { + module Utils { + module Stacking { + type StackedDatum = { + value: number; + offset: number; + }; + type StackingResult = Utils.Map>; + /** + * Computes the StackingResult (value and offset) for each data point in each Dataset. + * + * @param {Dataset[]} datasets The Datasets to be stacked on top of each other in the order of stacking + * @param {Accessor} keyAccessor Accessor for the key of the data + * @param {Accessor} valueAccessor Accessor for the value of the data + * @return {StackingResult} value and offset for each datapoint in each Dataset + */ + function stack(datasets: Dataset[], keyAccessor: Accessor, valueAccessor: Accessor): StackingResult; + /** + * Computes the total extent over all data points in all Datasets, taking stacking into consideration. + * + * @param {StackingResult} stackingResult The value and offset information for each datapoint in each dataset + * @oaram {Accessor} keyAccessor Accessor for the key of the data existent in the stackingResult + * @param {Accessor} filter A filter for data to be considered when computing the total extent + * @return {[number, number]} The total extent + */ + function stackedExtent(stackingResult: StackingResult, keyAccessor: Accessor, filter: Accessor): number[]; + /** + * Normalizes a key used for stacking + * + * @param {any} key The key to be normalized + * @return {string} The stringified key + */ + function normalizeKey(key: any): string; + } + } +} + + +declare module Plottable { + module Utils { + module Window { + /** + * Print a warning message to the console, if it is available. + * + * @param {string} The warnings to print + */ + function warn(warning: string): void; + /** + * Is like setTimeout, but activates synchronously if time=0 + * We special case 0 because of an observed issue where calling setTimeout causes visible flickering. + * We believe this is because when requestAnimationFrame calls into the paint function, as soon as that function finishes + * evaluating, the results are painted to the screen. As a result, if we want something to occur immediately but call setTimeout + * with time=0, then it is pushed to the call stack and rendered in the next frame, so the component that was rendered via + * setTimeout appears out-of-sync with the rest of the plot. + */ + function setTimeout(f: Function, time: number, ...args: any[]): number; + /** + * Sends a deprecation warning to the console. The warning includes the name of the deprecated method, + * version number of the deprecation, and an optional message. + * + * To be used in the first line of a deprecated method. + * + * @param {string} callingMethod The name of the method being deprecated + * @param {string} version The version when the tagged method became obsolete + * @param {string?} message Optional message to be shown with the warning + */ + function deprecated(callingMethod: string, version: string, message?: string): void; + } + } +} + + +declare module Plottable { + module Utils { + class ClientToSVGTranslator { + /** + * Returns the ClientToSVGTranslator for the containing elem. + * If one already exists on that , it will be returned; otherwise, a new one will be created. + */ + static getTranslator(elem: SVGElement): ClientToSVGTranslator; + constructor(svg: SVGElement); + /** + * Computes the position relative to the in svg-coordinate-space. + */ + computePosition(clientX: number, clientY: number): Point; + /** + * Checks whether event happened inside element. + */ + insideSVG(e: Event): boolean; + } + } +} + + +declare module Plottable { + module Configs { + /** + * Specifies if Plottable should show warnings. + */ + var SHOW_WARNINGS: boolean; + /** + * Specifies if Plottable should add elements to text. + */ + var ADD_TITLE_ELEMENTS: boolean; + } +} + + +declare module Plottable { + var version: string; +} + + +declare module Plottable { + type DatasetCallback = (dataset: Dataset) => void; + class KeyFunctions { + protected static counter: number; + static noConstancy: (d: any, i: number) => any; + static byIndex: (d: any, i: number) => any; + } + class Dataset { + /** + * A Dataset contains an array of data and some metadata. + * Changes to the data or metadata will cause anything subscribed to the Dataset to update. + * + * @constructor + * @param {any[]} [data=[]] The data for this Dataset. + * @param {any} [metadata={}] An object containing additional information. + */ + constructor(data?: any[], metadata?: any); + /** + * Adds a callback to be called when the Dataset updates. + * + * @param {DatasetCallback} callback. + * @returns {Dataset} The calling Dataset. + */ + onUpdate(callback: DatasetCallback): Dataset; + /** + * Removes a callback that would be called when the Dataset updates. + * + * @param {DatasetCallback} callback + * @returns {Dataset} The calling Dataset. + */ + offUpdate(callback: DatasetCallback): Dataset; + /** + * Gets the data. + * + * @returns {any[]} + */ + data(): any[]; + /** + * Sets the data. + * + * @param {any[]} data + * @returns {Dataset} The calling Dataset. + */ + data(data: any[]): Dataset; + /** + * Gets the metadata. + * + * @returns {any} + */ + metadata(): any; + /** + * Sets the metadata. + * + * @param {any} metadata + * @returns {Dataset} The calling Dataset. + */ + metadata(metadata: any): Dataset; + key(): (datum: any, index: number) => any; + /** + * Sets the key. + * + * @param { (d: any, i: number) => any} key + * @returns {Dataset} The calling Dataset. + */ + key(key: (datum: any, index: number) => any): Dataset; + } +} + + +declare module Plottable { + module RenderPolicies { + /** + * A policy for rendering Components. + */ + interface RenderPolicy { + render(): any; + } + /** + * Renders Components immediately after they are enqueued. + * Useful for debugging, horrible for performance. + */ + class Immediate implements RenderPolicy { + render(): void; + } + /** + * The default way to render, which only tries to render every frame + * (usually, 1/60th of a second). + */ + class AnimationFrame implements RenderPolicy { + render(): void; + } + /** + * Renders with `setTimeout()`. + * Generally an inferior way to render compared to `requestAnimationFrame`, + * but useful for browsers that don't suppoort `requestAnimationFrame`. + */ + class Timeout implements RenderPolicy { + render(): void; + } + } +} + + +declare module Plottable { + /** + * The RenderController is responsible for enqueueing and synchronizing + * layout and render calls for Components. + * + * Layout and render calls occur inside an animation callback + * (window.requestAnimationFrame if available). + * + * RenderController.flush() immediately lays out and renders all Components currently enqueued. + * + * To always have immediate rendering (useful for debugging), call + * ```typescript + * Plottable.RenderController.setRenderPolicy( + * new Plottable.RenderPolicies.Immediate() + * ); + * ``` + */ + module RenderController { + module Policy { + var IMMEDIATE: string; + var ANIMATION_FRAME: string; + var TIMEOUT: string; + } + function renderPolicy(): RenderPolicies.RenderPolicy; + function renderPolicy(renderPolicy: string): void; + /** + * Enqueues the Component for rendering. + * + * @param {Component} component + */ + function registerToRender(component: Component): void; + /** + * Enqueues the Component for layout and rendering. + * + * @param {Component} component + */ + function registerToComputeLayout(component: Component): void; + /** + * Renders all Components waiting to be rendered immediately + * instead of waiting until the next frame. + * + * Useful to call when debugging. + */ + function flush(): void; + } +} + +declare module Plottable { + /** + * Accesses a specific datum property. + */ + interface Accessor { + (datum: any, index: number, dataset: Dataset): T; + } + /** + * Retrieves a scaled datum property. + * Essentially passes the result of an Accessor through a Scale. + */ + type Projector = (datum: any, index: number, dataset: Dataset) => any; + /** + * A mapping from attributes ("x", "fill", etc.) to the functions that get + * that information out of the data. + */ + type AttributeToProjector = { + [attr: string]: Projector; + }; + /** + * A function that generates attribute values from the datum and index. + * Essentially a Projector with a particular Dataset rolled in. + */ + type AppliedProjector = (datum: any, index: number) => any; + /** + * A mapping from attributes to the AppliedProjectors used to generate them. + */ + type AttributeToAppliedProjector = { + [attr: string]: AppliedProjector; + }; + /** + * Space request used during layout negotiation. + * + * @member {number} minWidth The minimum acceptable width given the offered space. + * @member {number} minHeight the minimum acceptable height given the offered space. + */ + type SpaceRequest = { + minWidth: number; + minHeight: number; + }; + /** + * Min and max values for a particular property. + */ + type Range = { + min: number; + max: number; + }; + /** + * A location in pixel-space. + */ + type Point = { + x: number; + y: number; + }; + /** + * The corners of a box. + */ + type Bounds = { + topLeft: Point; + bottomRight: Point; + }; + /** + * An object representing a data-backed visual entity inside a Component. + */ + interface Entity { + datum: any; + position: Point; + selection: d3.Selection; + component: C; + } +} + + +declare module Plottable { + type Formatter = (d: any) => string; + /** + * This field is deprecated and will be removed in v2.0.0. + * + * The number of milliseconds between midnight one day and the next is + * not a fixed quantity. + * + * Use date.setDate(date.getDate() + number_of_days) instead. + * + */ + var MILLISECONDS_IN_ONE_DAY: number; + module Formatters { + /** + * Creates a formatter for currency values. + * + * @param {number} [precision] The number of decimal places to show (default 2). + * @param {string} [symbol] The currency symbol to use (default "$"). + * @param {boolean} [prefix] Whether to prepend or append the currency symbol (default true). + * + * @returns {Formatter} A formatter for currency values. + */ + function currency(precision?: number, symbol?: string, prefix?: boolean): (d: any) => string; + /** + * Creates a formatter that displays exactly [precision] decimal places. + * + * @param {number} [precision] The number of decimal places to show (default 3). + * + * @returns {Formatter} A formatter that displays exactly [precision] decimal places. + */ + function fixed(precision?: number): (d: any) => string; + /** + * Creates a formatter that formats numbers to show no more than + * [maxNumberOfDecimalPlaces] decimal places. All other values are stringified. + * + * @param {number} [maxNumberOfDecimalPlaces] The number of decimal places to show (default 3). + * + * @returns {Formatter} A formatter for general values. + */ + function general(maxNumberOfDecimalPlaces?: number): (d: any) => string; + /** + * Creates a formatter that stringifies its input. + * + * @returns {Formatter} A formatter that stringifies its input. + */ + function identity(): (d: any) => string; + /** + * Creates a formatter for percentage values. + * Multiplies the input by 100 and appends "%". + * + * @param {number} [precision] The number of decimal places to show (default 0). + * + * @returns {Formatter} A formatter for percentage values. + */ + function percentage(precision?: number): (d: any) => string; + /** + * Creates a formatter for values that displays [numberOfSignificantFigures] significant figures + * and puts SI notation. + * + * @param {number} [numberOfSignificantFigures] The number of significant figures to show (default 3). + * + * @returns {Formatter} A formatter for SI values. + */ + function siSuffix(numberOfSignificantFigures?: number): (d: any) => string; + /** + * Creates a formatter for values that displays abbreviated values + * and uses standard short scale suffixes + * - K - thousands - 10 ^ 3 + * - M - millions - 10 ^ 6 + * - B - billions - 10 ^ 9 + * - T - trillions - 10 ^ 12 + * - Q - quadrillions - 10 ^ 15 + * + * Numbers with a magnitude outside of (10 ^ (-precision), 10 ^ 15) are shown using + * scientific notation to avoid creating extremely long decimal strings. + * + * @param {number} [precision] the number of decimal places to show (default 3) + * @returns {Formatter} A formatter with short scale formatting + */ + function shortScale(precision?: number): (num: number) => string; + /** + * Creates a multi time formatter that displays dates. + * + * @returns {Formatter} A formatter for time/date values. + */ + function multiTime(): (d: any) => string; + /** + * Creates a time formatter that displays time/date using given specifier. + * + * List of directives can be found on: https://github.com/mbostock/d3/wiki/Time-Formatting#format + * + * @param {string} [specifier] The specifier for the formatter. + * + * @returns {Formatter} A formatter for time/date values. + */ + function time(specifier: string): Formatter; + /** + * @deprecated As of release v1.3.0, not safe for use with time zones. + * + * Creates a formatter for relative dates. + * + * @param {number} baseValue The start date (as epoch time) used in computing relative dates (default 0) + * @param {number} increment The unit used in calculating relative date values (default MILLISECONDS_IN_ONE_DAY) + * @param {string} label The label to append to the formatted string (default "") + * + * @returns {Formatter} A formatter for time/date values. + */ + function relativeDate(baseValue?: number, increment?: number, label?: string): (d: any) => string; + } +} + + +declare module Plottable { + /** + * A SymbolFactory is a function that takes in a symbolSize which is the edge length of the render area + * and returns a string representing the 'd' attribute of the resultant 'path' element + */ + type SymbolFactory = (symbolSize: number) => string; + module SymbolFactories { + function circle(): SymbolFactory; + function square(): SymbolFactory; + function cross(): SymbolFactory; + function diamond(): SymbolFactory; + function triangleUp(): SymbolFactory; + function triangleDown(): SymbolFactory; + } +} + + +declare module Plottable { + interface ScaleCallback> { + (scale: S): any; + } + module Scales { + /** + * A function that supplies domain values to be included into a Scale. + * + * @param {Scale} scale + * @returns {D[]} An array of values that should be included in the Scale. + */ + interface IncludedValuesProvider { + (scale: Scale): D[]; + } + /** + * A function that supplies padding exception values for the Scale. + * If one end of the domain is set to an excepted value as a result of autoDomain()-ing, + * that end of the domain will not be padded. + * + * @param {QuantitativeScale} scale + * @returns {D[]} An array of values that should not be padded. + */ + interface PaddingExceptionsProvider { + (scale: QuantitativeScale): D[]; + } + } + class Scale { + /** + * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. + * + * @constructor + */ + constructor(); + /** + * Given an array of potential domain values, computes the extent of those values. + * + * @param {D[]} values + * @returns {D[]} The extent of the input values. + */ + extentOfValues(values: D[]): D[]; + protected _getAllIncludedValues(): D[]; + protected _getExtent(): D[]; + /** + * Adds a callback to be called when the Scale updates. + * + * @param {ScaleCallback} callback. + * @returns {Scale} The calling Scale. + */ + onUpdate(callback: ScaleCallback>): Scale; + /** + * Removes a callback that would be called when the Scale updates. + * + * @param {ScaleCallback} callback. + * @returns {Scale} The calling Scale. + */ + offUpdate(callback: ScaleCallback>): Scale; + protected _dispatchUpdate(): void; + /** + * Sets the Scale's domain so that it spans the Extents of all its ExtentsProviders. + * + * @returns {Scale} The calling Scale. + */ + autoDomain(): Scale; + protected _autoDomainIfAutomaticMode(): void; + /** + * Computes the range value corresponding to a given domain value. + * + * @param {D} value + * @returns {R} The range value corresponding to the supplied domain value. + */ + scale(value: D): R; + /** + * Gets the domain. + * + * @returns {D[]} The current domain. + */ + domain(): D[]; + /** + * Sets the domain. + * + * @param {D[]} values + * @returns {Scale} The calling Scale. + */ + domain(values: D[]): Scale; + protected _getDomain(): void; + protected _setDomain(values: D[]): void; + protected _setBackingScaleDomain(values: D[]): void; + /** + * Gets the range. + * + * @returns {R[]} The current range. + */ + range(): R[]; + /** + * Sets the range. + * + * @param {R[]} values + * @returns {Scale} The calling Scale. + */ + range(values: R[]): Scale; + protected _getRange(): void; + protected _setRange(values: R[]): void; + /** + * Adds an IncludedValuesProvider to the Scale. + * + * @param {Scales.IncludedValuesProvider} provider + * @returns {Scale} The calling Scale. + */ + addIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; + /** + * Removes the IncludedValuesProvider from the Scale. + * + * @param {Scales.IncludedValuesProvider} provider + * @returns {Scale} The calling Scale. + */ + removeIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; + } +} + + +declare module Plottable { + class QuantitativeScale extends Scale { + protected static _DEFAULT_NUM_TICKS: number; + /** + * A QuantitativeScale is a Scale that maps number-like values to numbers. + * It is invertible and continuous. + * + * @constructor + */ + constructor(); + autoDomain(): QuantitativeScale; + protected _autoDomainIfAutomaticMode(): void; + protected _getExtent(): D[]; + /** + * Adds a padding exception provider. + * If one end of the domain is set to an excepted value as a result of autoDomain()-ing, + * that end of the domain will not be padded. + * + * @param {Scales.PaddingExceptionProvider} provider The provider function. + * @returns {QuantitativeScale} The calling QuantitativeScale. + */ + addPaddingExceptionsProvider(provider: Scales.PaddingExceptionsProvider): QuantitativeScale; + /** + * Removes the padding exception provider. + * + * @param {Scales.PaddingExceptionProvider} provider The provider function. + * @returns {QuantitativeScale} The calling QuantitativeScale. + */ + removePaddingExceptionsProvider(provider: Scales.PaddingExceptionsProvider): QuantitativeScale; + /** + * Gets the padding proportion. + */ + padProportion(): number; + /** + * Sets the padding porportion. + * When autoDomain()-ing, the computed domain will be expanded by this proportion, + * then rounded to human-readable values. + * + * @param {number} padProportion The padding proportion. Passing 0 disables padding. + * @returns {QuantitativeScale} The calling QuantitativeScale. + */ + padProportion(padProportion: number): QuantitativeScale; + /** + * Gets whether or not the scale snaps its domain to nice values. + */ + snappingDomainEnabled(): boolean; + /** + * Sets whether or not the scale snaps its domain to nice values. + */ + snappingDomainEnabled(snappingDomainEnabled: boolean): QuantitativeScale; + protected _expandSingleValueDomain(singleValueDomain: D[]): D[]; + /** + * Computes the domain value corresponding to a supplied range value. + * + * @param {number} value: A value from the Scale's range. + * @returns {D} The domain value corresponding to the supplied range value. + */ + invert(value: number): D; + domain(): D[]; + domain(values: D[]): QuantitativeScale; + /** + * Gets the lower end of the domain. + * + * @return {D} + */ + domainMin(): D; + /** + * Sets the lower end of the domain. + * + * @return {QuantitativeScale} The calling QuantitativeScale. + */ + domainMin(domainMin: D): QuantitativeScale; + /** + * Gets the upper end of the domain. + * + * @return {D} + */ + domainMax(): D; + /** + * Sets the upper end of the domain. + * + * @return {QuantitativeScale} The calling QuantitativeScale. + */ + domainMax(domainMax: D): QuantitativeScale; + extentOfValues(values: D[]): D[]; + protected _setDomain(values: D[]): void; + /** + * Gets the array of tick values generated by the default algorithm. + */ + defaultTicks(): D[]; + /** + * Gets an array of tick values spanning the domain. + * + * @returns {D[]} + */ + ticks(): D[]; + /** + * Given a domain, expands its domain onto "nice" values, e.g. whole + * numbers. + */ + protected _niceDomain(domain: D[], count?: number): D[]; + protected _defaultExtent(): D[]; + /** + * Gets the TickGenerator. + */ + tickGenerator(): Scales.TickGenerators.TickGenerator; + /** + * Sets the TickGenerator + * + * @param {TickGenerator} generator + * @return {QuantitativeScale} The calling QuantitativeScale. + */ + tickGenerator(generator: Scales.TickGenerators.TickGenerator): QuantitativeScale; + } +} + + +declare module Plottable { + module Scales { + class Linear extends QuantitativeScale { + /** + * @constructor + */ + constructor(); + protected _defaultExtent(): number[]; + protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; + scale(value: number): number; + protected _getDomain(): number[]; + protected _setBackingScaleDomain(values: number[]): void; + protected _getRange(): number[]; + protected _setRange(values: number[]): void; + invert(value: number): number; + defaultTicks(): number[]; + protected _niceDomain(domain: number[], count?: number): number[]; + } + } +} + + +declare module Plottable { + module Scales { + class ModifiedLog extends QuantitativeScale { + /** + * A ModifiedLog Scale acts as a regular log scale for large numbers. + * As it approaches 0, it gradually becomes linear. + * Consequently, a ModifiedLog Scale can process 0 and negative numbers. + * + * @constructor + * @param {number} [base=10] + * The base of the log. Must be > 1. + * + * For x <= base, scale(x) = log(x). + * + * For 0 < x < base, scale(x) will become more and more + * linear as it approaches 0. + * + * At x == 0, scale(x) == 0. + * + * For negative values, scale(-x) = -scale(x). + */ + constructor(base?: number); + /** + * Returns an adjusted log10 value for graphing purposes. The first + * adjustment is that negative values are changed to positive during + * the calculations, and then the answer is negated at the end. The + * second is that, for values less than 10, an increasingly large + * (0 to 1) scaling factor is added such that at 0 the value is + * adjusted to 1, resulting in a returned result of 0. + */ + scale(x: number): number; + invert(x: number): number; + protected _getDomain(): number[]; + protected _setDomain(values: number[]): void; + protected _setBackingScaleDomain(values: number[]): void; + ticks(): number[]; + /** + * Return an appropriate number of ticks from lower to upper. + * + * This will first try to fit as many powers of this.base as it can from + * lower to upper. + * + * If it still has ticks after that, it will generate ticks in "clusters", + * e.g. [20, 30, ... 90, 100] would be a cluster, [200, 300, ... 900, 1000] + * would be another cluster. + * + * This function will generate clusters as large as it can while not + * drastically exceeding its number of ticks. + */ + /** + * How many ticks does the range [lower, upper] deserve? + * + * e.g. if your domain was [10, 1000] and I asked _howManyTicks(10, 100), + * I would get 1/2 of the ticks. The range 10, 100 takes up 1/2 of the + * distance when plotted. + */ + protected _niceDomain(domain: number[], count?: number): number[]; + protected _defaultExtent(): number[]; + protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; + protected _getRange(): number[]; + protected _setRange(values: number[]): void; + defaultTicks(): number[]; + } + } +} + + +declare module Plottable { + module Scales { + class Category extends Scale { + /** + * A Category Scale maps strings to numbers. + * + * @constructor + */ + constructor(); + extentOfValues(values: string[]): string[]; + protected _getExtent(): string[]; + domain(): string[]; + domain(values: string[]): Category; + protected _setDomain(values: string[]): void; + range(): [number, number]; + range(values: [number, number]): Category; + /** + * Returns the width of the range band. + * + * @returns {number} The range band width + */ + rangeBand(): number; + /** + * Returns the step width of the scale. + * + * The step width is the pixel distance between adjacent values in the domain. + * + * @returns {number} + */ + stepWidth(): number; + /** + * Gets the inner padding. + * + * The inner padding is defined as the padding in between bands on the scale, + * expressed as a multiple of the rangeBand(). + * + * @returns {number} + */ + innerPadding(): number; + /** + * Sets the inner padding. + * + * The inner padding is defined as the padding in between bands on the scale, + * expressed as a multiple of the rangeBand(). + * + * @returns {Category} The calling Category Scale. + */ + innerPadding(innerPadding: number): Category; + /** + * Gets the outer padding. + * + * The outer padding is the padding in between the outer bands and the edges of the range, + * expressed as a multiple of the rangeBand(). + * + * @returns {number} + */ + outerPadding(): number; + /** + * Sets the outer padding. + * + * The outer padding is the padding in between the outer bands and the edges of the range, + * expressed as a multiple of the rangeBand(). + * + * @returns {Category} The calling Category Scale. + */ + outerPadding(outerPadding: number): Category; + scale(value: string): number; + protected _getDomain(): string[]; + protected _setBackingScaleDomain(values: string[]): void; + protected _getRange(): number[]; + protected _setRange(values: number[]): void; + } + } +} + + +declare module Plottable { + module Scales { + class Color extends Scale { + /** + * A Color Scale maps string values to color hex values expressed as a string. + * + * @constructor + * @param {string} [scaleType] One of "Category10"/"Category20"/"Category20b"/"Category20c". + * (see https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors) + * If not supplied, reads the colors defined using CSS -- see plottable.css. + */ + constructor(scaleType?: string); + extentOfValues(values: string[]): string[]; + protected _getExtent(): string[]; + static invalidateColorCache(): void; + /** + * Returns the color-string corresponding to a given string. + * If there are not enough colors in the range(), a lightened version of an existing color will be used. + * + * @param {string} value + * @returns {string} + */ + scale(value: string): string; + protected _getDomain(): string[]; + protected _setBackingScaleDomain(values: string[]): void; + protected _getRange(): string[]; + protected _setRange(values: string[]): void; + } + } +} + + +declare module Plottable { + module Scales { + class Time extends QuantitativeScale { + /** + * A Time Scale maps Date objects to numbers. + * + * @constructor + */ + constructor(); + /** + * Returns an array of ticks values separated by the specified interval. + * + * @param {string} interval A string specifying the interval unit. + * @param {number?} [step] The number of multiples of the interval between consecutive ticks. + * @return {Date[]} + */ + tickInterval(interval: string, step?: number): Date[]; + protected _setDomain(values: Date[]): void; + protected _defaultExtent(): Date[]; + protected _expandSingleValueDomain(singleValueDomain: Date[]): Date[]; + scale(value: Date): number; + protected _getDomain(): Date[]; + protected _setBackingScaleDomain(values: Date[]): void; + protected _getRange(): number[]; + protected _setRange(values: number[]): void; + invert(value: number): Date; + defaultTicks(): Date[]; + protected _niceDomain(domain: Date[]): Date[]; + /** + * Transforms the Plottable TimeInterval string into a d3 time interval equivalent. + * If the provided TimeInterval is incorrect, the default is d3.time.year + */ + static timeIntervalToD3Time(timeInterval: string): d3.time.Interval; + } + } +} + + +declare module Plottable { + module Scales { + class InterpolatedColor extends Scale { + static REDS: string[]; + static BLUES: string[]; + static POSNEG: string[]; + /** + * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. + * + * @param {string} [scaleType="linear"] One of "linear"/"log"/"sqrt"/"pow". + */ + constructor(scaleType?: string); + extentOfValues(values: number[]): number[]; + /** + * Generates the converted QuantitativeScale. + */ + /** + * Generates the d3 interpolator for colors. + */ + autoDomain(): InterpolatedColor; + scale(value: number): string; + protected _getDomain(): number[]; + protected _setBackingScaleDomain(values: number[]): void; + protected _getRange(): string[]; + protected _setRange(range: string[]): void; + } + } +} + + +declare module Plottable { + module Scales { + module TickGenerators { + /** + * Generates an array of tick values for the specified scale. + * + * @param {QuantitativeScale} scale + * @returns {D[]} + */ + interface TickGenerator { + (scale: Plottable.QuantitativeScale): D[]; + } + /** + * Creates a TickGenerator using the specified interval. + * + * Generates ticks at multiples of the interval while also including the domain boundaries. + * + * @param {number} interval + * @returns {TickGenerator} + */ + function intervalTickGenerator(interval: number): TickGenerator; + /** + * Creates a TickGenerator returns only integer tick values. + * + * @returns {TickGenerator} + */ + function integerTickGenerator(): TickGenerator; + } + } +} + + +declare module Plottable { + module Drawers { + /** + * A step for the drawer to draw. + * + * Specifies how AttributeToProjector needs to be animated. + */ + type DrawStep = { + attrToProjector: AttributeToProjector; + animator: Animator; + }; + /** + * A DrawStep that carries an AttributeToAppliedProjector map. + */ + type AppliedDrawStep = { + attrToAppliedProjector: AttributeToAppliedProjector; + animator: Animator; + }; + } + class Drawer { + protected _svgElementName: string; + protected _className: string; + /** + * A Drawer draws svg elements based on the input Dataset. + * + * @constructor + * @param {Dataset} dataset The dataset associated with this Drawer + */ + constructor(dataset: Dataset); + /** + * Retrieves the renderArea selection for the Drawer. + */ + renderArea(): d3.Selection; + /** + * Sets the renderArea selection for the Drawer. + * + * @param {d3.Selection} Selection containing the to render to. + * @returns {Drawer} The calling Drawer. + */ + renderArea(area: d3.Selection): Drawer; + /** + * Removes the Drawer and its renderArea + */ + remove(): void; + /** + * Binds data to selection + * + * @param{any[]} data The data to be drawn + */ + protected _applyDefaultAttributes(selection: d3.Selection): void; + /** + * Draws data using one step + * + * @param{AppliedDrawStep} step The step, how data should be drawn. + */ + /** + * Calculates the total time it takes to use the input drawSteps to draw the input data + * + * @param {any[]} data The data that would have been drawn + * @param {Drawers.DrawStep[]} drawSteps The DrawSteps to use + * @returns {number} The total time it takes to draw + */ + totalDrawTime(data: any[], drawSteps: Drawers.DrawStep[]): number; + /** + * Draws the data into the renderArea using the spefic steps and metadata + * + * @param{any[]} data The data to be drawn + * @param{DrawStep[]} drawSteps The list of steps, which needs to be drawn + */ + draw(data: any[], drawSteps: Drawers.DrawStep[]): Drawer; + selection(): d3.Selection; + /** + * Returns the CSS selector for this Drawer's visual elements. + */ + selector(): string; + /** + * Returns the D3 selection corresponding to the datum with the specified index. + */ + selectionForIndex(index: number): d3.Selection; + } +} + + +declare module Plottable { + module Drawers { + class Line extends Drawer { + constructor(dataset: Dataset); + protected _applyDefaultAttributes(selection: d3.Selection): void; + selectionForIndex(index: number): d3.Selection; + } + } +} + + +declare module Plottable { + module Drawers { + class Area extends Drawer { + constructor(dataset: Dataset); + protected _applyDefaultAttributes(selection: d3.Selection): void; + selectionForIndex(index: number): d3.Selection; + } + } +} + + +declare module Plottable { + module Drawers { + class Rectangle extends Drawer { + constructor(dataset: Dataset); + } + } +} + + +declare module Plottable { + module Drawers { + class Arc extends Drawer { + constructor(dataset: Dataset); + protected _applyDefaultAttributes(selection: d3.Selection): void; + } + } +} + + +declare module Plottable { + module Drawers { + class ArcOutline extends Drawer { + constructor(dataset: Dataset); + protected _applyDefaultAttributes(selection: d3.Selection): void; + } + } +} + + +declare module Plottable { + module Drawers { + class Symbol extends Drawer { + constructor(dataset: Dataset); + } + } +} + + +declare module Plottable { + module Drawers { + class Segment extends Drawer { + constructor(dataset: Dataset); + } + } +} + + +declare module Plottable { + type ComponentCallback = (component: Component) => void; + module Components { + class Alignment { + static TOP: string; + static BOTTOM: string; + static LEFT: string; + static RIGHT: string; + static CENTER: string; + } + } + class Component { + protected _boundingBox: d3.Selection; + protected _clipPathEnabled: boolean; + protected _isSetup: boolean; + protected _isAnchored: boolean; + constructor(); + /** + * Attaches the Component as a child of a given d3 Selection. + * + * @param {d3.Selection} selection. + * @returns {Component} The calling Component. + */ + anchor(selection: d3.Selection): Component; + /** + * Adds a callback to be called on anchoring the Component to the DOM. + * If the Component is already anchored, the callback is called immediately. + * + * @param {ComponentCallback} callback + * @return {Component} + */ + onAnchor(callback: ComponentCallback): Component; + /** + * Removes a callback that would be called on anchoring the Component to the DOM. + * The callback is identified by reference equality. + * + * @param {ComponentCallback} callback + * @return {Component} + */ + offAnchor(callback: ComponentCallback): Component; + /** + * Creates additional elements as necessary for the Component to function. + * Called during anchor() if the Component's element has not been created yet. + * Override in subclasses to provide additional functionality. + */ + protected _setup(): void; + /** + * Given available space in pixels, returns the minimum width and height this Component will need. + * + * @param {number} availableWidth + * @param {number} availableHeight + * @returns {SpaceRequest} + */ + requestedSpace(availableWidth: number, availableHeight: number): SpaceRequest; + /** + * Computes and sets the size, position, and alignment of the Component from the specified values. + * If no parameters are supplied and the Component is a root node, + * they are inferred from the size of the Component's element. + * + * @param {Point} [origin] Origin of the space offered to the Component. + * @param {number} [availableWidth] Available width in pixels. + * @param {number} [availableHeight] Available height in pixels. + * @returns {Component} The calling Component. + */ + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Component; + protected _sizeFromOffer(availableWidth: number, availableHeight: number): { + width: number; + height: number; + }; + /** + * Queues the Component for rendering. + * + * @returns {Component} The calling Component. + */ + render(): Component; + /** + * Renders the Component without waiting for the next frame. + */ + renderImmediately(): Component; + /** + * Causes the Component to re-layout and render. + * + * This function should be called when a CSS change has occured that could + * influence the layout of the Component, such as changing the font size. + * + * @returns {Component} The calling Component. + */ + redraw(): Component; + /** + * Renders the Component to a given . + * + * @param {String|d3.Selection} element A selector-string for the , or a d3 selection containing an . + * @returns {Component} The calling Component. + */ + renderTo(element: String | Element | d3.Selection): Component; + /** + * Gets the x alignment of the Component. + */ + xAlignment(): string; + /** + * Sets the x alignment of the Component. + * + * @param {string} xAlignment The x alignment of the Component ("left"/"center"/"right"). + * @returns {Component} The calling Component. + */ + xAlignment(xAlignment: string): Component; + /** + * Gets the y alignment of the Component. + */ + yAlignment(): string; + /** + * Sets the y alignment of the Component. + * + * @param {string} yAlignment The y alignment of the Component ("top"/"center"/"bottom"). + * @returns {Component} The calling Component. + */ + yAlignment(yAlignment: string): Component; + /** + * Checks if the Component has a given CSS class. + * + * @param {string} cssClass The CSS class to check for. + */ + hasClass(cssClass: string): boolean; + /** + * Adds a given CSS class to the Component. + * + * @param {string} cssClass The CSS class to add. + * @returns {Component} The calling Component. + */ + addClass(cssClass: string): Component; + /** + * Removes a given CSS class from the Component. + * + * @param {string} cssClass The CSS class to remove. + * @returns {Component} The calling Component. + */ + removeClass(cssClass: string): Component; + /** + * Checks if the Component has a fixed width or if it grows to fill available space. + * Returns false by default on the base Component class. + */ + fixedWidth(): boolean; + /** + * Checks if the Component has a fixed height or if it grows to fill available space. + * Returns false by default on the base Component class. + */ + fixedHeight(): boolean; + /** + * Detaches a Component from the DOM. The Component can be reused. + * + * This should only be used if you plan on reusing the calling Component. Otherwise, use destroy(). + * + * @returns The calling Component. + */ + detach(): Component; + /** + * Adds a callback to be called when the Component is detach()-ed. + * + * @param {ComponentCallback} callback + * @return {Component} The calling Component. + */ + onDetach(callback: ComponentCallback): Component; + /** + * Removes a callback to be called when the Component is detach()-ed. + * The callback is identified by reference equality. + * + * @param {ComponentCallback} callback + * @return {Component} The calling Component. + */ + offDetach(callback: ComponentCallback): Component; + /** + * Gets the parent ComponentContainer for this Component. + */ + parent(): ComponentContainer; + /** + * Sets the parent ComponentContainer for this Component. + * An error will be thrown if the parent does not contain this Component. + * Adding a Component to a ComponentContainer should be done + * using the appropriate method on the ComponentContainer. + */ + parent(parent: ComponentContainer): Component; + /** + * Removes a Component from the DOM and disconnects all listeners. + */ + destroy(): void; + /** + * Gets the width of the Component in pixels. + */ + width(): number; + /** + * Gets the height of the Component in pixels. + */ + height(): number; + /** + * Gets the origin of the Component relative to its parent. + * + * @return {Point} + */ + origin(): Point; + /** + * Gets the origin of the Component relative to the root . + * + * @return {Point} + */ + originToSVG(): Point; + /** + * Gets the Selection containing the in front of the visual elements of the Component. + * + * Will return undefined if the Component has not been anchored. + * + * @return {d3.Selection} + */ + foreground(): d3.Selection; + /** + * Gets a Selection containing a that holds the visual elements of the Component. + * + * Will return undefined if the Component has not been anchored. + * + * @return {d3.Selection} content selection for the Component + */ + content(): d3.Selection; + /** + * Gets the Selection containing the behind the visual elements of the Component. + * + * Will return undefined if the Component has not been anchored. + * + * @return {d3.Selection} background selection for the Component + */ + background(): d3.Selection; + } +} + + +declare module Plottable { + class ComponentContainer extends Component { + constructor(); + anchor(selection: d3.Selection): ComponentContainer; + render(): ComponentContainer; + /** + * Checks whether the specified Component is in the ComponentContainer. + */ + has(component: Component): boolean; + protected _adoptAndAnchor(component: Component): void; + /** + * Removes the specified Component from the ComponentContainer. + */ + remove(component: Component): ComponentContainer; + /** + * Carry out the actual removal of a Component. + * Implementation dependent on the type of container. + * + * @return {boolean} true if the Component was successfully removed, false otherwise. + */ + protected _remove(component: Component): boolean; + /** + * Invokes a callback on each Component in the ComponentContainer. + */ + protected _forEach(callback: (component: Component) => void): void; + /** + * Destroys the ComponentContainer and all Components within it. + */ + destroy(): void; + } +} + + +declare module Plottable { + module Components { + class Group extends ComponentContainer { + /** + * Constructs a Group. + * + * A Group contains Components that will be rendered on top of each other. + * Components added later will be rendered above Components already in the Group. + * + * @constructor + * @param {Component[]} [components=[]] Components to be added to the Group. + */ + constructor(components?: Component[]); + protected _forEach(callback: (component: Component) => any): void; + /** + * Checks whether the specified Component is in the Group. + */ + has(component: Component): boolean; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Group; + protected _sizeFromOffer(availableWidth: number, availableHeight: number): { + width: number; + height: number; + }; + fixedWidth(): boolean; + fixedHeight(): boolean; + /** + * @return {Component[]} The Components in this Group. + */ + components(): Component[]; + /** + * Adds a Component to this Group. + * The added Component will be rendered above Components already in the Group. + */ + append(component: Component): Group; + protected _remove(component: Component): boolean; + } + } +} + + +declare module Plottable { + class Axis extends Component { + /** + * The css class applied to each end tick mark (the line on the end tick). + */ + static END_TICK_MARK_CLASS: string; + /** + * The css class applied to each tick mark (the line on the tick). + */ + static TICK_MARK_CLASS: string; + /** + * The css class applied to each tick label (the text associated with the tick). + */ + static TICK_LABEL_CLASS: string; + /** + * The css class applied to each annotation line, which extends from the axis to the rect. + */ + static ANNOTATION_LINE_CLASS: string; + /** + * The css class applied to each annotation rect, which surrounds the annotation label. + */ + static ANNOTATION_RECT_CLASS: string; + /** + * The css class applied to each annotation circle, which denotes which tick is being annotated. + */ + static ANNOTATION_CIRCLE_CLASS: string; + /** + * The css class applied to each annotation label, which shows the formatted annotation text. + */ + static ANNOTATION_LABEL_CLASS: string; + protected _tickMarkContainer: d3.Selection; + protected _tickLabelContainer: d3.Selection; + protected _baseline: d3.Selection; + protected _scale: Scale; + protected _computedWidth: number; + protected _computedHeight: number; + /** + * Constructs an Axis. + * An Axis is a visual representation of a Scale. + * + * @constructor + * @param {Scale} scale + * @param {string} orientation One of "top"/"bottom"/"left"/"right". + */ + constructor(scale: Scale, orientation: string); + destroy(): void; + protected _isHorizontal(): boolean; + protected _computeWidth(): number; + protected _computeHeight(): number; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + fixedHeight(): boolean; + fixedWidth(): boolean; + protected _rescale(): void; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; + protected _setup(): void; + protected _getTickValues(): D[]; + renderImmediately(): Axis; + /** + * Gets the annotated ticks. + */ + annotatedTicks(): D[]; + /** + * Sets the annotated ticks. + * + * @returns {Axis} The calling Axis. + */ + annotatedTicks(annotatedTicks: D[]): Axis; + /** + * Gets the Formatter for the annotations. + */ + annotationFormatter(): Formatter; + /** + * Sets the Formatter for the annotations. + * + * @returns {Axis} The calling Axis. + */ + annotationFormatter(annotationFormatter: Formatter): Axis; + /** + * Gets if annotations are enabled. + */ + annotationsEnabled(): boolean; + /** + * Sets if annotations are enabled. + * + * @returns {Axis} The calling Axis. + */ + annotationsEnabled(annotationsEnabled: boolean): Axis; + /** + * Gets the count of annotation tiers to render. + */ + annotationTierCount(): number; + /** + * Sets the count of annotation tiers to render. + * + * @returns {Axis} The calling Axis. + */ + annotationTierCount(annotationTierCount: number): Axis; + protected _drawAnnotations(): void; + /** + * Retrieves the size of the core pieces. + * + * The core pieces include the labels, the end tick marks, the inner tick marks, and the tick label padding. + */ + protected _coreSize(): number; + protected _annotationTierHeight(): number; + protected _removeAnnotations(): void; + protected _generateBaselineAttrHash(): { + [key: string]: number; + }; + protected _generateTickMarkAttrHash(isEndTickMark?: boolean): { + [key: string]: number | ((d: any) => number); + }; + redraw(): Component; + protected _setDefaultAlignment(): void; + /** + * Gets the Formatter on the Axis. Tick values are passed through the + * Formatter before being displayed. + */ + formatter(): Formatter; + /** + * Sets the Formatter on the Axis. Tick values are passed through the + * Formatter before being displayed. + * + * @param {Formatter} formatter + * @returns {Axis} The calling Axis. + */ + formatter(formatter: Formatter): Axis; + /** + * @deprecated As of release v1.3.0, replaced by innerTickLength() + * + * Gets the tick mark length in pixels. + */ + tickLength(): number; + /** + * Sets the tick mark length in pixels. + * + * @param {number} length + * @returns {Axis} The calling Axis. + */ + tickLength(length: number): Axis; + /** + * Gets the tick mark length in pixels. + */ + innerTickLength(): number; + /** + * Sets the tick mark length in pixels. + * + * @param {number} length + * @returns {Axis} The calling Axis. + */ + innerTickLength(length: number): Axis; + /** + * Gets the end tick mark length in pixels. + */ + endTickLength(): number; + /** + * Sets the end tick mark length in pixels. + * + * @param {number} length + * @returns {Axis} The calling Axis. + */ + endTickLength(length: number): Axis; + protected _maxLabelTickLength(): number; + /** + * Gets the padding between each tick mark and its associated label in pixels. + */ + tickLabelPadding(): number; + /** + * Sets the padding between each tick mark and its associated label in pixels. + * + * @param {number} padding + * @returns {Axis} The calling Axis. + */ + tickLabelPadding(padding: number): Axis; + /** + * Gets the margin in pixels. + * The margin is the amount of space between the tick labels and the outer edge of the Axis. + * The margin also determines the space that annotations will reside in if annotations are enabled. + */ + margin(): number; + /** + * Sets the margin in pixels. + * The margin is the amount of space between the tick labels and the outer edge of the Axis. + * The margin also determines the space that annotations will reside in if annotations are enabled. + * + * @param {number} size + * @returns {Axis} The calling Axis. + */ + margin(size: number): Axis; + /** + * Gets the orientation of the Axis. + */ + orientation(): string; + /** + * Sets the orientation of the Axis. + * + * @param {number} orientation One of "top"/"bottom"/"left"/"right". + * @returns {Axis} The calling Axis. + */ + orientation(orientation: string): Axis; + /** + * Gets whether the Axis shows the end tick labels. + */ + showEndTickLabels(): boolean; + /** + * Sets whether the Axis shows the end tick labels. + * + * @param {boolean} show + * @returns {Axis} The calling Axis. + */ + showEndTickLabels(show: boolean): Axis; + } +} + + +declare module Plottable { + module TimeInterval { + var second: string; + var minute: string; + var hour: string; + var day: string; + var week: string; + var month: string; + var year: string; + } + module Axes { + /** + * Defines a configuration for a Time Axis tier. + * For details on how ticks are generated see: https://github.com/mbostock/d3/wiki/Time-Scales#ticks + * interval - A time unit associated with this configuration (seconds, minutes, hours, etc). + * step - number of intervals between each tick. + * formatter - formatter used to format tick labels. + */ + type TimeAxisTierConfiguration = { + interval: string; + step: number; + formatter: Formatter; + }; + /** + * An array of linked TimeAxisTierConfigurations. + * Each configuration will be shown on a different tier. + * Currently, up to two tiers are supported. + */ + type TimeAxisConfiguration = TimeAxisTierConfiguration[]; + class Time extends Axis { + /** + * The CSS class applied to each Time Axis tier + */ + static TIME_AXIS_TIER_CLASS: string; + /** + * Constructs a Time Axis. + * + * A Time Axis is a visual representation of a Time Scale. + * + * @constructor + * @param {Scales.Time} scale + * @param {string} orientation One of "top"/"bottom". + */ + constructor(scale: Scales.Time, orientation: string); + /** + * Gets the label positions for each tier. + */ + tierLabelPositions(): string[]; + /** + * Sets the label positions for each tier. + * + * @param {string[]} newPositions The positions for each tier. "bottom" and "center" are the only supported values. + * @returns {Axes.Time} The calling Time Axis. + */ + tierLabelPositions(newPositions: string[]): Time; + /** + * Gets the possible TimeAxisConfigurations. + */ + axisConfigurations(): TimeAxisConfiguration[]; + /** + * Sets the possible TimeAxisConfigurations. + * The Time Axis will choose the most precise configuration that will display in the available space. + * + * @param {TimeAxisConfiguration[]} configurations + * @returns {Axes.Time} The calling Time Axis. + */ + axisConfigurations(configurations: TimeAxisConfiguration[]): Time; + /** + * Gets the index of the most precise TimeAxisConfiguration that will fit in the current width. + */ + orientation(): string; + orientation(orientation: string): Time; + protected _computeHeight(): number; + /** + * Check if tier configuration fits in the current width. + */ + protected _sizeFromOffer(availableWidth: number, availableHeight: number): { + width: number; + height: number; + }; + protected _setup(): void; + protected _getTickValues(): any[]; + renderImmediately(): Time; + } + } +} + + +declare module Plottable { + module Axes { + class Numeric extends Axis { + /** + * Constructs a Numeric Axis. + * + * A Numeric Axis is a visual representation of a QuantitativeScale. + * + * @constructor + * @param {QuantitativeScale} scale + * @param {string} orientation One of "top"/"bottom"/"left"/"right". + */ + constructor(scale: QuantitativeScale, orientation: string); + protected _setup(): void; + protected _computeWidth(): number; + protected _computeHeight(): number; + protected _getTickValues(): number[]; + protected _rescale(): void; + renderImmediately(): Numeric; + /** + * Hides the Tick Marks which have no corresponding Tick Labels + */ + /** + * Gets the tick label position relative to the tick marks. + * + * @returns {string} The current tick label position. + */ + tickLabelPosition(): string; + /** + * Sets the tick label position relative to the tick marks. + * + * @param {string} position "top"/"center"/"bottom" for a vertical Numeric Axis, + * "left"/"center"/"right" for a horizontal Numeric Axis. + * @returns {Numeric} The calling Numeric Axis. + */ + tickLabelPosition(position: string): Numeric; + /** + * Gets the approximate text width setting. + * + * @returns {boolean} The current text width approximation setting. + */ + usesTextWidthApproximation(): boolean; + /** + * Sets the approximate text width setting. Approximating text width + * measurements can drastically speed up plot rendering, but the plot may + * have extra white space that would be eliminated by exact measurements. + * Additionally, very abnormal fonts may not approximate reasonably. + * + * @param {boolean} The new text width approximation setting. + * @returns {Axes.Numeric} The calling Axes.Numeric. + */ + usesTextWidthApproximation(enable: boolean): Axes.Numeric; + /** + * The method is responsible for evenly spacing the labels on the axis. + * @return test to see if taking every `interval` recrangle from `rects` + * will result in labels not overlapping + * + * For top, bottom, left, right positioning of the thicks, we want the padding + * between the labels to be 3x, such that the label will be `padding` distance + * from the tick and 2 * `padding` distance (or more) from the next tick + * + */ + } + } +} + + +declare module Plottable { + module Axes { + class Category extends Axis { + /** + * Constructs a Category Axis. + * + * A Category Axis is a visual representation of a Category Scale. + * + * @constructor + * @param {Scales.Category} scale + * @param {string} [orientation="bottom"] One of "top"/"bottom"/"left"/"right". + */ + constructor(scale: Scales.Category, orientation: string); + protected _setup(): void; + protected _rescale(): Component; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + protected _coreSize(): number; + protected _getTickValues(): string[]; + /** + * Gets the tick label angle in degrees. + */ + tickLabelAngle(): number; + /** + * Sets the tick label angle in degrees. + * Right now only -90/0/90 are supported. 0 is horizontal. + * + * @param {number} angle + * @returns {Category} The calling Category Axis. + */ + tickLabelAngle(angle: number): Category; + /** + * Measures the size of the ticks while also writing them to the DOM. + * @param {d3.Selection} ticks The tick elements to be written to. + */ + /** + * Measures the size of the ticks without making any (permanent) DOM + * changes. + * + * @param {string[]} ticks The strings that will be printed on the ticks. + */ + renderImmediately(): Category; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; + } + } +} + + +declare module Plottable { + module Components { + class Label extends Component { + /** + * A Label is a Component that displays a single line of text. + * + * @constructor + * @param {string} [displayText=""] The text of the Label. + * @param {number} [angle=0] The angle of the Label in degrees (-90/0/90). 0 is horizontal. + */ + constructor(displayText?: string, angle?: number); + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + protected _setup(): void; + /** + * Gets the Label's text. + */ + text(): string; + /** + * Sets the Label's text. + * + * @param {string} displayText + * @returns {Label} The calling Label. + */ + text(displayText: string): Label; + /** + * Gets the angle of the Label in degrees. + */ + angle(): number; + /** + * Sets the angle of the Label in degrees. + * + * @param {number} angle One of -90/0/90. 0 is horizontal. + * @returns {Label} The calling Label. + */ + angle(angle: number): Label; + /** + * Gets the amount of padding around the Label in pixels. + */ + padding(): number; + /** + * Sets the amount of padding around the Label in pixels. + * + * @param {number} padAmount + * @returns {Label} The calling Label. + */ + padding(padAmount: number): Label; + fixedWidth(): boolean; + fixedHeight(): boolean; + renderImmediately(): Label; + } + class TitleLabel extends Label { + static TITLE_LABEL_CLASS: string; + /** + * @constructor + * @param {string} [text] + * @param {number} [angle] One of -90/0/90. 0 is horizontal. + */ + constructor(text?: string, angle?: number); + } + class AxisLabel extends Label { + static AXIS_LABEL_CLASS: string; + /** + * @constructor + * @param {string} [text] + * @param {number} [angle] One of -90/0/90. 0 is horizontal. + */ + constructor(text?: string, angle?: number); + } + } +} + + +declare module Plottable { + module Components { + class Legend extends Component { + /** + * The css class applied to each legend row + */ + static LEGEND_ROW_CLASS: string; + /** + * The css class applied to each legend entry + */ + static LEGEND_ENTRY_CLASS: string; + /** + * The css class applied to each legend symbol + */ + static LEGEND_SYMBOL_CLASS: string; + /** + * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. + * + * @constructor + * @param {Scale.Color} scale + */ + constructor(colorScale: Scales.Color); + protected _setup(): void; + /** + * Gets the Formatter for the entry texts. + */ + formatter(): Formatter; + /** + * Sets the Formatter for the entry texts. + * + * @param {Formatter} formatter + * @returns {Legend} The calling Legend. + */ + formatter(formatter: Formatter): Legend; + /** + * Gets the maximum number of entries per row. + * + * @returns {number} + */ + maxEntriesPerRow(): number; + /** + * Sets the maximum number of entries perrow. + * + * @param {number} maxEntriesPerRow + * @returns {Legend} The calling Legend. + */ + maxEntriesPerRow(maxEntriesPerRow: number): Legend; + /** + * Gets the current comparator for the Legend's entries. + * + * @returns {(a: string, b: string) => number} + */ + comparator(): (a: string, b: string) => number; + /** + * Sets a new comparator for the Legend's entries. + * The comparator is used to set the display order of the entries. + * + * @param {(a: string, b: string) => number} comparator + * @returns {Legend} The calling Legend. + */ + comparator(comparator: (a: string, b: string) => number): Legend; + /** + * Gets the Color Scale. + * + * @returns {Scales.Color} + */ + colorScale(): Scales.Color; + /** + * Sets the Color Scale. + * + * @param {Scales.Color} scale + * @returns {Legend} The calling Legend. + */ + colorScale(colorScale: Scales.Color): Legend; + destroy(): void; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + /** + * Gets the Entities (representing Legend entries) at a particular point. + * Returns an empty array if no Entities are present at that location. + * + * @param {Point} p + * @returns {Entity[]} + */ + entitiesAt(p: Point): Entity[]; + renderImmediately(): Legend; + /** + * Gets the function determining the symbols of the Legend. + * + * @returns {(datum: any, index: number) => symbolFactory} + */ + symbol(): (datum: any, index: number) => SymbolFactory; + /** + * Sets the function determining the symbols of the Legend. + * + * @param {(datum: any, index: number) => SymbolFactory} symbol + * @returns {Legend} The calling Legend + */ + symbol(symbol: (datum: any, index: number) => SymbolFactory): Legend; + /** + * Gets the opacity of the symbols of the Legend. + * + * @returns {(datum: any, index: number) => number} + */ + symbolOpacity(): (datum: any, index: number) => number; + /** + * Sets the opacity of the symbols of the Legend. + * + * @param {number | ((datum: any, index: number) => number)} symbolOpacity + * @returns {Legend} The calling Legend + */ + symbolOpacity(symbolOpacity: number | ((datum: any, index: number) => number)): Legend; + fixedWidth(): boolean; + fixedHeight(): boolean; + } + } +} + + +declare module Plottable { + module Components { + class InterpolatedColorLegend extends Component { + /** + * The css class applied to the legend labels. + */ + static LEGEND_LABEL_CLASS: string; + /** + * Creates an InterpolatedColorLegend. + * + * The InterpolatedColorLegend consists of a sequence of swatches that show the + * associated InterpolatedColor Scale sampled at various points. + * Two labels show the maximum and minimum values of the InterpolatedColor Scale. + * + * @constructor + * @param {Scales.InterpolatedColor} interpolatedColorScale + */ + constructor(interpolatedColorScale: Scales.InterpolatedColor); + destroy(): void; + /** + * Gets the Formatter for the labels. + */ + formatter(): Formatter; + /** + * Sets the Formatter for the labels. + * + * @param {Formatter} formatter + * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. + */ + formatter(formatter: Formatter): InterpolatedColorLegend; + /** + * Gets whether the InterpolatedColorLegend expands to occupy all offered space in the long direction + */ + expands(): boolean; + /** + * Sets whether the InterpolatedColorLegend expands to occupy all offered space in the long direction + * + * @param {expands} boolean + * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. + */ + expands(expands: boolean): InterpolatedColorLegend; + /** + * Gets the orientation. + */ + orientation(): string; + /** + * Sets the orientation. + * + * @param {string} orientation One of "horizontal"/"left"/"right". + * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. + */ + orientation(orientation: string): InterpolatedColorLegend; + fixedWidth(): boolean; + fixedHeight(): boolean; + protected _setup(): void; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + renderImmediately(): InterpolatedColorLegend; + } + } +} + + +declare module Plottable { + module Components { + class Gridlines extends Component { + /** + * @constructor + * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. + * @param {QuantitativeScale} yScale The scale to base the y gridlines on. Pass null if no gridlines are desired. + */ + constructor(xScale: QuantitativeScale, yScale: QuantitativeScale); + destroy(): Gridlines; + protected _setup(): void; + renderImmediately(): Gridlines; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; + } + } +} + + +declare module Plottable { + module Components { + class Table extends ComponentContainer { + /** + * A Table combines Components in the form of a grid. A + * common case is combining a y-axis, x-axis, and the plotted data via + * ```typescript + * new Table([[yAxis, plot], + * [null, xAxis]]); + * ``` + * + * @constructor + * @param {Component[][]} [rows=[]] A 2-D array of Components to be added to the Table. + * null can be used if a cell is empty. + */ + constructor(rows?: Component[][]); + protected _forEach(callback: (component: Component) => any): void; + /** + * Checks whether the specified Component is in the Table. + */ + has(component: Component): boolean; + /** + * Adds a Component in the specified row and column position. + * + * For example, instead of calling `new Table([[a, b], [null, c]])`, you + * could call + * var table = new Plottable.Components.Table(); + * table.add(a, 0, 0); + * table.add(b, 0, 1); + * table.add(c, 1, 1); + * + * @param {Component} component The Component to be added. + * @param {number} row + * @param {number} col + * @returns {Table} The calling Table. + */ + add(component: Component, row: number, col: number): Table; + protected _remove(component: Component): boolean; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; + /** + * Gets the padding above and below each row in pixels. + */ + rowPadding(): number; + /** + * Sets the padding above and below each row in pixels. + * + * @param {number} rowPadding + * @returns {Table} The calling Table. + */ + rowPadding(rowPadding: number): Table; + /** + * Gets the padding to the left and right of each column in pixels. + */ + columnPadding(): number; + /** + * Sets the padding to the left and right of each column in pixels. + * + * @param {number} columnPadding + * @returns {Table} The calling Table. + */ + columnPadding(columnPadding: number): Table; + /** + * Gets the weight of the specified row. + * + * @param {number} index + */ + rowWeight(index: number): number; + /** + * Sets the weight of the specified row. + * Space is allocated to rows based on their weight. Rows with higher weights receive proportionally more space. + * + * A common case would be to have one row take up 2/3rds of the space, + * and the other row take up 1/3rd. + * + * Example: + * + * ```JavaScript + * plot = new Plottable.Component.Table([ + * [row1], + * [row2] + * ]); + * + * // assign twice as much space to the first row + * plot + * .rowWeight(0, 2) + * .rowWeight(1, 1) + * ``` + * + * @param {number} index + * @param {number} weight + * @returns {Table} The calling Table. + */ + rowWeight(index: number, weight: number): Table; + /** + * Gets the weight of the specified column. + * + * @param {number} index + */ + columnWeight(index: number): number; + /** + * Sets the weight of the specified column. + * Space is allocated to columns based on their weight. Columns with higher weights receive proportionally more space. + * + * Please see `rowWeight` docs for an example. + * + * @param {number} index + * @param {number} weight + * @returns {Table} The calling Table. + */ + columnWeight(index: number, weight: number): Table; + fixedWidth(): boolean; + fixedHeight(): boolean; + } + } +} + + +declare module Plottable { + module Components { + enum PropertyMode { + VALUE = 0, + PIXEL = 1, + } + class SelectionBoxLayer extends Component { + protected _box: d3.Selection; + protected _xBoundsMode: PropertyMode; + protected _yBoundsMode: PropertyMode; + constructor(); + protected _setup(): void; + protected _sizeFromOffer(availableWidth: number, availableHeight: number): { + width: number; + height: number; + }; + /** + * Gets the Bounds of the box. + */ + bounds(): Bounds; + /** + * Sets the Bounds of the box. + * + * @param {Bounds} newBounds + * @return {SelectionBoxLayer} The calling SelectionBoxLayer. + */ + bounds(newBounds: Bounds): SelectionBoxLayer; + protected _setBounds(newBounds: Bounds): void; + renderImmediately(): SelectionBoxLayer; + /** + * Gets whether the box is being shown. + */ + boxVisible(): boolean; + /** + * Shows or hides the selection box. + * + * @param {boolean} show Whether or not to show the box. + * @return {SelectionBoxLayer} The calling SelectionBoxLayer. + */ + boxVisible(show: boolean): SelectionBoxLayer; + fixedWidth(): boolean; + fixedHeight(): boolean; + /** + * Gets the x scale for this SelectionBoxLayer. + */ + xScale(): QuantitativeScale; + /** + * Sets the x scale for this SelectionBoxLayer. + * + * @returns {SelectionBoxLayer} The calling SelectionBoxLayer. + */ + xScale(xScale: QuantitativeScale): SelectionBoxLayer; + /** + * Gets the y scale for this SelectionBoxLayer. + */ + yScale(): QuantitativeScale; + /** + * Sets the y scale for this SelectionBoxLayer. + * + * @returns {SelectionBoxLayer} The calling SelectionBoxLayer. + */ + yScale(yScale: QuantitativeScale): SelectionBoxLayer; + /** + * Gets the data values backing the left and right edges of the box. + * + * Returns an undefined array if the edges are not backed by a scale. + */ + xExtent(): (number | { + valueOf(): number; + })[]; + /** + * Sets the data values backing the left and right edges of the box. + */ + xExtent(xExtent: (number | { + valueOf(): number; + })[]): SelectionBoxLayer; + protected _setXExtent(xExtent: (number | { + valueOf(): number; + })[]): void; + /** + * Gets the data values backing the top and bottom edges of the box. + * + * Returns an undefined array if the edges are not backed by a scale. + */ + yExtent(): (number | { + valueOf(): number; + })[]; + /** + * Sets the data values backing the top and bottom edges of the box. + */ + yExtent(yExtent: (number | { + valueOf(): number; + })[]): SelectionBoxLayer; + protected _setYExtent(yExtent: (number | { + valueOf(): number; + })[]): void; + destroy(): void; + } + } +} + + +declare module Plottable { + module Components { + class GuideLineLayer extends Component { + static ORIENTATION_VERTICAL: string; + static ORIENTATION_HORIZONTAL: string; + constructor(orientation: string); + protected _setup(): void; + protected _sizeFromOffer(availableWidth: number, availableHeight: number): { + width: number; + height: number; + }; + protected _isVertical(): boolean; + fixedWidth(): boolean; + fixedHeight(): boolean; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): GuideLineLayer; + renderImmediately(): GuideLineLayer; + protected _setPixelPositionWithoutChangingMode(pixelPosition: number): void; + /** + * Gets the QuantitativeScale on the GuideLineLayer. + * + * @return {QuantitativeScale} + */ + scale(): QuantitativeScale; + /** + * Sets the QuantitativeScale on the GuideLineLayer. + * If value() was the last property set, pixelPosition() will be updated according to the new scale. + * If pixelPosition() was the last property set, value() will be updated according to the new scale. + * + * @param {QuantitativeScale} scale + * @return {GuideLineLayer} The calling GuideLineLayer. + */ + scale(scale: QuantitativeScale): GuideLineLayer; + /** + * Gets the value of the guide line in data-space. + * + * @return {D} + */ + value(): D; + /** + * Sets the value of the guide line in data-space. + * If the GuideLineLayer has a scale, pixelPosition() will be updated now and whenever the scale updates. + * + * @param {D} value + * @return {GuideLineLayer} The calling GuideLineLayer. + */ + value(value: D): GuideLineLayer; + /** + * Gets the position of the guide line in pixel-space. + * + * @return {number} + */ + pixelPosition(): number; + /** + * Sets the position of the guide line in pixel-space. + * If the GuideLineLayer has a scale, the value() will be updated now and whenever the scale updates. + * + * @param {number} pixelPosition + * @return {GuideLineLayer} The calling GuideLineLayer. + */ + pixelPosition(pixelPosition: number): GuideLineLayer; + destroy(): void; + } + } +} + + +declare module Plottable { + module Plots { + interface PlotEntity extends Entity { + dataset: Dataset; + index: number; + component: Plot; + } + interface AccessorScaleBinding { + accessor: Accessor; + scale?: Scale; + } + module Animator { + var MAIN: string; + var RESET: string; + } + } + class Plot extends Component { + protected static _ANIMATION_MAX_DURATION: number; + protected _renderArea: d3.Selection; + protected _renderCallback: ScaleCallback>; + protected _propertyExtents: d3.Map; + protected _propertyBindings: d3.Map>; + /** + * A Plot draws some visualization of the inputted Datasets. + * + * @constructor + */ + constructor(); + anchor(selection: d3.Selection): Plot; + protected _setup(): void; + destroy(): void; + protected _createNodesForDataset(dataset: Dataset): Drawer; + protected _createDrawer(dataset: Dataset): Drawer; + protected _getAnimator(key: string): Animator; + protected _onDatasetUpdate(): void; + /** + * Gets the AccessorScaleBinding for a particular attribute. + * + * @param {string} attr + */ + attr(attr: string): Plots.AccessorScaleBinding; + /** + * Sets a particular attribute to a constant value or the result of an Accessor. + * + * @param {string} attr + * @param {number|string|Accessor|Accessor} attrValue + * @returns {Plot} The calling Plot. + */ + attr(attr: string, attrValue: number | string | Accessor | Accessor): Plot; + /** + * Sets a particular attribute to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the attribute values when autoDomain()-ing. + * + * @param {string} attr + * @param {A|Accessor} attrValue + * @param {Scale} scale The Scale used to scale the attrValue. + * @returns {Plot} The calling Plot. + */ + attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; + protected _bindProperty(property: string, value: any, scale: Scale): void; + protected _generateAttrToProjector(): AttributeToProjector; + renderImmediately(): Plot; + /** + * Returns whether the plot will be animated. + */ + animated(): boolean; + /** + * Enables or disables animation. + */ + animated(willAnimate: boolean): Plot; + detach(): Plot; + /** + * @returns {Scale[]} A unique array of all scales currently used by the Plot. + */ + /** + * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. + */ + protected _updateExtents(): void; + protected _updateExtentsForProperty(property: string): void; + protected _filterForProperty(property: string): Accessor; + /** + * Override in subclass to add special extents, such as included values + */ + protected _extentsForProperty(property: string): any[]; + /** + * Get the Animator associated with the specified Animator key. + * + * @return {Animator} + */ + animator(animatorKey: string): Animator; + /** + * Set the Animator associated with the specified Animator key. + * + * @param {string} animatorKey + * @param {Animator} animator + * @returns {Plot} The calling Plot. + */ + animator(animatorKey: string, animator: Animator): Plot; + /** + * Adds a Dataset to the Plot. + * + * @param {Dataset} dataset + * @returns {Plot} The calling Plot. + */ + addDataset(dataset: Dataset): Plot; + protected _addDataset(dataset: Dataset): Plot; + /** + * Removes a Dataset from the Plot. + * + * @param {Dataset} dataset + * @returns {Plot} The calling Plot. + */ + removeDataset(dataset: Dataset): Plot; + protected _removeDataset(dataset: Dataset): Plot; + protected _removeDatasetNodes(dataset: Dataset): void; + datasets(): Dataset[]; + datasets(datasets: Dataset[]): Plot; + protected _getDrawersInOrder(): Drawer[]; + protected _generateDrawSteps(): Drawers.DrawStep[]; + protected _additionalPaint(time: number): void; + protected _getDataToDraw(): Utils.Map; + /** + * Retrieves Selections of this Plot for the specified Datasets. + * + * @param {Dataset[]} [datasets] The Datasets to retrieve the Selections for. + * If not provided, Selections will be retrieved for all Datasets on the Plot. + * @returns {d3.Selection} + */ + selections(datasets?: Dataset[]): d3.Selection; + /** + * Gets the Entities associated with the specified Datasets. + * + * @param {dataset[]} datasets The Datasets to retrieve the Entities for. + * If not provided, returns defaults to all Datasets on the Plot. + * @return {Plots.PlotEntity[]} + */ + entities(datasets?: Dataset[]): Plots.PlotEntity[]; + /** + * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. + * + * @param {Point} queryPoint + * @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. + */ + entityNearest(queryPoint: Point): Plots.PlotEntity; + /** + * @deprecated As of release v1.1.0, replaced by _entityVisibleOnPlot() + */ + protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; + protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; + protected _uninstallScaleForKey(scale: Scale, key: string): void; + protected _installScaleForKey(scale: Scale, key: string): void; + protected _propertyProjectors(): AttributeToProjector; + protected static _scaledAccessor(binding: Plots.AccessorScaleBinding): Accessor; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; + protected _animateOnNextRender(): boolean; + } +} + + +declare module Plottable { + module Plots { + class Pie extends Plot { + /** + * @constructor + */ + constructor(); + protected _setup(): void; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Pie; + addDataset(dataset: Dataset): Pie; + protected _addDataset(dataset: Dataset): Pie; + removeDataset(dataset: Dataset): Pie; + protected _removeDatasetNodes(dataset: Dataset): void; + protected _removeDataset(dataset: Dataset): Pie; + selections(datasets?: Dataset[]): d3.Selection; + protected _onDatasetUpdate(): void; + protected _createDrawer(dataset: Dataset): Drawers.Arc; + entities(datasets?: Dataset[]): PlotEntity[]; + /** + * Gets the AccessorScaleBinding for the sector value. + */ + sectorValue(): AccessorScaleBinding; + /** + * Sets the sector value to a constant number or the result of an Accessor. + * + * @param {number|Accessor} sectorValue + * @returns {Pie} The calling Pie Plot. + */ + sectorValue(sectorValue: number | Accessor): Plots.Pie; + /** + * Sets the sector value to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {S|Accessor} sectorValue + * @param {Scale} scale + * @returns {Pie} The calling Pie Plot. + */ + sectorValue(sectorValue: S | Accessor, scale: Scale): Plots.Pie; + /** + * Gets the AccessorScaleBinding for the inner radius. + */ + innerRadius(): AccessorScaleBinding; + /** + * Sets the inner radius to a constant number or the result of an Accessor. + * + * @param {number|Accessor} innerRadius + * @returns {Pie} The calling Pie Plot. + */ + innerRadius(innerRadius: number | Accessor): Plots.Pie; + /** + * Sets the inner radius to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {R|Accessor} innerRadius + * @param {Scale} scale + * @returns {Pie} The calling Pie Plot. + */ + innerRadius(innerRadius: R | Accessor, scale: Scale): Plots.Pie; + /** + * Gets the AccessorScaleBinding for the outer radius. + */ + outerRadius(): AccessorScaleBinding; + /** + * Sets the outer radius to a constant number or the result of an Accessor. + * + * @param {number|Accessor} outerRadius + * @returns {Pie} The calling Pie Plot. + */ + outerRadius(outerRadius: number | Accessor): Plots.Pie; + /** + * Sets the outer radius to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {R|Accessor} outerRadius + * @param {Scale} scale + * @returns {Pie} The calling Pie Plot. + */ + outerRadius(outerRadius: R | Accessor, scale: Scale): Plots.Pie; + /** + * Get whether slice labels are enabled. + * + * @returns {boolean} Whether slices should display labels or not. + */ + labelsEnabled(): boolean; + /** + * Sets whether labels are enabled. + * + * @param {boolean} labelsEnabled + * @returns {Pie} The calling Pie Plot. + */ + labelsEnabled(enabled: boolean): Pie; + /** + * Gets the Formatter for the labels. + */ + labelFormatter(): Formatter; + /** + * Sets the Formatter for the labels. + * + * @param {Formatter} formatter + * @returns {Pie} The calling Pie Plot. + */ + labelFormatter(formatter: Formatter): Pie; + entitiesAt(queryPoint: Point): PlotEntity[]; + protected _propertyProjectors(): AttributeToProjector; + protected _getDataToDraw(): Utils.Map; + protected static _isValidData(value: any): boolean; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): { + x: number; + y: number; + }; + protected _additionalPaint(time: number): void; + } + } +} + + +declare module Plottable { + class XYPlot extends Plot { + protected static _X_KEY: string; + protected static _Y_KEY: string; + /** + * An XYPlot is a Plot that displays data along two primary directions, X and Y. + * + * @constructor + * @param {Scale} xScale The x scale to use. + * @param {Scale} yScale The y scale to use. + */ + constructor(); + /** + * Returns the whether or not the rendering is deferred for performance boost. + * @return {boolean} The deferred rendering option + */ + deferredRendering(): boolean; + /** + * Sets / unsets the deferred rendering option + * Activating this option improves the performance of plot interaction (pan / zoom) by + * performing lazy renders, only after the interaction has stopped. Because re-rendering + * is no longer performed during the interaction, the zooming might experience a small + * resolution degradation, before the lazy re-render is performed. + * + * This option is intended for cases where performance is an issue. + */ + deferredRendering(deferredRendering: boolean): XYPlot; + /** + * Gets the AccessorScaleBinding for X. + */ + x(): Plots.AccessorScaleBinding; + /** + * Sets X to a constant number or the result of an Accessor. + * + * @param {number|Accessor} x + * @returns {XYPlot} The calling XYPlot. + */ + x(x: number | Accessor): XYPlot; + /** + * Sets X to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {X|Accessor} x + * @param {Scale} xScale + * @returns {XYPlot} The calling XYPlot. + */ + x(x: X | Accessor, xScale: Scale): XYPlot; + /** + * Gets the AccessorScaleBinding for Y. + */ + y(): Plots.AccessorScaleBinding; + /** + * Sets Y to a constant number or the result of an Accessor. + * + * @param {number|Accessor} y + * @returns {XYPlot} The calling XYPlot. + */ + y(y: number | Accessor): XYPlot; + /** + * Sets Y to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {Y|Accessor} y + * @param {Scale} yScale + * @returns {XYPlot} The calling XYPlot. + */ + y(y: Y | Accessor, yScale: Scale): XYPlot; + protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + protected _uninstallScaleForKey(scale: Scale, key: string): void; + protected _installScaleForKey(scale: Scale, key: string): void; + destroy(): XYPlot; + /** + * Gets the automatic domain adjustment mode for visible points. + */ + autorangeMode(): string; + /** + * Sets the automatic domain adjustment mode for visible points to operate against the X Scale, Y Scale, or neither. + * If "x" or "y" is specified the adjustment is immediately performed. + * + * @param {string} autorangeMode One of "x"/"y"/"none". + * "x" will adjust the x Scale in relation to changes in the y domain. + * "y" will adjust the y Scale in relation to changes in the x domain. + * "none" means neither Scale will change automatically. + * @returns {XYPlot} The calling XYPlot. + */ + autorangeMode(autorangeMode: string): XYPlot; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; + /** + * Adjusts the domains of both X and Y scales to show all data. + * This call does not override the autorange() behavior. + * + * @returns {XYPlot} The calling XYPlot. + */ + showAllData(): XYPlot; + protected _projectorsReady(): boolean; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; + protected _getDataToDraw(): Utils.Map; + } +} + + +declare module Plottable { + module Plots { + class Rectangle extends XYPlot { + /** + * A Rectangle Plot displays rectangles based on the data. + * The left and right edges of each rectangle can be set with x() and x2(). + * If only x() is set the Rectangle Plot will attempt to compute the correct left and right edge positions. + * The top and bottom edges of each rectangle can be set with y() and y2(). + * If only y() is set the Rectangle Plot will attempt to compute the correct top and bottom edge positions. + * + * @constructor + * @param {Scale.Scale} xScale + * @param {Scale.Scale} yScale + */ + constructor(); + protected _createDrawer(dataset: Dataset): Drawers.Rectangle; + protected _generateAttrToProjector(): { + [attr: string]: (datum: any, index: number, dataset: Dataset) => any; + }; + protected _generateDrawSteps(): Drawers.DrawStep[]; + protected _updateExtentsForProperty(property: string): void; + protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + /** + * Gets the AccessorScaleBinding for X. + */ + x(): AccessorScaleBinding; + /** + * Sets X to a constant number or the result of an Accessor. + * + * @param {number|Accessor} x + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + x(x: number | Accessor): Plots.Rectangle; + /** + * Sets X to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {X|Accessor} x + * @param {Scale} xScale + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + x(x: X | Accessor, xScale: Scale): Plots.Rectangle; + /** + * Gets the AccessorScaleBinding for X2. + */ + x2(): AccessorScaleBinding; + /** + * Sets X2 to a constant number or the result of an Accessor. + * If a Scale has been set for X, it will also be used to scale X2. + * + * @param {number|Accessor|X|Accessor} x2 + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + x2(x2: number | Accessor | X | Accessor): Plots.Rectangle; + /** + * Gets the AccessorScaleBinding for Y. + */ + y(): AccessorScaleBinding; + /** + * Sets Y to a constant number or the result of an Accessor. + * + * @param {number|Accessor} y + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + y(y: number | Accessor): Plots.Rectangle; + /** + * Sets Y to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {Y|Accessor} y + * @param {Scale} yScale + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + y(y: Y | Accessor, yScale: Scale): Plots.Rectangle; + /** + * Gets the AccessorScaleBinding for Y2. + */ + y2(): AccessorScaleBinding; + /** + * Sets Y2 to a constant number or the result of an Accessor. + * If a Scale has been set for Y, it will also be used to scale Y2. + * + * @param {number|Accessor|Y|Accessor} y2 + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + y2(y2: number | Accessor | Y | Accessor): Plots.Rectangle; + /** + * Gets the PlotEntities at a particular Point. + * + * @param {Point} point The point to query. + * @returns {PlotEntity[]} The PlotEntities at the particular point + */ + entitiesAt(point: Point): PlotEntity[]; + /** + * Gets the Entities that intersect the Bounds. + * + * @param {Bounds} bounds + * @returns {PlotEntity[]} + */ + entitiesIn(bounds: Bounds): PlotEntity[]; + /** + * Gets the Entities that intersect the area defined by the ranges. + * + * @param {Range} xRange + * @param {Range} yRange + * @returns {PlotEntity[]} + */ + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + /** + * Gets the accessor for labels. + * + * @returns {Accessor} + */ + label(): Accessor; + /** + * Sets the text of labels to the result of an Accessor. + * + * @param {Accessor} label + * @returns {Plots.Rectangle} The calling Rectangle Plot. + */ + label(label: Accessor): Plots.Rectangle; + /** + * Gets whether labels are enabled. + * + * @returns {boolean} + */ + labelsEnabled(): boolean; + /** + * Sets whether labels are enabled. + * Labels too big to be contained in the rectangle, cut off by edges, or blocked by other rectangles will not be shown. + * + * @param {boolean} labelsEnabled + * @returns {Rectangle} The calling Rectangle Plot. + */ + labelsEnabled(enabled: boolean): Plots.Rectangle; + protected _propertyProjectors(): AttributeToProjector; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): { + x: any; + y: any; + }; + protected _getDataToDraw(): Utils.Map; + protected _additionalPaint(time: number): void; + } + } +} + + +declare module Plottable { + module Plots { + class Scatter extends XYPlot { + /** + * A Scatter Plot draws a symbol at each data point. + * + * @constructor + */ + constructor(); + protected _createDrawer(dataset: Dataset): Drawers.Symbol; + /** + * Gets the AccessorScaleBinding for the size property of the plot. + * The size property corresponds to the area of the symbol. + */ + size(): AccessorScaleBinding; + /** + * Sets the size property to a constant number or the result of an Accessor. + * + * @param {number|Accessor} size + * @returns {Plots.Scatter} The calling Scatter Plot. + */ + size(size: number | Accessor): Plots.Scatter; + /** + * Sets the size property to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {S|Accessor} sectorValue + * @param {Scale} scale + * @returns {Plots.Scatter} The calling Scatter Plot. + */ + size(size: S | Accessor, scale: Scale): Plots.Scatter; + /** + * Gets the AccessorScaleBinding for the symbol property of the plot. + * The symbol property corresponds to how the symbol will be drawn. + */ + symbol(): AccessorScaleBinding; + /** + * Sets the symbol property to an Accessor. + * + * @param {Accessor} symbol + * @returns {Plots.Scatter} The calling Scatter Plot. + */ + symbol(symbol: Accessor): Plots.Scatter; + protected _generateDrawSteps(): Drawers.DrawStep[]; + /** + * @deprecated As of release v1.1.0, replaced by _entityVisibleOnPlot() + */ + protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; + protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; + protected _propertyProjectors(): AttributeToProjector; + /** + * Gets the Entities that intersect the Bounds. + * + * @param {Bounds} bounds + * @returns {PlotEntity[]} + */ + entitiesIn(bounds: Bounds): PlotEntity[]; + /** + * Gets the Entities that intersect the area defined by the ranges. + * + * @param {Range} xRange + * @param {Range} yRange + * @returns {PlotEntity[]} + */ + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + /** + * Gets the Entities at a particular Point. + * + * @param {Point} p + * @returns {PlotEntity[]} + */ + entitiesAt(p: Point): PlotEntity[]; + } + } +} + + +declare module Plottable { + module Plots { + class Bar extends XYPlot { + static ORIENTATION_VERTICAL: string; + static ORIENTATION_HORIZONTAL: string; + protected _isVertical: boolean; + /** + * A Bar Plot draws bars growing out from a baseline to some value + * + * @constructor + * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". + */ + constructor(orientation?: string); + x(): Plots.AccessorScaleBinding; + x(x: number | Accessor): Bar; + x(x: X | Accessor, xScale: Scale): Bar; + y(): Plots.AccessorScaleBinding; + y(y: number | Accessor): Bar; + y(y: Y | Accessor, yScale: Scale): Bar; + /** + * Gets the orientation of the plot + * + * @return "vertical" | "horizontal" + */ + orientation(): string; + render(): Bar; + protected _createDrawer(dataset: Dataset): Drawers.Rectangle; + protected _setup(): void; + /** + * Gets the baseline value. + * The baseline is the line that the bars are drawn from. + * + * @returns {X|Y} + */ + baselineValue(): X | Y; + /** + * Sets the baseline value. + * The baseline is the line that the bars are drawn from. + * + * @param {X|Y} value + * @returns {Bar} The calling Bar Plot. + */ + baselineValue(value: X | Y): Bar; + addDataset(dataset: Dataset): Bar; + protected _addDataset(dataset: Dataset): Bar; + removeDataset(dataset: Dataset): Bar; + protected _removeDataset(dataset: Dataset): Bar; + datasets(): Dataset[]; + datasets(datasets: Dataset[]): Plot; + /** + * Get whether bar labels are enabled. + * + * @returns {boolean} Whether bars should display labels or not. + */ + labelsEnabled(): boolean; + /** + * Sets whether labels are enabled. + * + * @param {boolean} labelsEnabled + * @returns {Bar} The calling Bar Plot. + */ + labelsEnabled(enabled: boolean): Bar; + /** + * Gets the Formatter for the labels. + */ + labelFormatter(): Formatter; + /** + * Sets the Formatter for the labels. + * + * @param {Formatter} formatter + * @returns {Bar} The calling Bar Plot. + */ + labelFormatter(formatter: Formatter): Bar; + protected _createNodesForDataset(dataset: Dataset): Drawer; + protected _removeDatasetNodes(dataset: Dataset): void; + /** + * Returns the PlotEntity nearest to the query point according to the following algorithm: + * - If the query point is inside a bar, returns the PlotEntity for that bar. + * - Otherwise, gets the nearest PlotEntity by the primary direction (X for vertical, Y for horizontal), + * breaking ties with the secondary direction. + * Returns undefined if no PlotEntity can be found. + * + * @param {Point} queryPoint + * @returns {PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. + */ + entityNearest(queryPoint: Point): PlotEntity; + /** + * @deprecated As of release v1.1.0, replaced by _entityVisibleOnPlot() + */ + protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; + protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; + /** + * Gets the Entities at a particular Point. + * + * @param {Point} p + * @returns {PlotEntity[]} + */ + entitiesAt(p: Point): PlotEntity[]; + /** + * Gets the Entities that intersect the Bounds. + * + * @param {Bounds} bounds + * @returns {PlotEntity[]} + */ + entitiesIn(bounds: Bounds): PlotEntity[]; + /** + * Gets the Entities that intersect the area defined by the ranges. + * + * @param {Range} xRange + * @param {Range} yRange + * @returns {PlotEntity[]} + */ + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + protected _additionalPaint(time: number): void; + /** + * Makes sure the extent takes into account the widths of the bars + */ + protected _extentsForProperty(property: string): any[]; + protected _generateDrawSteps(): Drawers.DrawStep[]; + protected _generateAttrToProjector(): { + [attr: string]: (datum: any, index: number, dataset: Dataset) => any; + }; + /** + * Computes the barPixelWidth of all the bars in the plot. + * + * If the position scale of the plot is a CategoryScale and in bands mode, then the rangeBands function will be used. + * If the position scale of the plot is a QuantitativeScale, then the bar width is equal to the smallest distance between + * two adjacent data points, padded for visualisation. + */ + protected _getBarPixelWidth(): number; + entities(datasets?: Dataset[]): PlotEntity[]; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; + protected _uninstallScaleForKey(scale: Scale, key: string): void; + protected _getDataToDraw(): Utils.Map; + } + } +} + + +declare module Plottable { + module Plots { + class Line extends XYPlot { + /** + * A Line Plot draws line segments starting from the first data point to the next. + * + * @constructor + */ + constructor(); + x(): Plots.AccessorScaleBinding; + x(x: number | Accessor): Line; + x(x: X | Accessor, xScale: Scale): Line; + y(): Plots.AccessorScaleBinding; + y(y: number | Accessor): Line; + y(y: number | Accessor, yScale: Scale): Line; + autorangeMode(): string; + autorangeMode(autorangeMode: string): Line; + /** + * Gets whether or not the autoranging is done smoothly. + */ + autorangeSmooth(): boolean; + /** + * Sets whether or not the autorange is done smoothly. + * + * Smooth autoranging is done by making sure lines always exit on the left / right side of the plot + * and deactivating the nice domain feature on the scales + */ + autorangeSmooth(autorangeSmooth: boolean): Plots.Line; + /** + * Gets the interpolation function associated with the plot. + * + * @return {string | (points: Array<[number, number]>) => string)} + */ + interpolator(): string | ((points: Array<[number, number]>) => string); + /** + * Sets the interpolation function associated with the plot. + * + * @param {string | points: Array<[number, number]>) => string} interpolator Interpolation function + * @return Plots.Line + */ + interpolator(interpolator: string | ((points: Array<[number, number]>) => string)): Plots.Line; + interpolator(interpolator: "linear"): Line; + interpolator(interpolator: "linear-closed"): Line; + interpolator(interpolator: "step"): Line; + interpolator(interpolator: "step-before"): Line; + interpolator(interpolator: "step-after"): Line; + interpolator(interpolator: "basis"): Line; + interpolator(interpolator: "basis-open"): Line; + interpolator(interpolator: "basis-closed"): Line; + interpolator(interpolator: "bundle"): Line; + interpolator(interpolator: "cardinal"): Line; + interpolator(interpolator: "cardinal-open"): Line; + interpolator(interpolator: "cardinal-closed"): Line; + interpolator(interpolator: "monotone"): Line; + protected _createDrawer(dataset: Dataset): Drawer; + protected _extentsForProperty(property: string): any[]; + protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; + protected _generateDrawSteps(): Drawers.DrawStep[]; + protected _generateAttrToProjector(): { + [attr: string]: (datum: any, index: number, dataset: Dataset) => any; + }; + /** + * Returns the PlotEntity nearest to the query point by X then by Y, or undefined if no PlotEntity can be found. + * + * @param {Point} queryPoint + * @returns {PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. + */ + entityNearest(queryPoint: Point): PlotEntity; + protected _propertyProjectors(): AttributeToProjector; + protected _constructLineProjector(xProjector: Projector, yProjector: Projector): (datum: any, index: number, dataset: Dataset) => string; + protected _getDataToDraw(): Utils.Map; + } + } +} + + +declare module Plottable { + module Plots { + class Area extends Line { + /** + * An Area Plot draws a filled region (area) between Y and Y0. + * + * @constructor + */ + constructor(); + protected _setup(): void; + y(): Plots.AccessorScaleBinding; + y(y: number | Accessor): Area; + y(y: number | Accessor, yScale: QuantitativeScale): Area; + /** + * Gets the AccessorScaleBinding for Y0. + */ + y0(): Plots.AccessorScaleBinding; + /** + * Sets Y0 to a constant number or the result of an Accessor. + * If a Scale has been set for Y, it will also be used to scale Y0. + * + * @param {number|Accessor} y0 + * @returns {Area} The calling Area Plot. + */ + y0(y0: number | Accessor): Area; + protected _onDatasetUpdate(): void; + addDataset(dataset: Dataset): Area; + protected _addDataset(dataset: Dataset): Area; + protected _removeDatasetNodes(dataset: Dataset): void; + protected _additionalPaint(): void; + protected _createDrawer(dataset: Dataset): Drawers.Area; + protected _generateDrawSteps(): Drawers.DrawStep[]; + protected _updateYScale(): void; + protected _getResetYFunction(): Accessor; + protected _propertyProjectors(): AttributeToProjector; + selections(datasets?: Dataset[]): d3.Selection; + protected _constructAreaProjector(xProjector: Projector, yProjector: Projector, y0Projector: Projector): (datum: any[], index: number, dataset: Dataset) => string; + } + } +} + + +declare module Plottable { + module Plots { + class ClusteredBar extends Bar { + /** + * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. + * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. + * On a horizontal ClusteredBar Plot, the bars with the same Y value are grouped. + * + * @constructor + * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". + */ + constructor(orientation?: string); + protected _generateAttrToProjector(): { + [attr: string]: (datum: any, index: number, dataset: Dataset) => any; + }; + protected _getDataToDraw(): Utils.Map; + } + } +} + + +declare module Plottable { + module Plots { + class StackedArea extends Area { + /** + * @constructor + */ + constructor(); + protected _getAnimator(key: string): Animator; + protected _setup(): void; + x(): Plots.AccessorScaleBinding; + x(x: number | Accessor): StackedArea; + x(x: X | Accessor, xScale: Scale): StackedArea; + y(): Plots.AccessorScaleBinding; + y(y: number | Accessor): StackedArea; + y(y: number | Accessor, yScale: QuantitativeScale): StackedArea; + protected _additionalPaint(): void; + protected _updateYScale(): void; + protected _onDatasetUpdate(): StackedArea; + protected _updateExtentsForProperty(property: string): void; + protected _extentsForProperty(attr: string): any[]; + /** + * Given an array of Datasets and the accessor function for the key, computes the + * set reunion (no duplicates) of the domain of each Dataset. The keys are stringified + * before being returned. + * + * @param {Dataset[]} datasets The Datasets for which we extract the domain keys + * @param {Accessor} keyAccessor The accessor for the key of the data + * @return {string[]} An array of stringified keys + */ + protected _propertyProjectors(): AttributeToProjector; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; + } + } +} + + +declare module Plottable { + module Plots { + class StackedBar extends Bar { + /** + * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. + * On a vertical StackedBar Plot, the bars with the same X value are stacked. + * On a horizontal StackedBar Plot, the bars with the same Y value are stacked. + * + * @constructor + * @param {Scale} xScale + * @param {Scale} yScale + * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". + */ + constructor(orientation?: string); + x(): Plots.AccessorScaleBinding; + x(x: number | Accessor): StackedBar; + x(x: X | Accessor, xScale: Scale): StackedBar; + y(): Plots.AccessorScaleBinding; + y(y: number | Accessor): StackedBar; + y(y: Y | Accessor, yScale: Scale): StackedBar; + protected _generateAttrToProjector(): { + [attr: string]: (datum: any, index: number, dataset: Dataset) => any; + }; + protected _onDatasetUpdate(): StackedBar; + protected _updateExtentsForProperty(property: string): void; + protected _extentsForProperty(attr: string): any[]; + } + } +} + + +declare module Plottable { + module Plots { + class Segment extends XYPlot { + /** + * A Segment Plot displays line segments based on the data. + * + * @constructor + */ + constructor(); + protected _createDrawer(dataset: Dataset): Drawers.Segment; + protected _generateDrawSteps(): Drawers.DrawStep[]; + protected _updateExtentsForProperty(property: string): void; + protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + /** + * Gets the AccessorScaleBinding for X + */ + x(): AccessorScaleBinding; + /** + * Sets X to a constant value or the result of an Accessor. + * + * @param {X|Accessor} x + * @returns {Plots.Segment} The calling Segment Plot. + */ + x(x: number | Accessor): Plots.Segment; + /** + * Sets X to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {X|Accessor} x + * @param {Scale} xScale + * @returns {Plots.Segment} The calling Segment Plot. + */ + x(x: X | Accessor, xScale: Scale): Plots.Segment; + /** + * Gets the AccessorScaleBinding for X2 + */ + x2(): AccessorScaleBinding; + /** + * Sets X2 to a constant number or the result of an Accessor. + * If a Scale has been set for X, it will also be used to scale X2. + * + * @param {number|Accessor|Y|Accessor} y2 + * @returns {Plots.Segment} The calling Segment Plot + */ + x2(x2: number | Accessor | X | Accessor): Plots.Segment; + /** + * Gets the AccessorScaleBinding for Y + */ + y(): AccessorScaleBinding; + /** + * Sets Y to a constant value or the result of an Accessor. + * + * @param {Y|Accessor} y + * @returns {Plots.Segment} The calling Segment Plot. + */ + y(y: number | Accessor): Plots.Segment; + /** + * Sets Y to a scaled constant value or scaled result of an Accessor. + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {Y|Accessor} y + * @param {Scale} yScale + * @returns {Plots.Segment} The calling Segment Plot. + */ + y(y: Y | Accessor, yScale: Scale): Plots.Segment; + /** + * Gets the AccessorScaleBinding for Y2. + */ + y2(): AccessorScaleBinding; + /** + * Sets Y2 to a constant number or the result of an Accessor. + * If a Scale has been set for Y, it will also be used to scale Y2. + * + * @param {number|Accessor|Y|Accessor} y2 + * @returns {Plots.Segment} The calling Segment Plot. + */ + y2(y2: number | Accessor | Y | Accessor): Plots.Segment; + protected _propertyProjectors(): AttributeToProjector; + /** + * Gets the Entities that intersect the Bounds. + * + * @param {Bounds} bounds + * @returns {PlotEntity[]} + */ + entitiesIn(bounds: Bounds): PlotEntity[]; + /** + * Gets the Entities that intersect the area defined by the ranges. + * + * @param {Range} xRange + * @param {Range} yRange + * @returns {PlotEntity[]} + */ + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + } + } +} + + +declare module Plottable { + module Plots { + class Waterfall extends Bar { + constructor(); + /** + * Gets whether connectors are enabled. + * + * @returns {boolean} Whether connectors should be shown or not. + */ + connectorsEnabled(): boolean; + /** + * Sets whether connectors are enabled. + * + * @param {boolean} enabled + * @returns {Plots.Waterfall} The calling Waterfall Plot. + */ + connectorsEnabled(enabled: boolean): Waterfall; + /** + * Gets the AccessorScaleBinding for whether a bar represents a total or a delta. + */ + total(): Plots.AccessorScaleBinding; + /** + * Sets total to a constant number or the result of an Accessor + * + * @param {Accessor} + * @returns {Plots.Waterfall} The calling Waterfall Plot. + */ + total(total: Accessor): Waterfall; + protected _additionalPaint(time: number): void; + protected _createNodesForDataset(dataset: Dataset): Drawer; + protected _extentsForProperty(attr: string): any[]; + protected _generateAttrToProjector(): { + [attr: string]: (datum: any, index: number, dataset: Dataset) => any; + }; + protected _onDatasetUpdate(): Waterfall; + } + } +} + + +declare module Plottable { + module Plots { + class Wheel extends Plot { + /** + * @constructor + */ + constructor(); + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Wheel; + protected _createDrawer(dataset: Dataset): Drawers.Arc; + entities(datasets?: Dataset[]): PlotEntity[]; + protected _getDataToDraw(): Utils.Map; + protected _propertyProjectors(): AttributeToProjector; + /** + * Gets the AccessorScaleBinding for t in degrees. + */ + t(): AccessorScaleBinding; + /** + * Sets t to a constant number or the result of an Accessor in degrees. + * + * @param {number|Accessor} t + * @returns {Wheel} The calling Wheel Plot. + */ + t(t: number | Accessor): Plots.Wheel; + /** + * Sets t to a scaled constant value or scaled result of an Accessor in degrees. + * The supplied Scale will also be used for t2(). + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {T|Accessor} t + * @param {QuantitativeScale} scale + * @returns {Wheel} The calling Wheel Plot. + */ + t(t: T | Accessor, scale: QuantitativeScale): Plots.Wheel; + /** + * Gets the AccessorScaleBinding for t2 in degrees. + */ + t2(): AccessorScaleBinding; + /** + * Sets t2 to a constant number or the result of an Accessor in degrees. + * If a Scale has been set for t, it will also be used to scale t2. + * + * @param {number|Accessor>} t2 + * @returns {Wheel} The calling Wheel Plot. + */ + t2(t2: number | Accessor | T | Accessor): Plots.Wheel; + /** + * Gets the AccessorScaleBinding for r. + */ + r(): AccessorScaleBinding; + /** + * Sets r to a constant number or the result of an Accessor. + * + * @param {number|Accessor} r + * @returns {Wheel} The calling Wheel Plot. + */ + r(r: number | Accessor): Plots.Wheel; + /** + * Sets r to a scaled constant value or scaled result of an Accessor. + * The supplied Scale will also be used for r2(). + * The provided Scale will account for the values when autoDomain()-ing. + * + * @param {R|Accessor} r + * @param {QuantitativeScale} scale + * @returns {Wheel} The calling Wheel Plot. + */ + r(r: R | Accessor, scale: QuantitativeScale): Plots.Wheel; + /** + * Gets the AccessorScaleBinding for r2. + */ + r2(): AccessorScaleBinding; + /** + * Sets r2 to a constant number or the result of an Accessor. + * If a Scale has been set for r, it will also be used to scale r2. + * + * @param {number|Accessor|R|Accessor} r2 + * @returns {Wheel} The calling Wheel Plot. + */ + r2(r2: number | Accessor | R | Accessor): Plots.Wheel; + protected _pixelPoint(datum: any, index: number, dataset: Dataset): { + x: number; + y: number; + }; + } + } +} + + +declare module Plottable { + interface Animator { + /** + * Applies the supplied attributes to a d3.Selection with some animation. + * + * @param {d3.Selection} selection The update selection or transition selection that we wish to animate. + * @param {AttributeToAppliedProjector} attrToAppliedProjector The set of + * AppliedProjectors that we will use to set attributes on the selection. + * @return {any} Animators should return the selection or + * transition object so that plots may chain the transitions between + * animators. + */ + animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection | d3.Transition; + /** + * Given the number of elements, return the total time the animation requires + * + * @param {number} numberofIterations The number of elements that will be drawn + * @returns {number} + */ + totalTime(numberOfIterations: number): number; + } +} + + +declare module Plottable { + module Animators { + /** + * An animator implementation with no animation. The attributes are + * immediately set on the selection. + */ + class Null implements Animator { + totalTime(selection: any): number; + animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection; + } + } +} + + +declare module Plottable { + module Animators { + /** + * An Animator with easing and configurable durations and delays. + */ + class Easing implements Animator { + /** + * The default starting delay of the animation in milliseconds + */ + /** + * The default duration of one animation step in milliseconds + */ + /** + * The default maximum start delay between each step of an animation + */ + /** + * The default maximum total animation duration + */ + /** + * The default easing of the animation + */ + /** + * Constructs the default animator + * + * @constructor + */ + constructor(); + totalTime(numberOfSteps: number): number; + animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Transition; + /** + * Gets the start delay of the animation in milliseconds. + * + * @returns {number} The current start delay. + */ + startDelay(): number; + /** + * Sets the start delay of the animation in milliseconds. + * + * @param {number} startDelay The start delay in milliseconds. + * @returns {Easing} The calling Easing Animator. + */ + startDelay(startDelay: number): Easing; + /** + * Gets the duration of one animation step in milliseconds. + * + * @returns {number} The current duration. + */ + stepDuration(): number; + /** + * Sets the duration of one animation step in milliseconds. + * + * @param {number} stepDuration The duration in milliseconds. + * @returns {Easing} The calling Easing Animator. + */ + stepDuration(stepDuration: number): Easing; + /** + * Gets the maximum start delay between animation steps in milliseconds. + * + * @returns {number} The current maximum iterative delay. + */ + stepDelay(): number; + /** + * Sets the maximum start delay between animation steps in milliseconds. + * + * @param {number} stepDelay The maximum iterative delay in milliseconds. + * @returns {Easing} The calling Easing Animator. + */ + stepDelay(stepDelay: number): Easing; + /** + * Gets the maximum total animation duration constraint in milliseconds. + * + * If the animation time would exceed the specified time, the duration of each step + * and the delay between each step will be reduced until the animation fits within + * the specified time. + * + * @returns {number} The current maximum total animation duration. + */ + maxTotalDuration(): number; + /** + * Sets the maximum total animation duration constraint in miliseconds. + * + * If the animation time would exceed the specified time, the duration of each step + * and the delay between each step will be reduced until the animation fits within + * the specified time. + * + * @param {number} maxTotalDuration The maximum total animation duration in milliseconds. + * @returns {Easing} The calling Easing Animator. + */ + maxTotalDuration(maxTotalDuration: number): Easing; + /** + * Gets the current easing mode of the animation. + * + * @returns {string} the current easing mode. + */ + easingMode(): string; + /** + * Sets the easing mode of the animation. + * + * @param {string} easingMode The desired easing mode. + * @returns {Easing} The calling Easing Animator. + */ + easingMode(easingMode: string): Easing; + /** + * Adjust the iterative delay, such that it takes into account the maxTotalDuration constraint + */ + } + } +} + + +declare module Plottable { + class Dispatcher { + protected _eventToCallback: { + [eventName: string]: (e: Event) => any; + }; + protected _callbacks: Utils.CallbackSet[]; + protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; + protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; + } +} + + +declare module Plottable { + module Dispatchers { + type MouseCallback = (p: Point, event: MouseEvent) => void; + class Mouse extends Dispatcher { + /** + * Get a Mouse Dispatcher for the containing elem. + * If one already exists on that , it will be returned; otherwise, a new one will be created. + * + * @param {SVGElement} elem + * @return {Dispatchers.Mouse} + */ + static getDispatcher(elem: SVGElement): Dispatchers.Mouse; + /** + * This constructor not be invoked directly. + * + * @constructor + * @param {SVGElement} svg The root to attach to. + */ + constructor(svg: SVGElement); + /** + * Registers a callback to be called when the mouse position changes. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + onMouseMove(callback: MouseCallback): Dispatchers.Mouse; + /** + * Removes a callback that would be called when the mouse position changes. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + offMouseMove(callback: MouseCallback): Dispatchers.Mouse; + /** + * Registers a callback to be called when a mousedown occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + onMouseDown(callback: MouseCallback): Dispatchers.Mouse; + /** + * Removes a callback that would be called when a mousedown occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + offMouseDown(callback: MouseCallback): Dispatchers.Mouse; + /** + * Registers a callback to be called when a mouseup occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + onMouseUp(callback: MouseCallback): Dispatchers.Mouse; + /** + * Removes a callback that would be called when a mouseup occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + offMouseUp(callback: MouseCallback): Dispatchers.Mouse; + /** + * Registers a callback to be called when a wheel event occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + onWheel(callback: MouseCallback): Dispatchers.Mouse; + /** + * Removes a callback that would be called when a wheel event occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + offWheel(callback: MouseCallback): Dispatchers.Mouse; + /** + * Registers a callback to be called when a dblClick occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + onDblClick(callback: MouseCallback): Dispatchers.Mouse; + /** + * Removes a callback that would be called when a dblClick occurs. + * + * @param {MouseCallback} callback + * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. + */ + offDblClick(callback: MouseCallback): Dispatchers.Mouse; + /** + * Computes the mouse position from the given event, and if successful + * calls all the callbacks in the provided callbackSet. + */ + eventInsideSVG(event: MouseEvent): boolean; + /** + * Returns the last computed mouse position in coordinate space. + * + * @return {Point} + */ + lastMousePosition(): Point; + } + } +} + + +declare module Plottable { + module Dispatchers { + type TouchCallback = (ids: number[], idToPoint: { + [id: number]: Point; + }, event: TouchEvent) => void; + class Touch extends Dispatcher { + /** + * Gets a Touch Dispatcher for the containing elem. + * If one already exists on that , it will be returned; otherwise, a new one will be created. + * + * @param {SVGElement} elem + * @return {Dispatchers.Touch} + */ + static getDispatcher(elem: SVGElement): Dispatchers.Touch; + /** + * This constructor should not be invoked directly. + * + * @constructor + * @param {SVGElement} svg The root to attach to. + */ + constructor(svg: SVGElement); + /** + * Registers a callback to be called when a touch starts. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + onTouchStart(callback: TouchCallback): Dispatchers.Touch; + /** + * Removes a callback that would be called when a touch starts. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + offTouchStart(callback: TouchCallback): Dispatchers.Touch; + /** + * Registers a callback to be called when the touch position changes. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + onTouchMove(callback: TouchCallback): Dispatchers.Touch; + /** + * Removes a callback that would be called when the touch position changes. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + offTouchMove(callback: TouchCallback): Dispatchers.Touch; + /** + * Registers a callback to be called when a touch ends. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + onTouchEnd(callback: TouchCallback): Dispatchers.Touch; + /** + * Removes a callback that would be called when a touch ends. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + offTouchEnd(callback: TouchCallback): Dispatchers.Touch; + /** + * Registers a callback to be called when a touch is cancelled. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + onTouchCancel(callback: TouchCallback): Dispatchers.Touch; + /** + * Removes a callback that would be called when a touch is cancelled. + * + * @param {TouchCallback} callback + * @return {Dispatchers.Touch} The calling Touch Dispatcher. + */ + offTouchCancel(callback: TouchCallback): Dispatchers.Touch; + /** + * Computes the Touch position from the given event, and if successful + * calls all the callbacks in the provided callbackSet. + */ + eventInsideSVG(event: TouchEvent): boolean; + } + } +} + + +declare module Plottable { + module Dispatchers { + type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; + class Key extends Dispatcher { + /** + * Gets a Key Dispatcher. If one already exists it will be returned; + * otherwise, a new one will be created. + * + * @return {Dispatchers.Key} + */ + static getDispatcher(): Dispatchers.Key; + /** + * This constructor should not be invoked directly. + * + * @constructor + */ + constructor(); + /** + * Registers a callback to be called whenever a key is pressed. + * + * @param {KeyCallback} callback + * @return {Dispatchers.Key} The calling Key Dispatcher. + */ + onKeyDown(callback: KeyCallback): Key; + /** + * Removes the callback to be called whenever a key is pressed. + * + * @param {KeyCallback} callback + * @return {Dispatchers.Key} The calling Key Dispatcher. + */ + offKeyDown(callback: KeyCallback): Key; + /** Registers a callback to be called whenever a key is released. + * + * @param {KeyCallback} callback + * @return {Dispatchers.Key} The calling Key Dispatcher. + */ + onKeyUp(callback: KeyCallback): Key; + /** + * Removes the callback to be called whenever a key is released. + * + * @param {KeyCallback} callback + * @return {Dispatchers.Key} The calling Key Dispatcher. + */ + offKeyUp(callback: KeyCallback): Key; + } + } +} + + +declare module Plottable { + class Interaction { + protected _componentAttachedTo: Component; + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Attaches this Interaction to a Component. + * If the Interaction was already attached to a Component, it first detaches itself from the old Component. + * + * @param {Component} component + * @returns {Interaction} The calling Interaction. + */ + attachTo(component: Component): Interaction; + /** + * Detaches this Interaction from the Component. + * This Interaction can be reused. + * + * @param {Component} component + * @returns {Interaction} The calling Interaction. + */ + detachFrom(component: Component): Interaction; + /** + * Gets whether this Interaction is enabled. + */ + enabled(): boolean; + /** + * Enables or disables this Interaction. + * + * @param {boolean} enabled Whether the Interaction should be enabled. + * @return {Interaction} The calling Interaction. + */ + enabled(enabled: boolean): Interaction; + /** + * Translates an -coordinate-space point to Component-space coordinates. + * + * @param {Point} p A Point in -space coordinates. + * @return {Point} The same location in Component-space coordinates. + */ + protected _translateToComponentSpace(p: Point): Point; + /** + * Checks whether a Component-coordinate-space Point is inside the Component. + * + * @param {Point} p A Point in Compoennt-space coordinates. + * @return {boolean} Whether or not the point is inside the Component. + */ + protected _isInsideComponent(p: Point): boolean; + } +} + + +declare module Plottable { + type ClickCallback = (point: Point) => void; + module Interactions { + class Click extends Interaction { + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Adds a callback to be called when the Component is clicked. + * + * @param {ClickCallback} callback + * @return {Interactions.Click} The calling Click Interaction. + */ + onClick(callback: ClickCallback): Click; + /** + * Removes a callback that would be called when the Component is clicked. + * + * @param {ClickCallback} callback + * @return {Interactions.Click} The calling Click Interaction. + */ + offClick(callback: ClickCallback): Click; + } + } +} + + +declare module Plottable { + module Interactions { + class DoubleClick extends Interaction { + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Adds a callback to be called when the Component is double-clicked. + * + * @param {ClickCallback} callback + * @return {Interactions.DoubleClick} The calling DoubleClick Interaction. + */ + onDoubleClick(callback: ClickCallback): DoubleClick; + /** + * Removes a callback that would be called when the Component is double-clicked. + * + * @param {ClickCallback} callback + * @return {Interactions.DoubleClick} The calling DoubleClick Interaction. + */ + offDoubleClick(callback: ClickCallback): DoubleClick; + } + } +} + + +declare module Plottable { + type KeyCallback = (keyCode: number) => void; + module Interactions { + class Key extends Interaction { + /** + * A Key Interaction listens to key events that occur while the Component is + * moused over. + */ + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Adds a callback to be called when the key with the given keyCode is + * pressed and the user is moused over the Component. + * + * @param {number} keyCode + * @param {KeyCallback} callback + * @returns {Interactions.Key} The calling Key Interaction. + */ + onKeyPress(keyCode: number, callback: KeyCallback): Key; + /** + * Removes a callback that would be called when the key with the given keyCode is + * pressed and the user is moused over the Component. + * + * @param {number} keyCode + * @param {KeyCallback} callback + * @returns {Interactions.Key} The calling Key Interaction. + */ + offKeyPress(keyCode: number, callback: KeyCallback): Key; + /** + * Adds a callback to be called when the key with the given keyCode is + * released if the key was pressed with the mouse inside of the Component. + * + * @param {number} keyCode + * @param {KeyCallback} callback + * @returns {Interactions.Key} The calling Key Interaction. + */ + onKeyRelease(keyCode: number, callback: KeyCallback): Key; + /** + * Removes a callback that would be called when the key with the given keyCode is + * released if the key was pressed with the mouse inside of the Component. + * + * @param {number} keyCode + * @param {KeyCallback} callback + * @returns {Interactions.Key} The calling Key Interaction. + */ + offKeyRelease(keyCode: number, callback: KeyCallback): Key; + } + } +} + + +declare module Plottable { + type PointerCallback = (point: Point) => void; + module Interactions { + class Pointer extends Interaction { + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Adds a callback to be called when the pointer enters the Component. + * + * @param {PointerCallback} callback + * @return {Interactions.Pointer} The calling Pointer Interaction. + */ + onPointerEnter(callback: PointerCallback): Pointer; + /** + * Removes a callback that would be called when the pointer enters the Component. + * + * @param {PointerCallback} callback + * @return {Interactions.Pointer} The calling Pointer Interaction. + */ + offPointerEnter(callback: PointerCallback): Pointer; + /** + * Adds a callback to be called when the pointer moves within the Component. + * + * @param {PointerCallback} callback + * @return {Interactions.Pointer} The calling Pointer Interaction. + */ + onPointerMove(callback: PointerCallback): Pointer; + /** + * Removes a callback that would be called when the pointer moves within the Component. + * + * @param {PointerCallback} callback + * @return {Interactions.Pointer} The calling Pointer Interaction. + */ + offPointerMove(callback: PointerCallback): Pointer; + /** + * Adds a callback to be called when the pointer exits the Component. + * + * @param {PointerCallback} callback + * @return {Interactions.Pointer} The calling Pointer Interaction. + */ + onPointerExit(callback: PointerCallback): Pointer; + /** + * Removes a callback that would be called when the pointer exits the Component. + * + * @param {PointerCallback} callback + * @return {Interactions.Pointer} The calling Pointer Interaction. + */ + offPointerExit(callback: PointerCallback): Pointer; + } + } +} + + +declare module Plottable { + module Interactions { + class PanZoom extends Interaction { + /** + * The number of pixels occupied in a line. + */ + /** + * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale + * in response to the user panning or zooming. + * + * @constructor + * @param {QuantitativeScale} [xScale] The x-scale to update on panning/zooming. + * @param {QuantitativeScale} [yScale] The y-scale to update on panning/zooming. + */ + constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Gets the x scales for this PanZoom Interaction. + */ + xScales(): QuantitativeScale[]; + /** + * Sets the x scales for this PanZoom Interaction. + * + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + xScales(xScales: QuantitativeScale[]): Interactions.PanZoom; + /** + * Gets the y scales for this PanZoom Interaction. + */ + yScales(): QuantitativeScale[]; + /** + * Sets the y scales for this PanZoom Interaction. + * + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + yScales(yScales: QuantitativeScale[]): Interactions.PanZoom; + /** + * Adds an x scale to this PanZoom Interaction + * + * @param {QuantitativeScale} An x scale to add + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + addXScale(xScale: QuantitativeScale): PanZoom; + /** + * Removes an x scale from this PanZoom Interaction + * + * @param {QuantitativeScale} An x scale to remove + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + removeXScale(xScale: QuantitativeScale): PanZoom; + /** + * Adds a y scale to this PanZoom Interaction + * + * @param {QuantitativeScale} A y scale to add + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + addYScale(yScale: QuantitativeScale): PanZoom; + /** + * Removes a y scale from this PanZoom Interaction + * + * @param {QuantitativeScale} A y scale to remove + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + removeYScale(yScale: QuantitativeScale): PanZoom; + /** + * Gets the minimum domain extent for the scale, specifying the minimum allowable amount + * between the ends of the domain. + * + * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale + * + * @param {QuantitativeScale} quantitativeScale The scale to query + * @returns {D} The minimum domain extent for the scale. + */ + minDomainExtent(quantitativeScale: QuantitativeScale): D; + /** + * Sets the minimum domain extent for the scale, specifying the minimum allowable amount + * between the ends of the domain. + * + * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale + * + * @param {QuantitativeScale} quantitativeScale The scale to query + * @param {D} minDomainExtent The minimum domain extent for the scale. + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + minDomainExtent(quantitativeScale: QuantitativeScale, minDomainExtent: D): Interactions.PanZoom; + /** + * Gets the maximum domain extent for the scale, specifying the maximum allowable amount + * between the ends of the domain. + * + * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale + * + * @param {QuantitativeScale} quantitativeScale The scale to query + * @returns {D} The maximum domain extent for the scale. + */ + maxDomainExtent(quantitativeScale: QuantitativeScale): D; + /** + * Sets the maximum domain extent for the scale, specifying the maximum allowable amount + * between the ends of the domain. + * + * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale + * + * @param {QuantitativeScale} quantitativeScale The scale to query + * @param {D} minDomainExtent The maximum domain extent for the scale. + * @returns {Interactions.PanZoom} The calling PanZoom Interaction. + */ + maxDomainExtent(quantitativeScale: QuantitativeScale, maxDomainExtent: D): Interactions.PanZoom; + } + } +} + + +declare module Plottable { + type DragCallback = (start: Point, end: Point) => void; + module Interactions { + class Drag extends Interaction { + protected _anchor(component: Component): void; + protected _unanchor(): void; + /** + * Gets whether the Drag Interaction constrains Points passed to its + * callbacks to lie inside its Component. + * + * If true, when the user drags outside of the Component, the closest Point + * inside the Component will be passed to the callback instead of the actual + * cursor position. + * + * @return {boolean} + */ + constrainedToComponent(): boolean; + /** + * Sets whether the Drag Interaction constrains Points passed to its + * callbacks to lie inside its Component. + * + * If true, when the user drags outside of the Component, the closest Point + * inside the Component will be passed to the callback instead of the actual + * cursor position. + * + * @param {boolean} + * @return {Interactions.Drag} The calling Drag Interaction. + */ + constrainedToComponent(constrainedToComponent: boolean): Drag; + /** + * Adds a callback to be called when dragging starts. + * + * @param {DragCallback} callback + * @returns {Drag} The calling Drag Interaction. + */ + onDragStart(callback: DragCallback): Drag; + /** + * Removes a callback that would be called when dragging starts. + * + * @param {DragCallback} callback + * @returns {Drag} The calling Drag Interaction. + */ + offDragStart(callback: DragCallback): Drag; + /** + * Adds a callback to be called during dragging. + * + * @param {DragCallback} callback + * @returns {Drag} The calling Drag Interaction. + */ + onDrag(callback: DragCallback): Drag; + /** + * Removes a callback that would be called during dragging. + * + * @param {DragCallback} callback + * @returns {Drag} The calling Drag Interaction. + */ + offDrag(callback: DragCallback): Drag; + /** + * Adds a callback to be called when dragging ends. + * + * @param {DragCallback} callback + * @returns {Drag} The calling Drag Interaction. + */ + onDragEnd(callback: DragCallback): Drag; + /** + * Removes a callback that would be called when dragging ends. + * + * @param {DragCallback} callback + * @returns {Drag} The calling Drag Interaction. + */ + offDragEnd(callback: DragCallback): Drag; + } + } +} + + +declare module Plottable { + type DragBoxCallback = (bounds: Bounds) => void; + module Components { + class DragBoxLayer extends Components.SelectionBoxLayer { + protected _hasCorners: boolean; + /** + * Constructs a DragBoxLayer. + * + * A DragBoxLayer is a SelectionBoxLayer with a built-in Drag Interaction. + * A drag gesture will set the Bounds of the box. + * If resizing is enabled using resizable(true), the edges of box can be repositioned. + * + * @constructor + */ + constructor(); + protected _setup(): void; + renderImmediately(): DragBoxLayer; + /** + * Gets the detection radius of the drag box in pixels. + */ + detectionRadius(): number; + /** + * Sets the detection radius of the drag box in pixels. + * + * @param {number} r + * @return {DragBoxLayer} The calling DragBoxLayer. + */ + detectionRadius(r: number): DragBoxLayer; + /** + * Gets whether or not the drag box is resizable. + */ + resizable(): boolean; + /** + * Sets whether or not the drag box is resizable. + * + * @param {boolean} canResize + * @return {DragBoxLayer} The calling DragBoxLayer. + */ + resizable(canResize: boolean): DragBoxLayer; + protected _setResizableClasses(canResize: boolean): void; + /** + * Gets whether or not the drag box is movable. + */ + movable(): boolean; + /** + * Sets whether or not the drag box is movable. + * + * @param {boolean} movable + * @return {DragBoxLayer} The calling DragBoxLayer. + */ + movable(movable: boolean): DragBoxLayer; + /** + * Sets the callback to be called when dragging starts. + * + * @param {DragBoxCallback} callback + * @returns {DragBoxLayer} The calling DragBoxLayer. + */ + onDragStart(callback: DragBoxCallback): DragBoxLayer; + /** + * Removes a callback to be called when dragging starts. + * + * @param {DragBoxCallback} callback + * @returns {DragBoxLayer} The calling DragBoxLayer. + */ + offDragStart(callback: DragBoxCallback): DragBoxLayer; + /** + * Sets a callback to be called during dragging. + * + * @param {DragBoxCallback} callback + * @returns {DragBoxLayer} The calling DragBoxLayer. + */ + onDrag(callback: DragBoxCallback): DragBoxLayer; + /** + * Removes a callback to be called during dragging. + * + * @param {DragBoxCallback} callback + * @returns {DragBoxLayer} The calling DragBoxLayer. + */ + offDrag(callback: DragBoxCallback): DragBoxLayer; + /** + * Sets a callback to be called when dragging ends. + * + * @param {DragBoxCallback} callback + * @returns {DragBoxLayer} The calling DragBoxLayer. + */ + onDragEnd(callback: DragBoxCallback): DragBoxLayer; + /** + * Removes a callback to be called when dragging ends. + * + * @param {DragBoxCallback} callback + * @returns {DragBoxLayer} The calling DragBoxLayer. + */ + offDragEnd(callback: DragBoxCallback): DragBoxLayer; + /** + * Gets the internal Interactions.Drag of the DragBoxLayer. + */ + dragInteraction(): Interactions.Drag; + /** + * Enables or disables the interaction and drag box. + */ + enabled(enabled: boolean): DragBoxLayer; + /** + * Gets the enabled state. + */ + enabled(): boolean; + destroy(): void; + detach(): Component; + anchor(selection: d3.Selection): Component; + } + } +} + + +declare module Plottable { + module Components { + class XDragBoxLayer extends DragBoxLayer { + /** + * An XDragBoxLayer is a DragBoxLayer whose size can only be set in the X-direction. + * The y-values of the bounds() are always set to 0 and the height() of the XDragBoxLayer. + * + * @constructor + */ + constructor(); + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XDragBoxLayer; + protected _setBounds(newBounds: Bounds): void; + protected _setResizableClasses(canResize: boolean): void; + yScale(): QuantitativeScale; + yScale(yScale: QuantitativeScale): SelectionBoxLayer; + yExtent(): (number | { + valueOf(): number; + })[]; + yExtent(yExtent: (number | { + valueOf(): number; + })[]): SelectionBoxLayer; + } + } +} + + +declare module Plottable { + module Components { + class YDragBoxLayer extends DragBoxLayer { + /** + * A YDragBoxLayer is a DragBoxLayer whose size can only be set in the Y-direction. + * The x-values of the bounds() are always set to 0 and the width() of the YDragBoxLayer. + * + * @constructor + */ + constructor(); + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): YDragBoxLayer; + protected _setBounds(newBounds: Bounds): void; + protected _setResizableClasses(canResize: boolean): void; + xScale(): QuantitativeScale; + xScale(xScale: QuantitativeScale): SelectionBoxLayer; + xExtent(): (number | { + valueOf(): number; + })[]; + xExtent(xExtent: (number | { + valueOf(): number; + })[]): SelectionBoxLayer; + } + } +} + + +declare module Plottable { + interface DragLineCallback { + (dragLineLayer: Components.DragLineLayer): void; + } + module Components { + class DragLineLayer extends GuideLineLayer { + constructor(orientation: string); + protected _setup(): void; + renderImmediately(): DragLineLayer; + /** + * Gets the detection radius of the drag line in pixels. + */ + detectionRadius(): number; + /** + * Sets the detection radius of the drag line in pixels. + * + * @param {number} detectionRadius + * @return {DragLineLayer} The calling DragLineLayer. + */ + detectionRadius(detectionRadius: number): DragLineLayer; + /** + * Gets whether the DragLineLayer is enabled. + */ + enabled(): boolean; + /** + * Enables or disables the DragLineLayer. + * + * @param {boolean} enabled + * @return {DragLineLayer} The calling DragLineLayer. + */ + enabled(enabled: boolean): DragLineLayer; + /** + * Sets the callback to be called when dragging starts. + * The callback will be passed the calling DragLineLayer. + * + * @param {DragLineCallback} callback + * @returns {DragLineLayer} The calling DragLineLayer. + */ + onDragStart(callback: DragLineCallback): DragLineLayer; + /** + * Removes a callback that would be called when dragging starts. + * + * @param {DragLineCallback} callback + * @returns {DragLineLayer} The calling DragLineLayer. + */ + offDragStart(callback: DragLineCallback): DragLineLayer; + /** + * Sets a callback to be called during dragging. + * The callback will be passed the calling DragLineLayer. + * + * @param {DragLineCallback} callback + * @returns {DragLineLayer} The calling DragLineLayer. + */ + onDrag(callback: DragLineCallback): DragLineLayer; + /** + * Removes a callback that would be called during dragging. + * + * @param {DragLineCallback} callback + * @returns {DragLineLayer} The calling DragLineLayer. + */ + offDrag(callback: DragLineCallback): DragLineLayer; + /** + * Sets a callback to be called when dragging ends. + * The callback will be passed the calling DragLineLayer. + * + * @param {DragLineCallback} callback + * @returns {DragLineLayer} The calling DragLineLayer. + */ + onDragEnd(callback: DragLineCallback): DragLineLayer; + /** + * Removes a callback that would be called when dragging ends. + * + * @param {DragLineCallback} callback + * @returns {DragLineLayer} The calling DragLineLayer. + */ + offDragEnd(callback: DragLineCallback): DragLineLayer; + destroy(): void; + } + } +} diff --git a/plottable.js b/plottable.js index b7f289c235..b2fd453065 100644 --- a/plottable.js +++ b/plottable.js @@ -914,6 +914,15 @@ var Plottable; /// var Plottable; (function (Plottable) { + var KeyFunctions = (function () { + function KeyFunctions() { + } + KeyFunctions.counter = 0; + KeyFunctions.noConstancy = function (d) { return KeyFunctions.counter++; }; + KeyFunctions.byIndex = function (d, i) { return i; }; + return KeyFunctions; + })(); + Plottable.KeyFunctions = KeyFunctions; var Dataset = (function () { /** * A Dataset contains an array of data and some metadata. @@ -926,6 +935,7 @@ var Plottable; function Dataset(data, metadata) { if (data === void 0) { data = []; } if (metadata === void 0) { metadata = {}; } + this._key = KeyFunctions.noConstancy; this._data = data; this._metadata = metadata; this._callbacks = new Plottable.Utils.CallbackSet(); @@ -970,6 +980,16 @@ var Plottable; return this; } }; + Dataset.prototype.key = function (key) { + if (key == null) { + return this._key; + } + else { + this._key = key; + this._callbacks.callCallbacks(this); + return this; + } + }; return Dataset; })(); Plottable.Dataset = Dataset; @@ -2664,7 +2684,14 @@ var Plottable; * @param{any[]} data The data to be drawn */ Drawer.prototype._bindSelectionData = function (data) { - var dataElements = this.selection().data(data); + // if the dataset has a key, use it when binding the data + var dataElements; + if (this._dataset && this._dataset.key) { + dataElements = this.selection().data(data, this._dataset.key()); + } + else { + dataElements = this.selection().data(data); + } dataElements.enter().append(this._svgElementName); dataElements.exit().remove(); this._applyDefaultAttributes(dataElements); @@ -8251,11 +8278,6 @@ var Plottable; }; Scatter.prototype._generateDrawSteps = function () { var drawSteps = []; - if (this._animateOnNextRender()) { - var resetAttrToProjector = this._generateAttrToProjector(); - resetAttrToProjector["d"] = function () { return ""; }; - drawSteps.push({ attrToProjector: resetAttrToProjector, animator: this._getAnimator(Plots.Animator.RESET) }); - } drawSteps.push({ attrToProjector: this._generateAttrToProjector(), animator: this._getAnimator(Plots.Animator.MAIN) }); return drawSteps; }; From 485a77e78751cc17d6285bcdc707cce61648f08c Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 23:37:52 +1000 Subject: [PATCH 07/19] noConstancy counter exposed --- src/core/dataset.ts | 12 +++++++++--- src/drawers/drawer.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index d979d77968..91e6a95786 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -4,10 +4,16 @@ module Plottable { export type DatasetCallback = (dataset: Dataset) => void; + export class KeyFunctions { - protected static counter: number = 0; - public static noConstancy: (d: any, i: number) => any = (d: any) => { return KeyFunctions.counter++; }; - public static byIndex: (d: any, i: number) => any = (d: any, i: number) => { return i; }; + public static counter: number = 0; + public static noConstancy: (d: any, i: number) => any = (d: any, i: number) => { + + return KeyFunctions.counter++; + }; + public static byIndex: (d: any, i: number) => any = (d: any, i: number) => { + return i; + }; } export class Dataset { diff --git a/src/drawers/drawer.ts b/src/drawers/drawer.ts index 81f93502a9..02f753989c 100644 --- a/src/drawers/drawer.ts +++ b/src/drawers/drawer.ts @@ -78,7 +78,7 @@ export class Drawer { private _bindSelectionData(data: any[]) { // if the dataset has a key, use it when binding the data let dataElements: d3.selection.Update; - if (this._dataset && this._dataset.key) { + if (this._dataset && this._dataset.key()) { dataElements = this.selection().data(data, this._dataset.key()); } else { dataElements = this.selection().data(data); From a17d397ecaba5105a8a7ccb0fac70dd2a614fc28 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 23:48:46 +1000 Subject: [PATCH 08/19] byIndex is default --- src/core/dataset.ts | 5 ++--- test/core/keyTests.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 91e6a95786..48685f0b36 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -6,9 +6,8 @@ export type DatasetCallback = (dataset: Dataset) => void; export class KeyFunctions { - public static counter: number = 0; + protected static counter: number = 0; public static noConstancy: (d: any, i: number) => any = (d: any, i: number) => { - return KeyFunctions.counter++; }; public static byIndex: (d: any, i: number) => any = (d: any, i: number) => { @@ -19,7 +18,7 @@ export class KeyFunctions { export class Dataset { private _data: any[]; private _metadata: any; - private _key: (datum: any, index: number) => any = KeyFunctions.noConstancy; + private _key: (datum: any, index: number) => any = KeyFunctions.byIndex; private _callbacks: Utils.CallbackSet; /** diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts index 8d894b697d..971814223f 100644 --- a/test/core/keyTests.ts +++ b/test/core/keyTests.ts @@ -15,9 +15,9 @@ describe("DatasetKey", () => { let b: number = ds.key()(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); - it(" defaults to noConstancy predefined key function", () => { + it(" defaults to byIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - assert.isTrue(ds.key() === Plottable.KeyFunctions.noConstancy, "noConstancy is default"); + assert.isTrue(ds.key() === Plottable.KeyFunctions.byIndex, "byIndex is default"); }); it(" may accept ByIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); From c35fea5ec5fd38a8a8348f0585a2e49b8d28d5b3 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 2 Oct 2015 23:53:07 +1000 Subject: [PATCH 09/19] consecutive blank lines --- src/core/dataset.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 48685f0b36..4924f5d1c2 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -4,7 +4,6 @@ module Plottable { export type DatasetCallback = (dataset: Dataset) => void; - export class KeyFunctions { protected static counter: number = 0; public static noConstancy: (d: any, i: number) => any = (d: any, i: number) => { From e0f25c62193816663d29c4e58ba9464746aaf9da Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Sun, 4 Oct 2015 17:32:46 +1100 Subject: [PATCH 10/19] plottable.d.ts fix in gruntfile --- Gruntfile.js | 16 +-- plottable.d.ts | 304 ++++++++++++++++++++++++------------------------- 2 files changed, 161 insertions(+), 159 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 596aa17666..4e4fa4607d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -50,14 +50,16 @@ module.exports = function(grunt) { prereleaseName: "rc" } }; - - var prefixMatch = "\\n *(function |var |static )?"; + + + var regexLF = (grunt.util.linefeed == "\r\n" ? "(\\u000D\\n)" : "\\n"); + var prefixMatch = "\\n *(function |var |static )?".replace("\\n",regexLF); var varNameMatch = "[^(:;]*(\\([^)]*\\))?"; // catch function args too var nestedBraceMatch = ": \\{[^{}]*\\}"; var typeNameMatch = ": [^;]*"; - var finalMatch = "((" + nestedBraceMatch + ")|(" + typeNameMatch + "))?\\n?;"; - var jsdocInit = "\\n *\\/\\*\\* *\\n"; - var jsdocMid = "( *\\*[^\\n]*\\n)+"; + var finalMatch = "((" + nestedBraceMatch + ")|(" + typeNameMatch + "))?\\n?;".replace("\\n", regexLF); + var jsdocInit = "\\n *\\/\\*\\* *\\n".replace("\\n", regexLF); + var jsdocMid = "( *\\*[^\\n]*\\n)+".replace("\\n", regexLF); var jsdocEnd = " *\\*\\/ *"; var jsdoc = "(" + jsdocInit + jsdocMid + jsdocEnd + ")?"; @@ -92,7 +94,7 @@ module.exports = function(grunt) { // on each recompile var updateTsFiles = function() { tsFiles = grunt.file.read("src/reference.ts") - .split("\n") + .split(grunt.util.linefeed) .filter(function(s) { return s !== ""; }).map(function(s) { @@ -104,7 +106,7 @@ module.exports = function(grunt) { var testTsFiles; var updateTestTsFiles = function() { testTsFiles = grunt.file.read("test/testReference.ts") - .split("\n") + .split(grunt.util.linefeed) .filter(function(s) { return s !== ""; }).map(function(s) { diff --git a/plottable.d.ts b/plottable.d.ts index 765d4f2c23..79ea81ab02 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -66,7 +66,7 @@ declare module Plottable { * Shim for ES6 map. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map */ - class Map { + class Map { constructor(); set(key: K, value: V): Map; get(key: K): V; @@ -85,7 +85,7 @@ declare module Plottable { * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set */ class Set { - size: number; + size: number; constructor(); add(value: T): Set; delete(value: T): boolean; @@ -349,7 +349,7 @@ declare module Plottable { declare module Plottable { module Utils { - class ClientToSVGTranslator { + class ClientToSVGTranslator { /** * Returns the ClientToSVGTranslator for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -395,7 +395,7 @@ declare module Plottable { static noConstancy: (d: any, i: number) => any; static byIndex: (d: any, i: number) => any; } - class Dataset { + class Dataset { /** * A Dataset contains an array of data and some metadata. * Changes to the data or metadata will cause anything subscribed to the Dataset to update. @@ -484,7 +484,7 @@ declare module Plottable { * Generally an inferior way to render compared to `requestAnimationFrame`, * but useful for browsers that don't suppoort `requestAnimationFrame`. */ - class Timeout implements RenderPolicy { + class Timeout implements RenderPolicy { render(): void; } } @@ -766,7 +766,7 @@ declare module Plottable { (scale: QuantitativeScale): D[]; } } - class Scale { + class Scale { /** * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. * @@ -862,7 +862,7 @@ declare module Plottable { declare module Plottable { class QuantitativeScale extends Scale { - protected static _DEFAULT_NUM_TICKS: number; + protected static _DEFAULT_NUM_TICKS: number; /** * A QuantitativeScale is a Scale that maps number-like values to numbers. * It is invertible and continuous. @@ -901,7 +901,7 @@ declare module Plottable { * @param {number} padProportion The padding proportion. Passing 0 disables padding. * @returns {QuantitativeScale} The calling QuantitativeScale. */ - padProportion(padProportion: number): QuantitativeScale; + padProportion(padProportion: number): QuantitativeScale; /** * Gets whether or not the scale snaps its domain to nice values. */ @@ -979,7 +979,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Linear extends QuantitativeScale { + class Linear extends QuantitativeScale { /** * @constructor */ @@ -1001,7 +1001,7 @@ declare module Plottable { declare module Plottable { module Scales { - class ModifiedLog extends QuantitativeScale { + class ModifiedLog extends QuantitativeScale { /** * A ModifiedLog Scale acts as a regular log scale for large numbers. * As it approaches 0, it gradually becomes linear. @@ -1028,7 +1028,7 @@ declare module Plottable { * second is that, for values less than 10, an increasingly large * (0 to 1) scaling factor is added such that at 0 the value is * adjusted to 1, resulting in a returned result of 0. - */ + */ scale(x: number): number; invert(x: number): number; protected _getDomain(): number[]; @@ -1047,14 +1047,14 @@ declare module Plottable { * * This function will generate clusters as large as it can while not * drastically exceeding its number of ticks. - */ + */ /** * How many ticks does the range [lower, upper] deserve? * * e.g. if your domain was [10, 1000] and I asked _howManyTicks(10, 100), * I would get 1/2 of the ticks. The range 10, 100 takes up 1/2 of the * distance when plotted. - */ + */ protected _niceDomain(domain: number[], count?: number): number[]; protected _defaultExtent(): number[]; protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; @@ -1068,7 +1068,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Category extends Scale { + class Category extends Scale { /** * A Category Scale maps strings to numbers. * @@ -1081,7 +1081,7 @@ declare module Plottable { domain(values: string[]): Category; protected _setDomain(values: string[]): void; range(): [number, number]; - range(values: [number, number]): Category; + range(values: [number, number]): Category; /** * Returns the width of the range band. * @@ -1144,7 +1144,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Color extends Scale { + class Color extends Scale { /** * A Color Scale maps string values to color hex values expressed as a string. * @@ -1156,7 +1156,7 @@ declare module Plottable { constructor(scaleType?: string); extentOfValues(values: string[]): string[]; protected _getExtent(): string[]; - static invalidateColorCache(): void; + static invalidateColorCache(): void; /** * Returns the color-string corresponding to a given string. * If there are not enough colors in the range(), a lightened version of an existing color will be used. @@ -1176,7 +1176,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Time extends QuantitativeScale { + class Time extends QuantitativeScale { /** * A Time Scale maps Date objects to numbers. * @@ -1217,7 +1217,7 @@ declare module Plottable { class InterpolatedColor extends Scale { static REDS: string[]; static BLUES: string[]; - static POSNEG: string[]; + static POSNEG: string[]; /** * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. * @@ -1227,10 +1227,10 @@ declare module Plottable { extentOfValues(values: number[]): number[]; /** * Generates the converted QuantitativeScale. - */ + */ /** * Generates the d3 interpolator for colors. - */ + */ autoDomain(): InterpolatedColor; scale(value: number): string; protected _getDomain(): number[]; @@ -1293,9 +1293,9 @@ declare module Plottable { animator: Animator; }; } - class Drawer { + class Drawer { protected _svgElementName: string; - protected _className: string; + protected _className: string; /** * A Drawer draws svg elements based on the input Dataset. * @@ -1322,13 +1322,13 @@ declare module Plottable { * Binds data to selection * * @param{any[]} data The data to be drawn - */ + */ protected _applyDefaultAttributes(selection: d3.Selection): void; /** * Draws data using one step * * @param{AppliedDrawStep} step The step, how data should be drawn. - */ + */ /** * Calculates the total time it takes to use the input drawSteps to draw the input data * @@ -1437,11 +1437,11 @@ declare module Plottable { static CENTER: string; } } - class Component { - protected _boundingBox: d3.Selection; - protected _clipPathEnabled: boolean; + class Component { + protected _boundingBox: d3.Selection; + protected _clipPathEnabled: boolean; protected _isSetup: boolean; - protected _isAnchored: boolean; + protected _isAnchored: boolean; constructor(); /** * Attaches the Component as a child of a given d3 Selection. @@ -1500,7 +1500,7 @@ declare module Plottable { * * @returns {Component} The calling Component. */ - render(): Component; + render(): Component; /** * Renders the Component without waiting for the next frame. */ @@ -1542,7 +1542,7 @@ declare module Plottable { * @param {string} yAlignment The y alignment of the Component ("top"/"center"/"bottom"). * @returns {Component} The calling Component. */ - yAlignment(yAlignment: string): Component; + yAlignment(yAlignment: string): Component; /** * Checks if the Component has a given CSS class. * @@ -1660,7 +1660,7 @@ declare module Plottable { declare module Plottable { - class ComponentContainer extends Component { + class ComponentContainer extends Component { constructor(); anchor(selection: d3.Selection): ComponentContainer; render(): ComponentContainer; @@ -1694,7 +1694,7 @@ declare module Plottable { declare module Plottable { module Components { - class Group extends ComponentContainer { + class Group extends ComponentContainer { /** * Constructs a Group. * @@ -1762,13 +1762,13 @@ declare module Plottable { /** * The css class applied to each annotation label, which shows the formatted annotation text. */ - static ANNOTATION_LABEL_CLASS: string; + static ANNOTATION_LABEL_CLASS: string; protected _tickMarkContainer: d3.Selection; protected _tickLabelContainer: d3.Selection; protected _baseline: d3.Selection; - protected _scale: Scale; + protected _scale: Scale; protected _computedWidth: number; - protected _computedHeight: number; + protected _computedHeight: number; /** * Constructs an Axis. * An Axis is a visual representation of a Scale. @@ -1830,14 +1830,14 @@ declare module Plottable { * @returns {Axis} The calling Axis. */ annotationTierCount(annotationTierCount: number): Axis; - protected _drawAnnotations(): void; + protected _drawAnnotations(): void; /** * Retrieves the size of the core pieces. * * The core pieces include the labels, the end tick marks, the inner tick marks, and the tick label padding. */ protected _coreSize(): number; - protected _annotationTierHeight(): number; + protected _annotationTierHeight(): number; protected _removeAnnotations(): void; protected _generateBaselineAttrHash(): { [key: string]: number; @@ -1981,7 +1981,7 @@ declare module Plottable { /** * The CSS class applied to each Time Axis tier */ - static TIME_AXIS_TIER_CLASS: string; + static TIME_AXIS_TIER_CLASS: string; /** * Constructs a Time Axis. * @@ -2017,20 +2017,20 @@ declare module Plottable { axisConfigurations(configurations: TimeAxisConfiguration[]): Time; /** * Gets the index of the most precise TimeAxisConfiguration that will fit in the current width. - */ + */ orientation(): string; orientation(orientation: string): Time; - protected _computeHeight(): number; + protected _computeHeight(): number; /** * Check if tier configuration fits in the current width. - */ + */ protected _sizeFromOffer(availableWidth: number, availableHeight: number): { width: number; height: number; }; - protected _setup(): void; - protected _getTickValues(): any[]; - renderImmediately(): Time; + protected _setup(): void; + protected _getTickValues(): any[]; + renderImmediately(): Time; } } } @@ -2038,7 +2038,7 @@ declare module Plottable { declare module Plottable { module Axes { - class Numeric extends Axis { + class Numeric extends Axis { /** * Constructs a Numeric Axis. * @@ -2050,14 +2050,14 @@ declare module Plottable { */ constructor(scale: QuantitativeScale, orientation: string); protected _setup(): void; - protected _computeWidth(): number; + protected _computeWidth(): number; protected _computeHeight(): number; protected _getTickValues(): number[]; protected _rescale(): void; - renderImmediately(): Numeric; + renderImmediately(): Numeric; /** * Hides the Tick Marks which have no corresponding Tick Labels - */ + */ /** * Gets the tick label position relative to the tick marks. * @@ -2087,7 +2087,7 @@ declare module Plottable { * @param {boolean} The new text width approximation setting. * @returns {Axes.Numeric} The calling Axes.Numeric. */ - usesTextWidthApproximation(enable: boolean): Axes.Numeric; + usesTextWidthApproximation(enable: boolean): Axes.Numeric; /** * The method is responsible for evenly spacing the labels on the axis. * @return test to see if taking every `interval` recrangle from `rects` @@ -2097,7 +2097,7 @@ declare module Plottable { * between the labels to be 3x, such that the label will be `padding` distance * from the tick and 2 * `padding` distance (or more) from the next tick * - */ + */ } } } @@ -2105,7 +2105,7 @@ declare module Plottable { declare module Plottable { module Axes { - class Category extends Axis { + class Category extends Axis { /** * Constructs a Category Axis. * @@ -2136,13 +2136,13 @@ declare module Plottable { /** * Measures the size of the ticks while also writing them to the DOM. * @param {d3.Selection} ticks The tick elements to be written to. - */ + */ /** * Measures the size of the ticks without making any (permanent) DOM * changes. * * @param {string[]} ticks The strings that will be printed on the ticks. - */ + */ renderImmediately(): Category; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; } @@ -2152,7 +2152,7 @@ declare module Plottable { declare module Plottable { module Components { - class Label extends Component { + class Label extends Component { /** * A Label is a Component that displays a single line of text. * @@ -2236,7 +2236,7 @@ declare module Plottable { /** * The css class applied to each legend symbol */ - static LEGEND_SYMBOL_CLASS: string; + static LEGEND_SYMBOL_CLASS: string; /** * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. * @@ -2296,8 +2296,8 @@ declare module Plottable { * @returns {Legend} The calling Legend. */ colorScale(colorScale: Scales.Color): Legend; - destroy(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + destroy(): void; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; /** * Gets the Entities (representing Legend entries) at a particular point. * Returns an empty array if no Entities are present at that location. @@ -2342,7 +2342,7 @@ declare module Plottable { declare module Plottable { module Components { - class InterpolatedColorLegend extends Component { + class InterpolatedColorLegend extends Component { /** * The css class applied to the legend labels. */ @@ -2380,7 +2380,7 @@ declare module Plottable { * @param {expands} boolean * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. */ - expands(expands: boolean): InterpolatedColorLegend; + expands(expands: boolean): InterpolatedColorLegend; /** * Gets the orientation. */ @@ -2393,9 +2393,9 @@ declare module Plottable { */ orientation(orientation: string): InterpolatedColorLegend; fixedWidth(): boolean; - fixedHeight(): boolean; + fixedHeight(): boolean; protected _setup(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; renderImmediately(): InterpolatedColorLegend; } } @@ -2404,7 +2404,7 @@ declare module Plottable { declare module Plottable { module Components { - class Gridlines extends Component { + class Gridlines extends Component { /** * @constructor * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. @@ -2414,7 +2414,7 @@ declare module Plottable { destroy(): Gridlines; protected _setup(): void; renderImmediately(): Gridlines; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; } } } @@ -2422,7 +2422,7 @@ declare module Plottable { declare module Plottable { module Components { - class Table extends ComponentContainer { + class Table extends ComponentContainer { /** * A Table combines Components in the form of a grid. A * common case is combining a y-axis, x-axis, and the plotted data via @@ -2457,7 +2457,7 @@ declare module Plottable { * @returns {Table} The calling Table. */ add(component: Component, row: number, col: number): Table; - protected _remove(component: Component): boolean; + protected _remove(component: Component): boolean; requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; /** @@ -2532,7 +2532,7 @@ declare module Plottable { */ columnWeight(index: number, weight: number): Table; fixedWidth(): boolean; - fixedHeight(): boolean; + fixedHeight(): boolean; } } } @@ -2545,7 +2545,7 @@ declare module Plottable { PIXEL = 1, } class SelectionBoxLayer extends Component { - protected _box: d3.Selection; + protected _box: d3.Selection; protected _xBoundsMode: PropertyMode; protected _yBoundsMode: PropertyMode; constructor(); @@ -2565,7 +2565,7 @@ declare module Plottable { * @return {SelectionBoxLayer} The calling SelectionBoxLayer. */ bounds(newBounds: Bounds): SelectionBoxLayer; - protected _setBounds(newBounds: Bounds): void; + protected _setBounds(newBounds: Bounds): void; renderImmediately(): SelectionBoxLayer; /** * Gets whether the box is being shown. @@ -2621,7 +2621,7 @@ declare module Plottable { */ xExtent(xExtent: (number | { valueOf(): number; - })[]): SelectionBoxLayer; + })[]): SelectionBoxLayer; protected _setXExtent(xExtent: (number | { valueOf(): number; })[]): void; @@ -2638,7 +2638,7 @@ declare module Plottable { */ yExtent(yExtent: (number | { valueOf(): number; - })[]): SelectionBoxLayer; + })[]): SelectionBoxLayer; protected _setYExtent(yExtent: (number | { valueOf(): number; })[]): void; @@ -2652,7 +2652,7 @@ declare module Plottable { module Components { class GuideLineLayer extends Component { static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; + static ORIENTATION_HORIZONTAL: string; constructor(orientation: string); protected _setup(): void; protected _sizeFromOffer(availableWidth: number, availableHeight: number): { @@ -2663,7 +2663,7 @@ declare module Plottable { fixedWidth(): boolean; fixedHeight(): boolean; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): GuideLineLayer; - renderImmediately(): GuideLineLayer; + renderImmediately(): GuideLineLayer; protected _setPixelPositionWithoutChangingMode(pixelPosition: number): void; /** * Gets the QuantitativeScale on the GuideLineLayer. @@ -2731,9 +2731,9 @@ declare module Plottable { } } class Plot extends Component { - protected static _ANIMATION_MAX_DURATION: number; - protected _renderArea: d3.Selection; - protected _renderCallback: ScaleCallback>; + protected static _ANIMATION_MAX_DURATION: number; + protected _renderArea: d3.Selection; + protected _renderCallback: ScaleCallback>; protected _propertyExtents: d3.Map; protected _propertyBindings: d3.Map>; /** @@ -2773,7 +2773,7 @@ declare module Plottable { * @returns {Plot} The calling Plot. */ attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; - protected _bindProperty(property: string, value: any, scale: Scale): void; + protected _bindProperty(property: string, value: any, scale: Scale): void; protected _generateAttrToProjector(): AttributeToProjector; renderImmediately(): Plot; /** @@ -2787,17 +2787,17 @@ declare module Plottable { detach(): Plot; /** * @returns {Scale[]} A unique array of all scales currently used by the Plot. - */ + */ /** * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. */ - protected _updateExtents(): void; + protected _updateExtents(): void; protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): Accessor; + protected _filterForProperty(property: string): Accessor; /** * Override in subclass to add special extents, such as included values */ - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; /** * Get the Animator associated with the specified Animator key. * @@ -2834,7 +2834,7 @@ declare module Plottable { protected _getDrawersInOrder(): Drawer[]; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _additionalPaint(time: number): void; - protected _getDataToDraw(): Utils.Map; + protected _getDataToDraw(): Utils.Map; /** * Retrieves Selections of this Plot for the specified Datasets. * @@ -2850,7 +2850,7 @@ declare module Plottable { * If not provided, returns defaults to all Datasets on the Plot. * @return {Plots.PlotEntity[]} */ - entities(datasets?: Dataset[]): Plots.PlotEntity[]; + entities(datasets?: Dataset[]): Plots.PlotEntity[]; /** * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. * @@ -2875,7 +2875,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Pie extends Plot { + class Pie extends Plot { /** * @constructor */ @@ -2976,14 +2976,14 @@ declare module Plottable { */ labelFormatter(formatter: Formatter): Pie; entitiesAt(queryPoint: Point): PlotEntity[]; - protected _propertyProjectors(): AttributeToProjector; + protected _propertyProjectors(): AttributeToProjector; protected _getDataToDraw(): Utils.Map; protected static _isValidData(value: any): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): { x: number; y: number; }; - protected _additionalPaint(time: number): void; + protected _additionalPaint(time: number): void; } } } @@ -2992,7 +2992,7 @@ declare module Plottable { declare module Plottable { class XYPlot extends Plot { protected static _X_KEY: string; - protected static _Y_KEY: string; + protected static _Y_KEY: string; /** * An XYPlot is a Plot that displays data along two primary directions, X and Y. * @@ -3056,7 +3056,7 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ y(y: Y | Accessor, yScale: Scale): XYPlot; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; protected _uninstallScaleForKey(scale: Scale, key: string): void; protected _installScaleForKey(scale: Scale, key: string): void; destroy(): XYPlot; @@ -3075,14 +3075,14 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ autorangeMode(autorangeMode: string): XYPlot; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; /** * Adjusts the domains of both X and Y scales to show all data. * This call does not override the autorange() behavior. * * @returns {XYPlot} The calling XYPlot. */ - showAllData(): XYPlot; + showAllData(): XYPlot; protected _projectorsReady(): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _getDataToDraw(): Utils.Map; @@ -3092,7 +3092,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Rectangle extends XYPlot { + class Rectangle extends XYPlot { /** * A Rectangle Plot displays rectangles based on the data. * The left and right edges of each rectangle can be set with x() and x2(). @@ -3197,7 +3197,7 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; /** * Gets the accessor for labels. * @@ -3229,9 +3229,9 @@ declare module Plottable { protected _pixelPoint(datum: any, index: number, dataset: Dataset): { x: any; y: any; - }; + }; protected _getDataToDraw(): Utils.Map; - protected _additionalPaint(time: number): void; + protected _additionalPaint(time: number): void; } } } @@ -3239,7 +3239,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Scatter extends XYPlot { + class Scatter extends XYPlot { /** * A Scatter Plot draws a symbol at each data point. * @@ -3318,8 +3318,8 @@ declare module Plottable { module Plots { class Bar extends XYPlot { static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; - protected _isVertical: boolean; + static ORIENTATION_HORIZONTAL: string; + protected _isVertical: boolean; /** * A Bar Plot draws bars growing out from a baseline to some value * @@ -3426,12 +3426,12 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; protected _additionalPaint(time: number): void; /** * Makes sure the extent takes into account the widths of the bars */ - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; @@ -3443,7 +3443,7 @@ declare module Plottable { * If the position scale of the plot is a QuantitativeScale, then the bar width is equal to the smallest distance between * two adjacent data points, padded for visualisation. */ - protected _getBarPixelWidth(): number; + protected _getBarPixelWidth(): number; entities(datasets?: Dataset[]): PlotEntity[]; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _uninstallScaleForKey(scale: Scale, key: string): void; @@ -3455,7 +3455,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Line extends XYPlot { + class Line extends XYPlot { /** * A Line Plot draws line segments starting from the first data point to the next. * @@ -3480,7 +3480,7 @@ declare module Plottable { * Smooth autoranging is done by making sure lines always exit on the left / right side of the plot * and deactivating the nice domain feature on the scales */ - autorangeSmooth(autorangeSmooth: boolean): Plots.Line; + autorangeSmooth(autorangeSmooth: boolean): Plots.Line; /** * Gets the interpolation function associated with the plot. * @@ -3508,7 +3508,7 @@ declare module Plottable { interpolator(interpolator: "cardinal-closed"): Line; interpolator(interpolator: "monotone"): Line; protected _createDrawer(dataset: Dataset): Drawer; - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { @@ -3531,7 +3531,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Area extends Line { + class Area extends Line { /** * An Area Plot draws a filled region (area) between Y and Y0. * @@ -3558,7 +3558,7 @@ declare module Plottable { addDataset(dataset: Dataset): Area; protected _addDataset(dataset: Dataset): Area; protected _removeDatasetNodes(dataset: Dataset): void; - protected _additionalPaint(): void; + protected _additionalPaint(): void; protected _createDrawer(dataset: Dataset): Drawers.Area; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _updateYScale(): void; @@ -3573,7 +3573,7 @@ declare module Plottable { declare module Plottable { module Plots { - class ClusteredBar extends Bar { + class ClusteredBar extends Bar { /** * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. @@ -3585,7 +3585,7 @@ declare module Plottable { constructor(orientation?: string); protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; + }; protected _getDataToDraw(): Utils.Map; } } @@ -3594,7 +3594,7 @@ declare module Plottable { declare module Plottable { module Plots { - class StackedArea extends Area { + class StackedArea extends Area { /** * @constructor */ @@ -3611,7 +3611,7 @@ declare module Plottable { protected _updateYScale(): void; protected _onDatasetUpdate(): StackedArea; protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; + protected _extentsForProperty(attr: string): any[]; /** * Given an array of Datasets and the accessor function for the key, computes the * set reunion (no duplicates) of the domain of each Dataset. The keys are stringified @@ -3620,7 +3620,7 @@ declare module Plottable { * @param {Dataset[]} datasets The Datasets for which we extract the domain keys * @param {Accessor} keyAccessor The accessor for the key of the data * @return {string[]} An array of stringified keys - */ + */ protected _propertyProjectors(): AttributeToProjector; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; } @@ -3630,7 +3630,7 @@ declare module Plottable { declare module Plottable { module Plots { - class StackedBar extends Bar { + class StackedBar extends Bar { /** * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. * On a vertical StackedBar Plot, the bars with the same X value are stacked. @@ -3653,7 +3653,7 @@ declare module Plottable { }; protected _onDatasetUpdate(): StackedBar; protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; + protected _extentsForProperty(attr: string): any[]; } } } @@ -3661,7 +3661,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Segment extends XYPlot { + class Segment extends XYPlot { /** * A Segment Plot displays line segments based on the data. * @@ -3751,7 +3751,7 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; } } } @@ -3759,7 +3759,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Waterfall extends Bar { + class Waterfall extends Bar { constructor(); /** * Gets whether connectors are enabled. @@ -3791,7 +3791,7 @@ declare module Plottable { protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; }; - protected _onDatasetUpdate(): Waterfall; + protected _onDatasetUpdate(): Waterfall; } } } @@ -3799,7 +3799,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Wheel extends Plot { + class Wheel extends Plot { /** * @constructor */ @@ -3930,19 +3930,19 @@ declare module Plottable { class Easing implements Animator { /** * The default starting delay of the animation in milliseconds - */ + */ /** * The default duration of one animation step in milliseconds - */ + */ /** * The default maximum start delay between each step of an animation - */ + */ /** * The default maximum total animation duration - */ + */ /** * The default easing of the animation - */ + */ /** * Constructs the default animator * @@ -4026,7 +4026,7 @@ declare module Plottable { easingMode(easingMode: string): Easing; /** * Adjust the iterative delay, such that it takes into account the maxTotalDuration constraint - */ + */ } } } @@ -4037,7 +4037,7 @@ declare module Plottable { protected _eventToCallback: { [eventName: string]: (e: Event) => any; }; - protected _callbacks: Utils.CallbackSet[]; + protected _callbacks: Utils.CallbackSet[]; protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; } @@ -4047,7 +4047,7 @@ declare module Plottable { declare module Plottable { module Dispatchers { type MouseCallback = (p: Point, event: MouseEvent) => void; - class Mouse extends Dispatcher { + class Mouse extends Dispatcher { /** * Get a Mouse Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4136,7 +4136,7 @@ declare module Plottable { /** * Computes the mouse position from the given event, and if successful * calls all the callbacks in the provided callbackSet. - */ + */ eventInsideSVG(event: MouseEvent): boolean; /** * Returns the last computed mouse position in coordinate space. @@ -4154,7 +4154,7 @@ declare module Plottable { type TouchCallback = (ids: number[], idToPoint: { [id: number]: Point; }, event: TouchEvent) => void; - class Touch extends Dispatcher { + class Touch extends Dispatcher { /** * Gets a Touch Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4229,7 +4229,7 @@ declare module Plottable { /** * Computes the Touch position from the given event, and if successful * calls all the callbacks in the provided callbackSet. - */ + */ eventInsideSVG(event: TouchEvent): boolean; } } @@ -4239,7 +4239,7 @@ declare module Plottable { declare module Plottable { module Dispatchers { type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; - class Key extends Dispatcher { + class Key extends Dispatcher { /** * Gets a Key Dispatcher. If one already exists it will be returned; * otherwise, a new one will be created. @@ -4279,7 +4279,7 @@ declare module Plottable { * @param {KeyCallback} callback * @return {Dispatchers.Key} The calling Key Dispatcher. */ - offKeyUp(callback: KeyCallback): Key; + offKeyUp(callback: KeyCallback): Key; } } } @@ -4287,7 +4287,7 @@ declare module Plottable { declare module Plottable { class Interaction { - protected _componentAttachedTo: Component; + protected _componentAttachedTo: Component; protected _anchor(component: Component): void; protected _unanchor(): void; /** @@ -4297,7 +4297,7 @@ declare module Plottable { * @param {Component} component * @returns {Interaction} The calling Interaction. */ - attachTo(component: Component): Interaction; + attachTo(component: Component): Interaction; /** * Detaches this Interaction from the Component. * This Interaction can be reused. @@ -4305,7 +4305,7 @@ declare module Plottable { * @param {Component} component * @returns {Interaction} The calling Interaction. */ - detachFrom(component: Component): Interaction; + detachFrom(component: Component): Interaction; /** * Gets whether this Interaction is enabled. */ @@ -4338,9 +4338,9 @@ declare module Plottable { declare module Plottable { type ClickCallback = (point: Point) => void; module Interactions { - class Click extends Interaction { + class Click extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the Component is clicked. * @@ -4362,9 +4362,9 @@ declare module Plottable { declare module Plottable { module Interactions { - class DoubleClick extends Interaction { + class DoubleClick extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the Component is double-clicked. * @@ -4391,9 +4391,9 @@ declare module Plottable { /** * A Key Interaction listens to key events that occur while the Component is * moused over. - */ + */ protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the key with the given keyCode is * pressed and the user is moused over the Component. @@ -4438,9 +4438,9 @@ declare module Plottable { declare module Plottable { type PointerCallback = (point: Point) => void; module Interactions { - class Pointer extends Interaction { + class Pointer extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the pointer enters the Component. * @@ -4493,7 +4493,7 @@ declare module Plottable { class PanZoom extends Interaction { /** * The number of pixels occupied in a line. - */ + */ /** * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale * in response to the user panning or zooming. @@ -4504,7 +4504,7 @@ declare module Plottable { */ constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Gets the x scales for this PanZoom Interaction. */ @@ -4603,9 +4603,9 @@ declare module Plottable { declare module Plottable { type DragCallback = (start: Point, end: Point) => void; module Interactions { - class Drag extends Interaction { + class Drag extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Gets whether the Drag Interaction constrains Points passed to its * callbacks to lie inside its Component. @@ -4679,8 +4679,8 @@ declare module Plottable { declare module Plottable { type DragBoxCallback = (bounds: Bounds) => void; module Components { - class DragBoxLayer extends Components.SelectionBoxLayer { - protected _hasCorners: boolean; + class DragBoxLayer extends Components.SelectionBoxLayer { + protected _hasCorners: boolean; /** * Constructs a DragBoxLayer. * @@ -4690,8 +4690,8 @@ declare module Plottable { * * @constructor */ - constructor(); - protected _setup(): void; + constructor(); + protected _setup(): void; renderImmediately(): DragBoxLayer; /** * Gets the detection radius of the drag box in pixels. @@ -4726,7 +4726,7 @@ declare module Plottable { * @param {boolean} movable * @return {DragBoxLayer} The calling DragBoxLayer. */ - movable(movable: boolean): DragBoxLayer; + movable(movable: boolean): DragBoxLayer; /** * Sets the callback to be called when dragging starts. * @@ -4783,7 +4783,7 @@ declare module Plottable { enabled(): boolean; destroy(): void; detach(): Component; - anchor(selection: d3.Selection): Component; + anchor(selection: d3.Selection): Component; } } } @@ -4854,7 +4854,7 @@ declare module Plottable { (dragLineLayer: Components.DragLineLayer): void; } module Components { - class DragLineLayer extends GuideLineLayer { + class DragLineLayer extends GuideLineLayer { constructor(orientation: string); protected _setup(): void; renderImmediately(): DragLineLayer; From dc6c439f81baa8e7a87e24c6d008492f64aa803f Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Sun, 4 Oct 2015 17:39:13 +1100 Subject: [PATCH 11/19] Revert "plottable.d.ts fix in gruntfile" This reverts commit e0f25c62193816663d29c4e58ba9464746aaf9da. --- Gruntfile.js | 16 ++- plottable.d.ts | 304 ++++++++++++++++++++++++------------------------- 2 files changed, 159 insertions(+), 161 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4e4fa4607d..596aa17666 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -50,16 +50,14 @@ module.exports = function(grunt) { prereleaseName: "rc" } }; - - - var regexLF = (grunt.util.linefeed == "\r\n" ? "(\\u000D\\n)" : "\\n"); - var prefixMatch = "\\n *(function |var |static )?".replace("\\n",regexLF); + + var prefixMatch = "\\n *(function |var |static )?"; var varNameMatch = "[^(:;]*(\\([^)]*\\))?"; // catch function args too var nestedBraceMatch = ": \\{[^{}]*\\}"; var typeNameMatch = ": [^;]*"; - var finalMatch = "((" + nestedBraceMatch + ")|(" + typeNameMatch + "))?\\n?;".replace("\\n", regexLF); - var jsdocInit = "\\n *\\/\\*\\* *\\n".replace("\\n", regexLF); - var jsdocMid = "( *\\*[^\\n]*\\n)+".replace("\\n", regexLF); + var finalMatch = "((" + nestedBraceMatch + ")|(" + typeNameMatch + "))?\\n?;"; + var jsdocInit = "\\n *\\/\\*\\* *\\n"; + var jsdocMid = "( *\\*[^\\n]*\\n)+"; var jsdocEnd = " *\\*\\/ *"; var jsdoc = "(" + jsdocInit + jsdocMid + jsdocEnd + ")?"; @@ -94,7 +92,7 @@ module.exports = function(grunt) { // on each recompile var updateTsFiles = function() { tsFiles = grunt.file.read("src/reference.ts") - .split(grunt.util.linefeed) + .split("\n") .filter(function(s) { return s !== ""; }).map(function(s) { @@ -106,7 +104,7 @@ module.exports = function(grunt) { var testTsFiles; var updateTestTsFiles = function() { testTsFiles = grunt.file.read("test/testReference.ts") - .split(grunt.util.linefeed) + .split("\n") .filter(function(s) { return s !== ""; }).map(function(s) { diff --git a/plottable.d.ts b/plottable.d.ts index 79ea81ab02..765d4f2c23 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -66,7 +66,7 @@ declare module Plottable { * Shim for ES6 map. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map */ - class Map { + class Map { constructor(); set(key: K, value: V): Map; get(key: K): V; @@ -85,7 +85,7 @@ declare module Plottable { * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set */ class Set { - size: number; + size: number; constructor(); add(value: T): Set; delete(value: T): boolean; @@ -349,7 +349,7 @@ declare module Plottable { declare module Plottable { module Utils { - class ClientToSVGTranslator { + class ClientToSVGTranslator { /** * Returns the ClientToSVGTranslator for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -395,7 +395,7 @@ declare module Plottable { static noConstancy: (d: any, i: number) => any; static byIndex: (d: any, i: number) => any; } - class Dataset { + class Dataset { /** * A Dataset contains an array of data and some metadata. * Changes to the data or metadata will cause anything subscribed to the Dataset to update. @@ -484,7 +484,7 @@ declare module Plottable { * Generally an inferior way to render compared to `requestAnimationFrame`, * but useful for browsers that don't suppoort `requestAnimationFrame`. */ - class Timeout implements RenderPolicy { + class Timeout implements RenderPolicy { render(): void; } } @@ -766,7 +766,7 @@ declare module Plottable { (scale: QuantitativeScale): D[]; } } - class Scale { + class Scale { /** * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. * @@ -862,7 +862,7 @@ declare module Plottable { declare module Plottable { class QuantitativeScale extends Scale { - protected static _DEFAULT_NUM_TICKS: number; + protected static _DEFAULT_NUM_TICKS: number; /** * A QuantitativeScale is a Scale that maps number-like values to numbers. * It is invertible and continuous. @@ -901,7 +901,7 @@ declare module Plottable { * @param {number} padProportion The padding proportion. Passing 0 disables padding. * @returns {QuantitativeScale} The calling QuantitativeScale. */ - padProportion(padProportion: number): QuantitativeScale; + padProportion(padProportion: number): QuantitativeScale; /** * Gets whether or not the scale snaps its domain to nice values. */ @@ -979,7 +979,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Linear extends QuantitativeScale { + class Linear extends QuantitativeScale { /** * @constructor */ @@ -1001,7 +1001,7 @@ declare module Plottable { declare module Plottable { module Scales { - class ModifiedLog extends QuantitativeScale { + class ModifiedLog extends QuantitativeScale { /** * A ModifiedLog Scale acts as a regular log scale for large numbers. * As it approaches 0, it gradually becomes linear. @@ -1028,7 +1028,7 @@ declare module Plottable { * second is that, for values less than 10, an increasingly large * (0 to 1) scaling factor is added such that at 0 the value is * adjusted to 1, resulting in a returned result of 0. - */ + */ scale(x: number): number; invert(x: number): number; protected _getDomain(): number[]; @@ -1047,14 +1047,14 @@ declare module Plottable { * * This function will generate clusters as large as it can while not * drastically exceeding its number of ticks. - */ + */ /** * How many ticks does the range [lower, upper] deserve? * * e.g. if your domain was [10, 1000] and I asked _howManyTicks(10, 100), * I would get 1/2 of the ticks. The range 10, 100 takes up 1/2 of the * distance when plotted. - */ + */ protected _niceDomain(domain: number[], count?: number): number[]; protected _defaultExtent(): number[]; protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; @@ -1068,7 +1068,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Category extends Scale { + class Category extends Scale { /** * A Category Scale maps strings to numbers. * @@ -1081,7 +1081,7 @@ declare module Plottable { domain(values: string[]): Category; protected _setDomain(values: string[]): void; range(): [number, number]; - range(values: [number, number]): Category; + range(values: [number, number]): Category; /** * Returns the width of the range band. * @@ -1144,7 +1144,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Color extends Scale { + class Color extends Scale { /** * A Color Scale maps string values to color hex values expressed as a string. * @@ -1156,7 +1156,7 @@ declare module Plottable { constructor(scaleType?: string); extentOfValues(values: string[]): string[]; protected _getExtent(): string[]; - static invalidateColorCache(): void; + static invalidateColorCache(): void; /** * Returns the color-string corresponding to a given string. * If there are not enough colors in the range(), a lightened version of an existing color will be used. @@ -1176,7 +1176,7 @@ declare module Plottable { declare module Plottable { module Scales { - class Time extends QuantitativeScale { + class Time extends QuantitativeScale { /** * A Time Scale maps Date objects to numbers. * @@ -1217,7 +1217,7 @@ declare module Plottable { class InterpolatedColor extends Scale { static REDS: string[]; static BLUES: string[]; - static POSNEG: string[]; + static POSNEG: string[]; /** * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. * @@ -1227,10 +1227,10 @@ declare module Plottable { extentOfValues(values: number[]): number[]; /** * Generates the converted QuantitativeScale. - */ + */ /** * Generates the d3 interpolator for colors. - */ + */ autoDomain(): InterpolatedColor; scale(value: number): string; protected _getDomain(): number[]; @@ -1293,9 +1293,9 @@ declare module Plottable { animator: Animator; }; } - class Drawer { + class Drawer { protected _svgElementName: string; - protected _className: string; + protected _className: string; /** * A Drawer draws svg elements based on the input Dataset. * @@ -1322,13 +1322,13 @@ declare module Plottable { * Binds data to selection * * @param{any[]} data The data to be drawn - */ + */ protected _applyDefaultAttributes(selection: d3.Selection): void; /** * Draws data using one step * * @param{AppliedDrawStep} step The step, how data should be drawn. - */ + */ /** * Calculates the total time it takes to use the input drawSteps to draw the input data * @@ -1437,11 +1437,11 @@ declare module Plottable { static CENTER: string; } } - class Component { - protected _boundingBox: d3.Selection; - protected _clipPathEnabled: boolean; + class Component { + protected _boundingBox: d3.Selection; + protected _clipPathEnabled: boolean; protected _isSetup: boolean; - protected _isAnchored: boolean; + protected _isAnchored: boolean; constructor(); /** * Attaches the Component as a child of a given d3 Selection. @@ -1500,7 +1500,7 @@ declare module Plottable { * * @returns {Component} The calling Component. */ - render(): Component; + render(): Component; /** * Renders the Component without waiting for the next frame. */ @@ -1542,7 +1542,7 @@ declare module Plottable { * @param {string} yAlignment The y alignment of the Component ("top"/"center"/"bottom"). * @returns {Component} The calling Component. */ - yAlignment(yAlignment: string): Component; + yAlignment(yAlignment: string): Component; /** * Checks if the Component has a given CSS class. * @@ -1660,7 +1660,7 @@ declare module Plottable { declare module Plottable { - class ComponentContainer extends Component { + class ComponentContainer extends Component { constructor(); anchor(selection: d3.Selection): ComponentContainer; render(): ComponentContainer; @@ -1694,7 +1694,7 @@ declare module Plottable { declare module Plottable { module Components { - class Group extends ComponentContainer { + class Group extends ComponentContainer { /** * Constructs a Group. * @@ -1762,13 +1762,13 @@ declare module Plottable { /** * The css class applied to each annotation label, which shows the formatted annotation text. */ - static ANNOTATION_LABEL_CLASS: string; + static ANNOTATION_LABEL_CLASS: string; protected _tickMarkContainer: d3.Selection; protected _tickLabelContainer: d3.Selection; protected _baseline: d3.Selection; - protected _scale: Scale; + protected _scale: Scale; protected _computedWidth: number; - protected _computedHeight: number; + protected _computedHeight: number; /** * Constructs an Axis. * An Axis is a visual representation of a Scale. @@ -1830,14 +1830,14 @@ declare module Plottable { * @returns {Axis} The calling Axis. */ annotationTierCount(annotationTierCount: number): Axis; - protected _drawAnnotations(): void; + protected _drawAnnotations(): void; /** * Retrieves the size of the core pieces. * * The core pieces include the labels, the end tick marks, the inner tick marks, and the tick label padding. */ protected _coreSize(): number; - protected _annotationTierHeight(): number; + protected _annotationTierHeight(): number; protected _removeAnnotations(): void; protected _generateBaselineAttrHash(): { [key: string]: number; @@ -1981,7 +1981,7 @@ declare module Plottable { /** * The CSS class applied to each Time Axis tier */ - static TIME_AXIS_TIER_CLASS: string; + static TIME_AXIS_TIER_CLASS: string; /** * Constructs a Time Axis. * @@ -2017,20 +2017,20 @@ declare module Plottable { axisConfigurations(configurations: TimeAxisConfiguration[]): Time; /** * Gets the index of the most precise TimeAxisConfiguration that will fit in the current width. - */ + */ orientation(): string; orientation(orientation: string): Time; - protected _computeHeight(): number; + protected _computeHeight(): number; /** * Check if tier configuration fits in the current width. - */ + */ protected _sizeFromOffer(availableWidth: number, availableHeight: number): { width: number; height: number; }; - protected _setup(): void; - protected _getTickValues(): any[]; - renderImmediately(): Time; + protected _setup(): void; + protected _getTickValues(): any[]; + renderImmediately(): Time; } } } @@ -2038,7 +2038,7 @@ declare module Plottable { declare module Plottable { module Axes { - class Numeric extends Axis { + class Numeric extends Axis { /** * Constructs a Numeric Axis. * @@ -2050,14 +2050,14 @@ declare module Plottable { */ constructor(scale: QuantitativeScale, orientation: string); protected _setup(): void; - protected _computeWidth(): number; + protected _computeWidth(): number; protected _computeHeight(): number; protected _getTickValues(): number[]; protected _rescale(): void; - renderImmediately(): Numeric; + renderImmediately(): Numeric; /** * Hides the Tick Marks which have no corresponding Tick Labels - */ + */ /** * Gets the tick label position relative to the tick marks. * @@ -2087,7 +2087,7 @@ declare module Plottable { * @param {boolean} The new text width approximation setting. * @returns {Axes.Numeric} The calling Axes.Numeric. */ - usesTextWidthApproximation(enable: boolean): Axes.Numeric; + usesTextWidthApproximation(enable: boolean): Axes.Numeric; /** * The method is responsible for evenly spacing the labels on the axis. * @return test to see if taking every `interval` recrangle from `rects` @@ -2097,7 +2097,7 @@ declare module Plottable { * between the labels to be 3x, such that the label will be `padding` distance * from the tick and 2 * `padding` distance (or more) from the next tick * - */ + */ } } } @@ -2105,7 +2105,7 @@ declare module Plottable { declare module Plottable { module Axes { - class Category extends Axis { + class Category extends Axis { /** * Constructs a Category Axis. * @@ -2136,13 +2136,13 @@ declare module Plottable { /** * Measures the size of the ticks while also writing them to the DOM. * @param {d3.Selection} ticks The tick elements to be written to. - */ + */ /** * Measures the size of the ticks without making any (permanent) DOM * changes. * * @param {string[]} ticks The strings that will be printed on the ticks. - */ + */ renderImmediately(): Category; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; } @@ -2152,7 +2152,7 @@ declare module Plottable { declare module Plottable { module Components { - class Label extends Component { + class Label extends Component { /** * A Label is a Component that displays a single line of text. * @@ -2236,7 +2236,7 @@ declare module Plottable { /** * The css class applied to each legend symbol */ - static LEGEND_SYMBOL_CLASS: string; + static LEGEND_SYMBOL_CLASS: string; /** * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. * @@ -2296,8 +2296,8 @@ declare module Plottable { * @returns {Legend} The calling Legend. */ colorScale(colorScale: Scales.Color): Legend; - destroy(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + destroy(): void; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; /** * Gets the Entities (representing Legend entries) at a particular point. * Returns an empty array if no Entities are present at that location. @@ -2342,7 +2342,7 @@ declare module Plottable { declare module Plottable { module Components { - class InterpolatedColorLegend extends Component { + class InterpolatedColorLegend extends Component { /** * The css class applied to the legend labels. */ @@ -2380,7 +2380,7 @@ declare module Plottable { * @param {expands} boolean * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. */ - expands(expands: boolean): InterpolatedColorLegend; + expands(expands: boolean): InterpolatedColorLegend; /** * Gets the orientation. */ @@ -2393,9 +2393,9 @@ declare module Plottable { */ orientation(orientation: string): InterpolatedColorLegend; fixedWidth(): boolean; - fixedHeight(): boolean; + fixedHeight(): boolean; protected _setup(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; renderImmediately(): InterpolatedColorLegend; } } @@ -2404,7 +2404,7 @@ declare module Plottable { declare module Plottable { module Components { - class Gridlines extends Component { + class Gridlines extends Component { /** * @constructor * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. @@ -2414,7 +2414,7 @@ declare module Plottable { destroy(): Gridlines; protected _setup(): void; renderImmediately(): Gridlines; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; } } } @@ -2422,7 +2422,7 @@ declare module Plottable { declare module Plottable { module Components { - class Table extends ComponentContainer { + class Table extends ComponentContainer { /** * A Table combines Components in the form of a grid. A * common case is combining a y-axis, x-axis, and the plotted data via @@ -2457,7 +2457,7 @@ declare module Plottable { * @returns {Table} The calling Table. */ add(component: Component, row: number, col: number): Table; - protected _remove(component: Component): boolean; + protected _remove(component: Component): boolean; requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; /** @@ -2532,7 +2532,7 @@ declare module Plottable { */ columnWeight(index: number, weight: number): Table; fixedWidth(): boolean; - fixedHeight(): boolean; + fixedHeight(): boolean; } } } @@ -2545,7 +2545,7 @@ declare module Plottable { PIXEL = 1, } class SelectionBoxLayer extends Component { - protected _box: d3.Selection; + protected _box: d3.Selection; protected _xBoundsMode: PropertyMode; protected _yBoundsMode: PropertyMode; constructor(); @@ -2565,7 +2565,7 @@ declare module Plottable { * @return {SelectionBoxLayer} The calling SelectionBoxLayer. */ bounds(newBounds: Bounds): SelectionBoxLayer; - protected _setBounds(newBounds: Bounds): void; + protected _setBounds(newBounds: Bounds): void; renderImmediately(): SelectionBoxLayer; /** * Gets whether the box is being shown. @@ -2621,7 +2621,7 @@ declare module Plottable { */ xExtent(xExtent: (number | { valueOf(): number; - })[]): SelectionBoxLayer; + })[]): SelectionBoxLayer; protected _setXExtent(xExtent: (number | { valueOf(): number; })[]): void; @@ -2638,7 +2638,7 @@ declare module Plottable { */ yExtent(yExtent: (number | { valueOf(): number; - })[]): SelectionBoxLayer; + })[]): SelectionBoxLayer; protected _setYExtent(yExtent: (number | { valueOf(): number; })[]): void; @@ -2652,7 +2652,7 @@ declare module Plottable { module Components { class GuideLineLayer extends Component { static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; + static ORIENTATION_HORIZONTAL: string; constructor(orientation: string); protected _setup(): void; protected _sizeFromOffer(availableWidth: number, availableHeight: number): { @@ -2663,7 +2663,7 @@ declare module Plottable { fixedWidth(): boolean; fixedHeight(): boolean; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): GuideLineLayer; - renderImmediately(): GuideLineLayer; + renderImmediately(): GuideLineLayer; protected _setPixelPositionWithoutChangingMode(pixelPosition: number): void; /** * Gets the QuantitativeScale on the GuideLineLayer. @@ -2731,9 +2731,9 @@ declare module Plottable { } } class Plot extends Component { - protected static _ANIMATION_MAX_DURATION: number; - protected _renderArea: d3.Selection; - protected _renderCallback: ScaleCallback>; + protected static _ANIMATION_MAX_DURATION: number; + protected _renderArea: d3.Selection; + protected _renderCallback: ScaleCallback>; protected _propertyExtents: d3.Map; protected _propertyBindings: d3.Map>; /** @@ -2773,7 +2773,7 @@ declare module Plottable { * @returns {Plot} The calling Plot. */ attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; - protected _bindProperty(property: string, value: any, scale: Scale): void; + protected _bindProperty(property: string, value: any, scale: Scale): void; protected _generateAttrToProjector(): AttributeToProjector; renderImmediately(): Plot; /** @@ -2787,17 +2787,17 @@ declare module Plottable { detach(): Plot; /** * @returns {Scale[]} A unique array of all scales currently used by the Plot. - */ + */ /** * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. */ - protected _updateExtents(): void; + protected _updateExtents(): void; protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): Accessor; + protected _filterForProperty(property: string): Accessor; /** * Override in subclass to add special extents, such as included values */ - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; /** * Get the Animator associated with the specified Animator key. * @@ -2834,7 +2834,7 @@ declare module Plottable { protected _getDrawersInOrder(): Drawer[]; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _additionalPaint(time: number): void; - protected _getDataToDraw(): Utils.Map; + protected _getDataToDraw(): Utils.Map; /** * Retrieves Selections of this Plot for the specified Datasets. * @@ -2850,7 +2850,7 @@ declare module Plottable { * If not provided, returns defaults to all Datasets on the Plot. * @return {Plots.PlotEntity[]} */ - entities(datasets?: Dataset[]): Plots.PlotEntity[]; + entities(datasets?: Dataset[]): Plots.PlotEntity[]; /** * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. * @@ -2875,7 +2875,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Pie extends Plot { + class Pie extends Plot { /** * @constructor */ @@ -2976,14 +2976,14 @@ declare module Plottable { */ labelFormatter(formatter: Formatter): Pie; entitiesAt(queryPoint: Point): PlotEntity[]; - protected _propertyProjectors(): AttributeToProjector; + protected _propertyProjectors(): AttributeToProjector; protected _getDataToDraw(): Utils.Map; protected static _isValidData(value: any): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): { x: number; y: number; }; - protected _additionalPaint(time: number): void; + protected _additionalPaint(time: number): void; } } } @@ -2992,7 +2992,7 @@ declare module Plottable { declare module Plottable { class XYPlot extends Plot { protected static _X_KEY: string; - protected static _Y_KEY: string; + protected static _Y_KEY: string; /** * An XYPlot is a Plot that displays data along two primary directions, X and Y. * @@ -3056,7 +3056,7 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ y(y: Y | Accessor, yScale: Scale): XYPlot; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; protected _uninstallScaleForKey(scale: Scale, key: string): void; protected _installScaleForKey(scale: Scale, key: string): void; destroy(): XYPlot; @@ -3075,14 +3075,14 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ autorangeMode(autorangeMode: string): XYPlot; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; /** * Adjusts the domains of both X and Y scales to show all data. * This call does not override the autorange() behavior. * * @returns {XYPlot} The calling XYPlot. */ - showAllData(): XYPlot; + showAllData(): XYPlot; protected _projectorsReady(): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _getDataToDraw(): Utils.Map; @@ -3092,7 +3092,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Rectangle extends XYPlot { + class Rectangle extends XYPlot { /** * A Rectangle Plot displays rectangles based on the data. * The left and right edges of each rectangle can be set with x() and x2(). @@ -3197,7 +3197,7 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; /** * Gets the accessor for labels. * @@ -3229,9 +3229,9 @@ declare module Plottable { protected _pixelPoint(datum: any, index: number, dataset: Dataset): { x: any; y: any; - }; + }; protected _getDataToDraw(): Utils.Map; - protected _additionalPaint(time: number): void; + protected _additionalPaint(time: number): void; } } } @@ -3239,7 +3239,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Scatter extends XYPlot { + class Scatter extends XYPlot { /** * A Scatter Plot draws a symbol at each data point. * @@ -3318,8 +3318,8 @@ declare module Plottable { module Plots { class Bar extends XYPlot { static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; - protected _isVertical: boolean; + static ORIENTATION_HORIZONTAL: string; + protected _isVertical: boolean; /** * A Bar Plot draws bars growing out from a baseline to some value * @@ -3426,12 +3426,12 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; protected _additionalPaint(time: number): void; /** * Makes sure the extent takes into account the widths of the bars */ - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; @@ -3443,7 +3443,7 @@ declare module Plottable { * If the position scale of the plot is a QuantitativeScale, then the bar width is equal to the smallest distance between * two adjacent data points, padded for visualisation. */ - protected _getBarPixelWidth(): number; + protected _getBarPixelWidth(): number; entities(datasets?: Dataset[]): PlotEntity[]; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _uninstallScaleForKey(scale: Scale, key: string): void; @@ -3455,7 +3455,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Line extends XYPlot { + class Line extends XYPlot { /** * A Line Plot draws line segments starting from the first data point to the next. * @@ -3480,7 +3480,7 @@ declare module Plottable { * Smooth autoranging is done by making sure lines always exit on the left / right side of the plot * and deactivating the nice domain feature on the scales */ - autorangeSmooth(autorangeSmooth: boolean): Plots.Line; + autorangeSmooth(autorangeSmooth: boolean): Plots.Line; /** * Gets the interpolation function associated with the plot. * @@ -3508,7 +3508,7 @@ declare module Plottable { interpolator(interpolator: "cardinal-closed"): Line; interpolator(interpolator: "monotone"): Line; protected _createDrawer(dataset: Dataset): Drawer; - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { @@ -3531,7 +3531,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Area extends Line { + class Area extends Line { /** * An Area Plot draws a filled region (area) between Y and Y0. * @@ -3558,7 +3558,7 @@ declare module Plottable { addDataset(dataset: Dataset): Area; protected _addDataset(dataset: Dataset): Area; protected _removeDatasetNodes(dataset: Dataset): void; - protected _additionalPaint(): void; + protected _additionalPaint(): void; protected _createDrawer(dataset: Dataset): Drawers.Area; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _updateYScale(): void; @@ -3573,7 +3573,7 @@ declare module Plottable { declare module Plottable { module Plots { - class ClusteredBar extends Bar { + class ClusteredBar extends Bar { /** * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. @@ -3585,7 +3585,7 @@ declare module Plottable { constructor(orientation?: string); protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; + }; protected _getDataToDraw(): Utils.Map; } } @@ -3594,7 +3594,7 @@ declare module Plottable { declare module Plottable { module Plots { - class StackedArea extends Area { + class StackedArea extends Area { /** * @constructor */ @@ -3611,7 +3611,7 @@ declare module Plottable { protected _updateYScale(): void; protected _onDatasetUpdate(): StackedArea; protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; + protected _extentsForProperty(attr: string): any[]; /** * Given an array of Datasets and the accessor function for the key, computes the * set reunion (no duplicates) of the domain of each Dataset. The keys are stringified @@ -3620,7 +3620,7 @@ declare module Plottable { * @param {Dataset[]} datasets The Datasets for which we extract the domain keys * @param {Accessor} keyAccessor The accessor for the key of the data * @return {string[]} An array of stringified keys - */ + */ protected _propertyProjectors(): AttributeToProjector; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; } @@ -3630,7 +3630,7 @@ declare module Plottable { declare module Plottable { module Plots { - class StackedBar extends Bar { + class StackedBar extends Bar { /** * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. * On a vertical StackedBar Plot, the bars with the same X value are stacked. @@ -3653,7 +3653,7 @@ declare module Plottable { }; protected _onDatasetUpdate(): StackedBar; protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; + protected _extentsForProperty(attr: string): any[]; } } } @@ -3661,7 +3661,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Segment extends XYPlot { + class Segment extends XYPlot { /** * A Segment Plot displays line segments based on the data. * @@ -3751,7 +3751,7 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; } } } @@ -3759,7 +3759,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Waterfall extends Bar { + class Waterfall extends Bar { constructor(); /** * Gets whether connectors are enabled. @@ -3791,7 +3791,7 @@ declare module Plottable { protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; }; - protected _onDatasetUpdate(): Waterfall; + protected _onDatasetUpdate(): Waterfall; } } } @@ -3799,7 +3799,7 @@ declare module Plottable { declare module Plottable { module Plots { - class Wheel extends Plot { + class Wheel extends Plot { /** * @constructor */ @@ -3930,19 +3930,19 @@ declare module Plottable { class Easing implements Animator { /** * The default starting delay of the animation in milliseconds - */ + */ /** * The default duration of one animation step in milliseconds - */ + */ /** * The default maximum start delay between each step of an animation - */ + */ /** * The default maximum total animation duration - */ + */ /** * The default easing of the animation - */ + */ /** * Constructs the default animator * @@ -4026,7 +4026,7 @@ declare module Plottable { easingMode(easingMode: string): Easing; /** * Adjust the iterative delay, such that it takes into account the maxTotalDuration constraint - */ + */ } } } @@ -4037,7 +4037,7 @@ declare module Plottable { protected _eventToCallback: { [eventName: string]: (e: Event) => any; }; - protected _callbacks: Utils.CallbackSet[]; + protected _callbacks: Utils.CallbackSet[]; protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; } @@ -4047,7 +4047,7 @@ declare module Plottable { declare module Plottable { module Dispatchers { type MouseCallback = (p: Point, event: MouseEvent) => void; - class Mouse extends Dispatcher { + class Mouse extends Dispatcher { /** * Get a Mouse Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4136,7 +4136,7 @@ declare module Plottable { /** * Computes the mouse position from the given event, and if successful * calls all the callbacks in the provided callbackSet. - */ + */ eventInsideSVG(event: MouseEvent): boolean; /** * Returns the last computed mouse position in coordinate space. @@ -4154,7 +4154,7 @@ declare module Plottable { type TouchCallback = (ids: number[], idToPoint: { [id: number]: Point; }, event: TouchEvent) => void; - class Touch extends Dispatcher { + class Touch extends Dispatcher { /** * Gets a Touch Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4229,7 +4229,7 @@ declare module Plottable { /** * Computes the Touch position from the given event, and if successful * calls all the callbacks in the provided callbackSet. - */ + */ eventInsideSVG(event: TouchEvent): boolean; } } @@ -4239,7 +4239,7 @@ declare module Plottable { declare module Plottable { module Dispatchers { type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; - class Key extends Dispatcher { + class Key extends Dispatcher { /** * Gets a Key Dispatcher. If one already exists it will be returned; * otherwise, a new one will be created. @@ -4279,7 +4279,7 @@ declare module Plottable { * @param {KeyCallback} callback * @return {Dispatchers.Key} The calling Key Dispatcher. */ - offKeyUp(callback: KeyCallback): Key; + offKeyUp(callback: KeyCallback): Key; } } } @@ -4287,7 +4287,7 @@ declare module Plottable { declare module Plottable { class Interaction { - protected _componentAttachedTo: Component; + protected _componentAttachedTo: Component; protected _anchor(component: Component): void; protected _unanchor(): void; /** @@ -4297,7 +4297,7 @@ declare module Plottable { * @param {Component} component * @returns {Interaction} The calling Interaction. */ - attachTo(component: Component): Interaction; + attachTo(component: Component): Interaction; /** * Detaches this Interaction from the Component. * This Interaction can be reused. @@ -4305,7 +4305,7 @@ declare module Plottable { * @param {Component} component * @returns {Interaction} The calling Interaction. */ - detachFrom(component: Component): Interaction; + detachFrom(component: Component): Interaction; /** * Gets whether this Interaction is enabled. */ @@ -4338,9 +4338,9 @@ declare module Plottable { declare module Plottable { type ClickCallback = (point: Point) => void; module Interactions { - class Click extends Interaction { + class Click extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the Component is clicked. * @@ -4362,9 +4362,9 @@ declare module Plottable { declare module Plottable { module Interactions { - class DoubleClick extends Interaction { + class DoubleClick extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the Component is double-clicked. * @@ -4391,9 +4391,9 @@ declare module Plottable { /** * A Key Interaction listens to key events that occur while the Component is * moused over. - */ + */ protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the key with the given keyCode is * pressed and the user is moused over the Component. @@ -4438,9 +4438,9 @@ declare module Plottable { declare module Plottable { type PointerCallback = (point: Point) => void; module Interactions { - class Pointer extends Interaction { + class Pointer extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the pointer enters the Component. * @@ -4493,7 +4493,7 @@ declare module Plottable { class PanZoom extends Interaction { /** * The number of pixels occupied in a line. - */ + */ /** * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale * in response to the user panning or zooming. @@ -4504,7 +4504,7 @@ declare module Plottable { */ constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Gets the x scales for this PanZoom Interaction. */ @@ -4603,9 +4603,9 @@ declare module Plottable { declare module Plottable { type DragCallback = (start: Point, end: Point) => void; module Interactions { - class Drag extends Interaction { + class Drag extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Gets whether the Drag Interaction constrains Points passed to its * callbacks to lie inside its Component. @@ -4679,8 +4679,8 @@ declare module Plottable { declare module Plottable { type DragBoxCallback = (bounds: Bounds) => void; module Components { - class DragBoxLayer extends Components.SelectionBoxLayer { - protected _hasCorners: boolean; + class DragBoxLayer extends Components.SelectionBoxLayer { + protected _hasCorners: boolean; /** * Constructs a DragBoxLayer. * @@ -4690,8 +4690,8 @@ declare module Plottable { * * @constructor */ - constructor(); - protected _setup(): void; + constructor(); + protected _setup(): void; renderImmediately(): DragBoxLayer; /** * Gets the detection radius of the drag box in pixels. @@ -4726,7 +4726,7 @@ declare module Plottable { * @param {boolean} movable * @return {DragBoxLayer} The calling DragBoxLayer. */ - movable(movable: boolean): DragBoxLayer; + movable(movable: boolean): DragBoxLayer; /** * Sets the callback to be called when dragging starts. * @@ -4783,7 +4783,7 @@ declare module Plottable { enabled(): boolean; destroy(): void; detach(): Component; - anchor(selection: d3.Selection): Component; + anchor(selection: d3.Selection): Component; } } } @@ -4854,7 +4854,7 @@ declare module Plottable { (dragLineLayer: Components.DragLineLayer): void; } module Components { - class DragLineLayer extends GuideLineLayer { + class DragLineLayer extends GuideLineLayer { constructor(orientation: string); protected _setup(): void; renderImmediately(): DragLineLayer; From c3c6558f7ab24404b5079924dede2a18b28b124e Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Sun, 4 Oct 2015 20:41:48 +1100 Subject: [PATCH 12/19] plottable.d.ts fix in gruntfile --- plottable.d.ts | 464 ++++++++++++++++++++++++------------------------- 1 file changed, 232 insertions(+), 232 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index 765d4f2c23..5d8153247f 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -1,4 +1,4 @@ - +/// declare module Plottable { module Utils { module Math { @@ -59,14 +59,14 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { /** * Shim for ES6 map. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map */ - class Map { + class Map { constructor(); set(key: K, value: V): Map; get(key: K): V; @@ -77,7 +77,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { /** @@ -85,7 +85,7 @@ declare module Plottable { * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set */ class Set { - size: number; + size: number; constructor(); add(value: T): Set; delete(value: T): boolean; @@ -95,7 +95,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { module DOM { @@ -193,7 +193,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { module Color { @@ -223,7 +223,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { module Array { @@ -260,7 +260,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { /** @@ -274,7 +274,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { module Stacking { @@ -312,7 +312,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { module Window { @@ -346,10 +346,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Utils { - class ClientToSVGTranslator { + class ClientToSVGTranslator { /** * Returns the ClientToSVGTranslator for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -368,7 +368,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Configs { /** @@ -382,12 +382,12 @@ declare module Plottable { } } - +/// declare module Plottable { var version: string; } - +/// declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; class KeyFunctions { @@ -395,7 +395,7 @@ declare module Plottable { static noConstancy: (d: any, i: number) => any; static byIndex: (d: any, i: number) => any; } - class Dataset { + class Dataset { /** * A Dataset contains an array of data and some metadata. * Changes to the data or metadata will cause anything subscribed to the Dataset to update. @@ -456,7 +456,7 @@ declare module Plottable { } } - +/// declare module Plottable { module RenderPolicies { /** @@ -484,13 +484,13 @@ declare module Plottable { * Generally an inferior way to render compared to `requestAnimationFrame`, * but useful for browsers that don't suppoort `requestAnimationFrame`. */ - class Timeout implements RenderPolicy { + class Timeout implements RenderPolicy { render(): void; } } } - +/// declare module Plottable { /** * The RenderController is responsible for enqueueing and synchronizing @@ -610,7 +610,7 @@ declare module Plottable { } } - +/// declare module Plottable { type Formatter = (d: any) => string; /** @@ -722,7 +722,7 @@ declare module Plottable { } } - +/// declare module Plottable { /** * A SymbolFactory is a function that takes in a symbolSize which is the edge length of the render area @@ -739,7 +739,7 @@ declare module Plottable { } } - +/// declare module Plottable { interface ScaleCallback> { (scale: S): any; @@ -766,7 +766,7 @@ declare module Plottable { (scale: QuantitativeScale): D[]; } } - class Scale { + class Scale { /** * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. * @@ -859,10 +859,10 @@ declare module Plottable { } } - +/// declare module Plottable { class QuantitativeScale extends Scale { - protected static _DEFAULT_NUM_TICKS: number; + protected static _DEFAULT_NUM_TICKS: number; /** * A QuantitativeScale is a Scale that maps number-like values to numbers. * It is invertible and continuous. @@ -901,7 +901,7 @@ declare module Plottable { * @param {number} padProportion The padding proportion. Passing 0 disables padding. * @returns {QuantitativeScale} The calling QuantitativeScale. */ - padProportion(padProportion: number): QuantitativeScale; + padProportion(padProportion: number): QuantitativeScale; /** * Gets whether or not the scale snaps its domain to nice values. */ @@ -976,10 +976,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { - class Linear extends QuantitativeScale { + class Linear extends QuantitativeScale { /** * @constructor */ @@ -998,10 +998,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { - class ModifiedLog extends QuantitativeScale { + class ModifiedLog extends QuantitativeScale { /** * A ModifiedLog Scale acts as a regular log scale for large numbers. * As it approaches 0, it gradually becomes linear. @@ -1028,7 +1028,7 @@ declare module Plottable { * second is that, for values less than 10, an increasingly large * (0 to 1) scaling factor is added such that at 0 the value is * adjusted to 1, resulting in a returned result of 0. - */ + */ scale(x: number): number; invert(x: number): number; protected _getDomain(): number[]; @@ -1047,14 +1047,14 @@ declare module Plottable { * * This function will generate clusters as large as it can while not * drastically exceeding its number of ticks. - */ + */ /** * How many ticks does the range [lower, upper] deserve? * * e.g. if your domain was [10, 1000] and I asked _howManyTicks(10, 100), * I would get 1/2 of the ticks. The range 10, 100 takes up 1/2 of the * distance when plotted. - */ + */ protected _niceDomain(domain: number[], count?: number): number[]; protected _defaultExtent(): number[]; protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; @@ -1065,10 +1065,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { - class Category extends Scale { + class Category extends Scale { /** * A Category Scale maps strings to numbers. * @@ -1081,7 +1081,7 @@ declare module Plottable { domain(values: string[]): Category; protected _setDomain(values: string[]): void; range(): [number, number]; - range(values: [number, number]): Category; + range(values: [number, number]): Category; /** * Returns the width of the range band. * @@ -1141,10 +1141,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { - class Color extends Scale { + class Color extends Scale { /** * A Color Scale maps string values to color hex values expressed as a string. * @@ -1156,7 +1156,7 @@ declare module Plottable { constructor(scaleType?: string); extentOfValues(values: string[]): string[]; protected _getExtent(): string[]; - static invalidateColorCache(): void; + static invalidateColorCache(): void; /** * Returns the color-string corresponding to a given string. * If there are not enough colors in the range(), a lightened version of an existing color will be used. @@ -1173,10 +1173,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { - class Time extends QuantitativeScale { + class Time extends QuantitativeScale { /** * A Time Scale maps Date objects to numbers. * @@ -1211,13 +1211,13 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { class InterpolatedColor extends Scale { static REDS: string[]; static BLUES: string[]; - static POSNEG: string[]; + static POSNEG: string[]; /** * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. * @@ -1227,10 +1227,10 @@ declare module Plottable { extentOfValues(values: number[]): number[]; /** * Generates the converted QuantitativeScale. - */ + */ /** * Generates the d3 interpolator for colors. - */ + */ autoDomain(): InterpolatedColor; scale(value: number): string; protected _getDomain(): number[]; @@ -1241,7 +1241,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Scales { module TickGenerators { @@ -1273,7 +1273,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { /** @@ -1293,9 +1293,9 @@ declare module Plottable { animator: Animator; }; } - class Drawer { + class Drawer { protected _svgElementName: string; - protected _className: string; + protected _className: string; /** * A Drawer draws svg elements based on the input Dataset. * @@ -1322,13 +1322,13 @@ declare module Plottable { * Binds data to selection * * @param{any[]} data The data to be drawn - */ + */ protected _applyDefaultAttributes(selection: d3.Selection): void; /** * Draws data using one step * * @param{AppliedDrawStep} step The step, how data should be drawn. - */ + */ /** * Calculates the total time it takes to use the input drawSteps to draw the input data * @@ -1356,7 +1356,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class Line extends Drawer { @@ -1367,7 +1367,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class Area extends Drawer { @@ -1378,7 +1378,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class Rectangle extends Drawer { @@ -1387,7 +1387,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class Arc extends Drawer { @@ -1397,7 +1397,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class ArcOutline extends Drawer { @@ -1407,7 +1407,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class Symbol extends Drawer { @@ -1416,7 +1416,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Drawers { class Segment extends Drawer { @@ -1425,7 +1425,7 @@ declare module Plottable { } } - +/// declare module Plottable { type ComponentCallback = (component: Component) => void; module Components { @@ -1437,11 +1437,11 @@ declare module Plottable { static CENTER: string; } } - class Component { - protected _boundingBox: d3.Selection; - protected _clipPathEnabled: boolean; + class Component { + protected _boundingBox: d3.Selection; + protected _clipPathEnabled: boolean; protected _isSetup: boolean; - protected _isAnchored: boolean; + protected _isAnchored: boolean; constructor(); /** * Attaches the Component as a child of a given d3 Selection. @@ -1500,7 +1500,7 @@ declare module Plottable { * * @returns {Component} The calling Component. */ - render(): Component; + render(): Component; /** * Renders the Component without waiting for the next frame. */ @@ -1542,7 +1542,7 @@ declare module Plottable { * @param {string} yAlignment The y alignment of the Component ("top"/"center"/"bottom"). * @returns {Component} The calling Component. */ - yAlignment(yAlignment: string): Component; + yAlignment(yAlignment: string): Component; /** * Checks if the Component has a given CSS class. * @@ -1658,9 +1658,9 @@ declare module Plottable { } } - +/// declare module Plottable { - class ComponentContainer extends Component { + class ComponentContainer extends Component { constructor(); anchor(selection: d3.Selection): ComponentContainer; render(): ComponentContainer; @@ -1691,10 +1691,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Components { - class Group extends ComponentContainer { + class Group extends ComponentContainer { /** * Constructs a Group. * @@ -1732,7 +1732,7 @@ declare module Plottable { } } - +/// declare module Plottable { class Axis extends Component { /** @@ -1762,13 +1762,13 @@ declare module Plottable { /** * The css class applied to each annotation label, which shows the formatted annotation text. */ - static ANNOTATION_LABEL_CLASS: string; + static ANNOTATION_LABEL_CLASS: string; protected _tickMarkContainer: d3.Selection; protected _tickLabelContainer: d3.Selection; protected _baseline: d3.Selection; - protected _scale: Scale; + protected _scale: Scale; protected _computedWidth: number; - protected _computedHeight: number; + protected _computedHeight: number; /** * Constructs an Axis. * An Axis is a visual representation of a Scale. @@ -1830,14 +1830,14 @@ declare module Plottable { * @returns {Axis} The calling Axis. */ annotationTierCount(annotationTierCount: number): Axis; - protected _drawAnnotations(): void; + protected _drawAnnotations(): void; /** * Retrieves the size of the core pieces. * * The core pieces include the labels, the end tick marks, the inner tick marks, and the tick label padding. */ protected _coreSize(): number; - protected _annotationTierHeight(): number; + protected _annotationTierHeight(): number; protected _removeAnnotations(): void; protected _generateBaselineAttrHash(): { [key: string]: number; @@ -1947,7 +1947,7 @@ declare module Plottable { } } - +/// declare module Plottable { module TimeInterval { var second: string; @@ -1981,7 +1981,7 @@ declare module Plottable { /** * The CSS class applied to each Time Axis tier */ - static TIME_AXIS_TIER_CLASS: string; + static TIME_AXIS_TIER_CLASS: string; /** * Constructs a Time Axis. * @@ -2017,28 +2017,28 @@ declare module Plottable { axisConfigurations(configurations: TimeAxisConfiguration[]): Time; /** * Gets the index of the most precise TimeAxisConfiguration that will fit in the current width. - */ + */ orientation(): string; orientation(orientation: string): Time; - protected _computeHeight(): number; + protected _computeHeight(): number; /** * Check if tier configuration fits in the current width. - */ + */ protected _sizeFromOffer(availableWidth: number, availableHeight: number): { width: number; height: number; }; - protected _setup(): void; - protected _getTickValues(): any[]; - renderImmediately(): Time; + protected _setup(): void; + protected _getTickValues(): any[]; + renderImmediately(): Time; } } } - +/// declare module Plottable { module Axes { - class Numeric extends Axis { + class Numeric extends Axis { /** * Constructs a Numeric Axis. * @@ -2050,14 +2050,14 @@ declare module Plottable { */ constructor(scale: QuantitativeScale, orientation: string); protected _setup(): void; - protected _computeWidth(): number; + protected _computeWidth(): number; protected _computeHeight(): number; protected _getTickValues(): number[]; protected _rescale(): void; - renderImmediately(): Numeric; + renderImmediately(): Numeric; /** * Hides the Tick Marks which have no corresponding Tick Labels - */ + */ /** * Gets the tick label position relative to the tick marks. * @@ -2087,7 +2087,7 @@ declare module Plottable { * @param {boolean} The new text width approximation setting. * @returns {Axes.Numeric} The calling Axes.Numeric. */ - usesTextWidthApproximation(enable: boolean): Axes.Numeric; + usesTextWidthApproximation(enable: boolean): Axes.Numeric; /** * The method is responsible for evenly spacing the labels on the axis. * @return test to see if taking every `interval` recrangle from `rects` @@ -2097,15 +2097,15 @@ declare module Plottable { * between the labels to be 3x, such that the label will be `padding` distance * from the tick and 2 * `padding` distance (or more) from the next tick * - */ + */ } } } - +/// declare module Plottable { module Axes { - class Category extends Axis { + class Category extends Axis { /** * Constructs a Category Axis. * @@ -2136,23 +2136,23 @@ declare module Plottable { /** * Measures the size of the ticks while also writing them to the DOM. * @param {d3.Selection} ticks The tick elements to be written to. - */ + */ /** * Measures the size of the ticks without making any (permanent) DOM * changes. * * @param {string[]} ticks The strings that will be printed on the ticks. - */ + */ renderImmediately(): Category; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; } } } - +/// declare module Plottable { module Components { - class Label extends Component { + class Label extends Component { /** * A Label is a Component that displays a single line of text. * @@ -2221,7 +2221,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Components { class Legend extends Component { @@ -2236,7 +2236,7 @@ declare module Plottable { /** * The css class applied to each legend symbol */ - static LEGEND_SYMBOL_CLASS: string; + static LEGEND_SYMBOL_CLASS: string; /** * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. * @@ -2296,8 +2296,8 @@ declare module Plottable { * @returns {Legend} The calling Legend. */ colorScale(colorScale: Scales.Color): Legend; - destroy(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + destroy(): void; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; /** * Gets the Entities (representing Legend entries) at a particular point. * Returns an empty array if no Entities are present at that location. @@ -2339,10 +2339,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Components { - class InterpolatedColorLegend extends Component { + class InterpolatedColorLegend extends Component { /** * The css class applied to the legend labels. */ @@ -2380,7 +2380,7 @@ declare module Plottable { * @param {expands} boolean * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. */ - expands(expands: boolean): InterpolatedColorLegend; + expands(expands: boolean): InterpolatedColorLegend; /** * Gets the orientation. */ @@ -2393,18 +2393,18 @@ declare module Plottable { */ orientation(orientation: string): InterpolatedColorLegend; fixedWidth(): boolean; - fixedHeight(): boolean; + fixedHeight(): boolean; protected _setup(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; renderImmediately(): InterpolatedColorLegend; } } } - +/// declare module Plottable { module Components { - class Gridlines extends Component { + class Gridlines extends Component { /** * @constructor * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. @@ -2414,15 +2414,15 @@ declare module Plottable { destroy(): Gridlines; protected _setup(): void; renderImmediately(): Gridlines; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; } } } - +/// declare module Plottable { module Components { - class Table extends ComponentContainer { + class Table extends ComponentContainer { /** * A Table combines Components in the form of a grid. A * common case is combining a y-axis, x-axis, and the plotted data via @@ -2457,7 +2457,7 @@ declare module Plottable { * @returns {Table} The calling Table. */ add(component: Component, row: number, col: number): Table; - protected _remove(component: Component): boolean; + protected _remove(component: Component): boolean; requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; /** @@ -2532,12 +2532,12 @@ declare module Plottable { */ columnWeight(index: number, weight: number): Table; fixedWidth(): boolean; - fixedHeight(): boolean; + fixedHeight(): boolean; } } } - +/// declare module Plottable { module Components { enum PropertyMode { @@ -2545,7 +2545,7 @@ declare module Plottable { PIXEL = 1, } class SelectionBoxLayer extends Component { - protected _box: d3.Selection; + protected _box: d3.Selection; protected _xBoundsMode: PropertyMode; protected _yBoundsMode: PropertyMode; constructor(); @@ -2565,7 +2565,7 @@ declare module Plottable { * @return {SelectionBoxLayer} The calling SelectionBoxLayer. */ bounds(newBounds: Bounds): SelectionBoxLayer; - protected _setBounds(newBounds: Bounds): void; + protected _setBounds(newBounds: Bounds): void; renderImmediately(): SelectionBoxLayer; /** * Gets whether the box is being shown. @@ -2621,7 +2621,7 @@ declare module Plottable { */ xExtent(xExtent: (number | { valueOf(): number; - })[]): SelectionBoxLayer; + })[]): SelectionBoxLayer; protected _setXExtent(xExtent: (number | { valueOf(): number; })[]): void; @@ -2638,7 +2638,7 @@ declare module Plottable { */ yExtent(yExtent: (number | { valueOf(): number; - })[]): SelectionBoxLayer; + })[]): SelectionBoxLayer; protected _setYExtent(yExtent: (number | { valueOf(): number; })[]): void; @@ -2647,12 +2647,12 @@ declare module Plottable { } } - +/// declare module Plottable { module Components { class GuideLineLayer extends Component { static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; + static ORIENTATION_HORIZONTAL: string; constructor(orientation: string); protected _setup(): void; protected _sizeFromOffer(availableWidth: number, availableHeight: number): { @@ -2663,7 +2663,7 @@ declare module Plottable { fixedWidth(): boolean; fixedHeight(): boolean; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): GuideLineLayer; - renderImmediately(): GuideLineLayer; + renderImmediately(): GuideLineLayer; protected _setPixelPositionWithoutChangingMode(pixelPosition: number): void; /** * Gets the QuantitativeScale on the GuideLineLayer. @@ -2713,7 +2713,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Plots { interface PlotEntity extends Entity { @@ -2731,9 +2731,9 @@ declare module Plottable { } } class Plot extends Component { - protected static _ANIMATION_MAX_DURATION: number; - protected _renderArea: d3.Selection; - protected _renderCallback: ScaleCallback>; + protected static _ANIMATION_MAX_DURATION: number; + protected _renderArea: d3.Selection; + protected _renderCallback: ScaleCallback>; protected _propertyExtents: d3.Map; protected _propertyBindings: d3.Map>; /** @@ -2773,7 +2773,7 @@ declare module Plottable { * @returns {Plot} The calling Plot. */ attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; - protected _bindProperty(property: string, value: any, scale: Scale): void; + protected _bindProperty(property: string, value: any, scale: Scale): void; protected _generateAttrToProjector(): AttributeToProjector; renderImmediately(): Plot; /** @@ -2787,17 +2787,17 @@ declare module Plottable { detach(): Plot; /** * @returns {Scale[]} A unique array of all scales currently used by the Plot. - */ + */ /** * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. */ - protected _updateExtents(): void; + protected _updateExtents(): void; protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): Accessor; + protected _filterForProperty(property: string): Accessor; /** * Override in subclass to add special extents, such as included values */ - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; /** * Get the Animator associated with the specified Animator key. * @@ -2834,7 +2834,7 @@ declare module Plottable { protected _getDrawersInOrder(): Drawer[]; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _additionalPaint(time: number): void; - protected _getDataToDraw(): Utils.Map; + protected _getDataToDraw(): Utils.Map; /** * Retrieves Selections of this Plot for the specified Datasets. * @@ -2850,7 +2850,7 @@ declare module Plottable { * If not provided, returns defaults to all Datasets on the Plot. * @return {Plots.PlotEntity[]} */ - entities(datasets?: Dataset[]): Plots.PlotEntity[]; + entities(datasets?: Dataset[]): Plots.PlotEntity[]; /** * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. * @@ -2872,10 +2872,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Plots { - class Pie extends Plot { + class Pie extends Plot { /** * @constructor */ @@ -2976,23 +2976,23 @@ declare module Plottable { */ labelFormatter(formatter: Formatter): Pie; entitiesAt(queryPoint: Point): PlotEntity[]; - protected _propertyProjectors(): AttributeToProjector; + protected _propertyProjectors(): AttributeToProjector; protected _getDataToDraw(): Utils.Map; protected static _isValidData(value: any): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): { x: number; y: number; }; - protected _additionalPaint(time: number): void; + protected _additionalPaint(time: number): void; } } } - +/// declare module Plottable { class XYPlot extends Plot { protected static _X_KEY: string; - protected static _Y_KEY: string; + protected static _Y_KEY: string; /** * An XYPlot is a Plot that displays data along two primary directions, X and Y. * @@ -3056,7 +3056,7 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ y(y: Y | Accessor, yScale: Scale): XYPlot; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; protected _uninstallScaleForKey(scale: Scale, key: string): void; protected _installScaleForKey(scale: Scale, key: string): void; destroy(): XYPlot; @@ -3075,24 +3075,24 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ autorangeMode(autorangeMode: string): XYPlot; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; + computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; /** * Adjusts the domains of both X and Y scales to show all data. * This call does not override the autorange() behavior. * * @returns {XYPlot} The calling XYPlot. */ - showAllData(): XYPlot; + showAllData(): XYPlot; protected _projectorsReady(): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _getDataToDraw(): Utils.Map; } } - +/// declare module Plottable { module Plots { - class Rectangle extends XYPlot { + class Rectangle extends XYPlot { /** * A Rectangle Plot displays rectangles based on the data. * The left and right edges of each rectangle can be set with x() and x2(). @@ -3197,7 +3197,7 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; /** * Gets the accessor for labels. * @@ -3229,17 +3229,17 @@ declare module Plottable { protected _pixelPoint(datum: any, index: number, dataset: Dataset): { x: any; y: any; - }; + }; protected _getDataToDraw(): Utils.Map; - protected _additionalPaint(time: number): void; + protected _additionalPaint(time: number): void; } } } - +/// declare module Plottable { module Plots { - class Scatter extends XYPlot { + class Scatter extends XYPlot { /** * A Scatter Plot draws a symbol at each data point. * @@ -3313,13 +3313,13 @@ declare module Plottable { } } - +/// declare module Plottable { module Plots { class Bar extends XYPlot { static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; - protected _isVertical: boolean; + static ORIENTATION_HORIZONTAL: string; + protected _isVertical: boolean; /** * A Bar Plot draws bars growing out from a baseline to some value * @@ -3426,12 +3426,12 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; protected _additionalPaint(time: number): void; /** * Makes sure the extent takes into account the widths of the bars */ - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; @@ -3443,7 +3443,7 @@ declare module Plottable { * If the position scale of the plot is a QuantitativeScale, then the bar width is equal to the smallest distance between * two adjacent data points, padded for visualisation. */ - protected _getBarPixelWidth(): number; + protected _getBarPixelWidth(): number; entities(datasets?: Dataset[]): PlotEntity[]; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _uninstallScaleForKey(scale: Scale, key: string): void; @@ -3452,10 +3452,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Plots { - class Line extends XYPlot { + class Line extends XYPlot { /** * A Line Plot draws line segments starting from the first data point to the next. * @@ -3480,7 +3480,7 @@ declare module Plottable { * Smooth autoranging is done by making sure lines always exit on the left / right side of the plot * and deactivating the nice domain feature on the scales */ - autorangeSmooth(autorangeSmooth: boolean): Plots.Line; + autorangeSmooth(autorangeSmooth: boolean): Plots.Line; /** * Gets the interpolation function associated with the plot. * @@ -3508,7 +3508,7 @@ declare module Plottable { interpolator(interpolator: "cardinal-closed"): Line; interpolator(interpolator: "monotone"): Line; protected _createDrawer(dataset: Dataset): Drawer; - protected _extentsForProperty(property: string): any[]; + protected _extentsForProperty(property: string): any[]; protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { @@ -3528,10 +3528,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Plots { - class Area extends Line { + class Area extends Line { /** * An Area Plot draws a filled region (area) between Y and Y0. * @@ -3558,7 +3558,7 @@ declare module Plottable { addDataset(dataset: Dataset): Area; protected _addDataset(dataset: Dataset): Area; protected _removeDatasetNodes(dataset: Dataset): void; - protected _additionalPaint(): void; + protected _additionalPaint(): void; protected _createDrawer(dataset: Dataset): Drawers.Area; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _updateYScale(): void; @@ -3570,10 +3570,10 @@ declare module Plottable { } } - +/// declare module Plottable { module Plots { - class ClusteredBar extends Bar { + class ClusteredBar extends Bar { /** * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. @@ -3585,16 +3585,16 @@ declare module Plottable { constructor(orientation?: string); protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; + }; protected _getDataToDraw(): Utils.Map; } } } - +/// declare module Plottable { module Plots { - class StackedArea extends Area { + class StackedArea extends Area { /** * @constructor */ @@ -3611,7 +3611,7 @@ declare module Plottable { protected _updateYScale(): void; protected _onDatasetUpdate(): StackedArea; protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; + protected _extentsForProperty(attr: string): any[]; /** * Given an array of Datasets and the accessor function for the key, computes the * set reunion (no duplicates) of the domain of each Dataset. The keys are stringified @@ -3620,17 +3620,17 @@ declare module Plottable { * @param {Dataset[]} datasets The Datasets for which we extract the domain keys * @param {Accessor} keyAccessor The accessor for the key of the data * @return {string[]} An array of stringified keys - */ + */ protected _propertyProjectors(): AttributeToProjector; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; } } } - +/// declare module Plottable { module Plots { - class StackedBar extends Bar { + class StackedBar extends Bar { /** * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. * On a vertical StackedBar Plot, the bars with the same X value are stacked. @@ -3653,15 +3653,15 @@ declare module Plottable { }; protected _onDatasetUpdate(): StackedBar; protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; + protected _extentsForProperty(attr: string): any[]; } } } - +/// declare module Plottable { module Plots { - class Segment extends XYPlot { + class Segment extends XYPlot { /** * A Segment Plot displays line segments based on the data. * @@ -3751,15 +3751,15 @@ declare module Plottable { * @param {Range} yRange * @returns {PlotEntity[]} */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; } } } - +/// declare module Plottable { module Plots { - class Waterfall extends Bar { + class Waterfall extends Bar { constructor(); /** * Gets whether connectors are enabled. @@ -3791,15 +3791,15 @@ declare module Plottable { protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; }; - protected _onDatasetUpdate(): Waterfall; + protected _onDatasetUpdate(): Waterfall; } } } - +/// declare module Plottable { module Plots { - class Wheel extends Plot { + class Wheel extends Plot { /** * @constructor */ @@ -3883,7 +3883,7 @@ declare module Plottable { } } - +/// declare module Plottable { interface Animator { /** @@ -3907,7 +3907,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Animators { /** @@ -3921,7 +3921,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Animators { /** @@ -3930,19 +3930,19 @@ declare module Plottable { class Easing implements Animator { /** * The default starting delay of the animation in milliseconds - */ + */ /** * The default duration of one animation step in milliseconds - */ + */ /** * The default maximum start delay between each step of an animation - */ + */ /** * The default maximum total animation duration - */ + */ /** * The default easing of the animation - */ + */ /** * Constructs the default animator * @@ -4026,28 +4026,28 @@ declare module Plottable { easingMode(easingMode: string): Easing; /** * Adjust the iterative delay, such that it takes into account the maxTotalDuration constraint - */ + */ } } } - +/// declare module Plottable { class Dispatcher { protected _eventToCallback: { [eventName: string]: (e: Event) => any; }; - protected _callbacks: Utils.CallbackSet[]; + protected _callbacks: Utils.CallbackSet[]; protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; } } - +/// declare module Plottable { module Dispatchers { type MouseCallback = (p: Point, event: MouseEvent) => void; - class Mouse extends Dispatcher { + class Mouse extends Dispatcher { /** * Get a Mouse Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4136,7 +4136,7 @@ declare module Plottable { /** * Computes the mouse position from the given event, and if successful * calls all the callbacks in the provided callbackSet. - */ + */ eventInsideSVG(event: MouseEvent): boolean; /** * Returns the last computed mouse position in coordinate space. @@ -4148,13 +4148,13 @@ declare module Plottable { } } - +/// declare module Plottable { module Dispatchers { type TouchCallback = (ids: number[], idToPoint: { [id: number]: Point; }, event: TouchEvent) => void; - class Touch extends Dispatcher { + class Touch extends Dispatcher { /** * Gets a Touch Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4229,17 +4229,17 @@ declare module Plottable { /** * Computes the Touch position from the given event, and if successful * calls all the callbacks in the provided callbackSet. - */ + */ eventInsideSVG(event: TouchEvent): boolean; } } } - +/// declare module Plottable { module Dispatchers { type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; - class Key extends Dispatcher { + class Key extends Dispatcher { /** * Gets a Key Dispatcher. If one already exists it will be returned; * otherwise, a new one will be created. @@ -4279,15 +4279,15 @@ declare module Plottable { * @param {KeyCallback} callback * @return {Dispatchers.Key} The calling Key Dispatcher. */ - offKeyUp(callback: KeyCallback): Key; + offKeyUp(callback: KeyCallback): Key; } } } - +/// declare module Plottable { class Interaction { - protected _componentAttachedTo: Component; + protected _componentAttachedTo: Component; protected _anchor(component: Component): void; protected _unanchor(): void; /** @@ -4297,7 +4297,7 @@ declare module Plottable { * @param {Component} component * @returns {Interaction} The calling Interaction. */ - attachTo(component: Component): Interaction; + attachTo(component: Component): Interaction; /** * Detaches this Interaction from the Component. * This Interaction can be reused. @@ -4305,7 +4305,7 @@ declare module Plottable { * @param {Component} component * @returns {Interaction} The calling Interaction. */ - detachFrom(component: Component): Interaction; + detachFrom(component: Component): Interaction; /** * Gets whether this Interaction is enabled. */ @@ -4334,13 +4334,13 @@ declare module Plottable { } } - +/// declare module Plottable { type ClickCallback = (point: Point) => void; module Interactions { - class Click extends Interaction { + class Click extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the Component is clicked. * @@ -4359,12 +4359,12 @@ declare module Plottable { } } - +/// declare module Plottable { module Interactions { - class DoubleClick extends Interaction { + class DoubleClick extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the Component is double-clicked. * @@ -4383,7 +4383,7 @@ declare module Plottable { } } - +/// declare module Plottable { type KeyCallback = (keyCode: number) => void; module Interactions { @@ -4391,9 +4391,9 @@ declare module Plottable { /** * A Key Interaction listens to key events that occur while the Component is * moused over. - */ + */ protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the key with the given keyCode is * pressed and the user is moused over the Component. @@ -4434,13 +4434,13 @@ declare module Plottable { } } - +/// declare module Plottable { type PointerCallback = (point: Point) => void; module Interactions { - class Pointer extends Interaction { + class Pointer extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Adds a callback to be called when the pointer enters the Component. * @@ -4487,13 +4487,13 @@ declare module Plottable { } } - +/// declare module Plottable { module Interactions { class PanZoom extends Interaction { /** * The number of pixels occupied in a line. - */ + */ /** * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale * in response to the user panning or zooming. @@ -4504,7 +4504,7 @@ declare module Plottable { */ constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Gets the x scales for this PanZoom Interaction. */ @@ -4599,13 +4599,13 @@ declare module Plottable { } } - +/// declare module Plottable { type DragCallback = (start: Point, end: Point) => void; module Interactions { - class Drag extends Interaction { + class Drag extends Interaction { protected _anchor(component: Component): void; - protected _unanchor(): void; + protected _unanchor(): void; /** * Gets whether the Drag Interaction constrains Points passed to its * callbacks to lie inside its Component. @@ -4675,12 +4675,12 @@ declare module Plottable { } } - +/// declare module Plottable { type DragBoxCallback = (bounds: Bounds) => void; module Components { - class DragBoxLayer extends Components.SelectionBoxLayer { - protected _hasCorners: boolean; + class DragBoxLayer extends Components.SelectionBoxLayer { + protected _hasCorners: boolean; /** * Constructs a DragBoxLayer. * @@ -4690,8 +4690,8 @@ declare module Plottable { * * @constructor */ - constructor(); - protected _setup(): void; + constructor(); + protected _setup(): void; renderImmediately(): DragBoxLayer; /** * Gets the detection radius of the drag box in pixels. @@ -4726,7 +4726,7 @@ declare module Plottable { * @param {boolean} movable * @return {DragBoxLayer} The calling DragBoxLayer. */ - movable(movable: boolean): DragBoxLayer; + movable(movable: boolean): DragBoxLayer; /** * Sets the callback to be called when dragging starts. * @@ -4783,12 +4783,12 @@ declare module Plottable { enabled(): boolean; destroy(): void; detach(): Component; - anchor(selection: d3.Selection): Component; + anchor(selection: d3.Selection): Component; } } } - +/// declare module Plottable { module Components { class XDragBoxLayer extends DragBoxLayer { @@ -4818,7 +4818,7 @@ declare module Plottable { } } - +/// declare module Plottable { module Components { class YDragBoxLayer extends DragBoxLayer { @@ -4848,13 +4848,13 @@ declare module Plottable { } } - +/// declare module Plottable { interface DragLineCallback { (dragLineLayer: Components.DragLineLayer): void; } module Components { - class DragLineLayer extends GuideLineLayer { + class DragLineLayer extends GuideLineLayer { constructor(orientation: string); protected _setup(): void; renderImmediately(): DragLineLayer; From 4592debf5285863d02a930daf156680bd2287cf6 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Sun, 4 Oct 2015 22:10:12 +1100 Subject: [PATCH 13/19] build plottable.js and .d.ts --- plottable.d.ts | 172 ++++++++++++++++++++++++++----------------------- plottable.js | 12 ++-- 2 files changed, 100 insertions(+), 84 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index 5d8153247f..fc4bd0619d 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -1,4 +1,4 @@ -/// + declare module Plottable { module Utils { module Math { @@ -59,7 +59,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { /** @@ -77,7 +77,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { /** @@ -95,7 +95,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { module DOM { @@ -193,7 +193,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { module Color { @@ -223,7 +223,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { module Array { @@ -260,7 +260,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { /** @@ -274,7 +274,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { module Stacking { @@ -312,7 +312,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { module Window { @@ -346,7 +346,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Utils { class ClientToSVGTranslator { @@ -368,7 +368,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Configs { /** @@ -382,12 +382,12 @@ declare module Plottable { } } -/// + declare module Plottable { var version: string; } -/// + declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; class KeyFunctions { @@ -456,7 +456,7 @@ declare module Plottable { } } -/// + declare module Plottable { module RenderPolicies { /** @@ -490,7 +490,7 @@ declare module Plottable { } } -/// + declare module Plottable { /** * The RenderController is responsible for enqueueing and synchronizing @@ -610,7 +610,7 @@ declare module Plottable { } } -/// + declare module Plottable { type Formatter = (d: any) => string; /** @@ -722,7 +722,7 @@ declare module Plottable { } } -/// + declare module Plottable { /** * A SymbolFactory is a function that takes in a symbolSize which is the edge length of the render area @@ -739,7 +739,7 @@ declare module Plottable { } } -/// + declare module Plottable { interface ScaleCallback> { (scale: S): any; @@ -859,7 +859,7 @@ declare module Plottable { } } -/// + declare module Plottable { class QuantitativeScale extends Scale { protected static _DEFAULT_NUM_TICKS: number; @@ -976,7 +976,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { class Linear extends QuantitativeScale { @@ -998,7 +998,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { class ModifiedLog extends QuantitativeScale { @@ -1065,7 +1065,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { class Category extends Scale { @@ -1141,7 +1141,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { class Color extends Scale { @@ -1173,7 +1173,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { class Time extends QuantitativeScale { @@ -1211,7 +1211,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { class InterpolatedColor extends Scale { @@ -1241,7 +1241,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Scales { module TickGenerators { @@ -1273,7 +1273,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { /** @@ -1356,7 +1356,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class Line extends Drawer { @@ -1367,7 +1367,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class Area extends Drawer { @@ -1378,7 +1378,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class Rectangle extends Drawer { @@ -1387,7 +1387,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class Arc extends Drawer { @@ -1397,7 +1397,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class ArcOutline extends Drawer { @@ -1407,7 +1407,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class Symbol extends Drawer { @@ -1416,7 +1416,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Drawers { class Segment extends Drawer { @@ -1425,7 +1425,7 @@ declare module Plottable { } } -/// + declare module Plottable { type ComponentCallback = (component: Component) => void; module Components { @@ -1658,7 +1658,7 @@ declare module Plottable { } } -/// + declare module Plottable { class ComponentContainer extends Component { constructor(); @@ -1691,7 +1691,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class Group extends ComponentContainer { @@ -1732,7 +1732,7 @@ declare module Plottable { } } -/// + declare module Plottable { class Axis extends Component { /** @@ -1947,7 +1947,7 @@ declare module Plottable { } } -/// + declare module Plottable { module TimeInterval { var second: string; @@ -2035,7 +2035,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Axes { class Numeric extends Axis { @@ -2102,7 +2102,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Axes { class Category extends Axis { @@ -2149,7 +2149,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class Label extends Component { @@ -2221,7 +2221,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class Legend extends Component { @@ -2339,7 +2339,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class InterpolatedColorLegend extends Component { @@ -2401,7 +2401,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class Gridlines extends Component { @@ -2419,7 +2419,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class Table extends ComponentContainer { @@ -2537,7 +2537,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { enum PropertyMode { @@ -2647,7 +2647,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class GuideLineLayer extends Component { @@ -2713,7 +2713,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { interface PlotEntity extends Entity { @@ -2872,7 +2872,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Pie extends Plot { @@ -2988,7 +2988,7 @@ declare module Plottable { } } -/// + declare module Plottable { class XYPlot extends Plot { protected static _X_KEY: string; @@ -3089,7 +3089,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Rectangle extends XYPlot { @@ -3236,7 +3236,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Scatter extends XYPlot { @@ -3313,7 +3313,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Bar extends XYPlot { @@ -3452,7 +3452,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Line extends XYPlot { @@ -3507,6 +3507,18 @@ declare module Plottable { interpolator(interpolator: "cardinal-open"): Line; interpolator(interpolator: "cardinal-closed"): Line; interpolator(interpolator: "monotone"): Line; + /** + * Gets if croppedRendering is enabled + * + * When croppedRendering is enabled, lines that will not be visible in the viewport will not be drawn. + */ + croppedRenderingEnabled(): boolean; + /** + * Sets if croppedRendering is enabled + * + * @returns {Plots.Line} The calling Plots.Line + */ + croppedRenderingEnabled(croppedRendering: boolean): Plots.Line; protected _createDrawer(dataset: Dataset): Drawer; protected _extentsForProperty(property: string): any[]; protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; @@ -3528,7 +3540,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Area extends Line { @@ -3570,7 +3582,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class ClusteredBar extends Bar { @@ -3591,7 +3603,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class StackedArea extends Area { @@ -3627,7 +3639,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class StackedBar extends Bar { @@ -3658,7 +3670,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Segment extends XYPlot { @@ -3756,7 +3768,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Waterfall extends Bar { @@ -3796,7 +3808,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Plots { class Wheel extends Plot { @@ -3883,7 +3895,7 @@ declare module Plottable { } } -/// + declare module Plottable { interface Animator { /** @@ -3907,7 +3919,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Animators { /** @@ -3921,7 +3933,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Animators { /** @@ -4031,7 +4043,7 @@ declare module Plottable { } } -/// + declare module Plottable { class Dispatcher { protected _eventToCallback: { @@ -4043,7 +4055,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Dispatchers { type MouseCallback = (p: Point, event: MouseEvent) => void; @@ -4148,7 +4160,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Dispatchers { type TouchCallback = (ids: number[], idToPoint: { @@ -4235,7 +4247,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Dispatchers { type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; @@ -4284,7 +4296,7 @@ declare module Plottable { } } -/// + declare module Plottable { class Interaction { protected _componentAttachedTo: Component; @@ -4334,7 +4346,7 @@ declare module Plottable { } } -/// + declare module Plottable { type ClickCallback = (point: Point) => void; module Interactions { @@ -4359,7 +4371,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Interactions { class DoubleClick extends Interaction { @@ -4383,7 +4395,7 @@ declare module Plottable { } } -/// + declare module Plottable { type KeyCallback = (keyCode: number) => void; module Interactions { @@ -4434,7 +4446,7 @@ declare module Plottable { } } -/// + declare module Plottable { type PointerCallback = (point: Point) => void; module Interactions { @@ -4487,7 +4499,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Interactions { class PanZoom extends Interaction { @@ -4599,7 +4611,7 @@ declare module Plottable { } } -/// + declare module Plottable { type DragCallback = (start: Point, end: Point) => void; module Interactions { @@ -4675,7 +4687,7 @@ declare module Plottable { } } -/// + declare module Plottable { type DragBoxCallback = (bounds: Bounds) => void; module Components { @@ -4788,7 +4800,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class XDragBoxLayer extends DragBoxLayer { @@ -4818,7 +4830,7 @@ declare module Plottable { } } -/// + declare module Plottable { module Components { class YDragBoxLayer extends DragBoxLayer { @@ -4848,7 +4860,7 @@ declare module Plottable { } } -/// + declare module Plottable { interface DragLineCallback { (dragLineLayer: Components.DragLineLayer): void; diff --git a/plottable.js b/plottable.js index 655afe7283..c818fca825 100644 --- a/plottable.js +++ b/plottable.js @@ -918,8 +918,12 @@ var Plottable; function KeyFunctions() { } KeyFunctions.counter = 0; - KeyFunctions.noConstancy = function (d) { return KeyFunctions.counter++; }; - KeyFunctions.byIndex = function (d, i) { return i; }; + KeyFunctions.noConstancy = function (d, i) { + return KeyFunctions.counter++; + }; + KeyFunctions.byIndex = function (d, i) { + return i; + }; return KeyFunctions; })(); Plottable.KeyFunctions = KeyFunctions; @@ -935,7 +939,7 @@ var Plottable; function Dataset(data, metadata) { if (data === void 0) { data = []; } if (metadata === void 0) { metadata = {}; } - this._key = KeyFunctions.noConstancy; + this._key = KeyFunctions.byIndex; this._data = data; this._metadata = metadata; this._callbacks = new Plottable.Utils.CallbackSet(); @@ -2686,7 +2690,7 @@ var Plottable; Drawer.prototype._bindSelectionData = function (data) { // if the dataset has a key, use it when binding the data var dataElements; - if (this._dataset && this._dataset.key) { + if (this._dataset && this._dataset.key()) { dataElements = this.selection().data(data, this._dataset.key()); } else { From 9aac33e0798a90566849dd36034bbb308df43cda Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Thu, 8 Oct 2015 17:46:22 +1100 Subject: [PATCH 14/19] byIndex becomes useIndex --- src/core/dataset.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 4924f5d1c2..4b6aeaf986 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -9,15 +9,18 @@ export class KeyFunctions { public static noConstancy: (d: any, i: number) => any = (d: any, i: number) => { return KeyFunctions.counter++; }; - public static byIndex: (d: any, i: number) => any = (d: any, i: number) => { + public static useIndex: (d: any, i: number) => any = (d: any, i: number) => { return i; }; + public static useProperty(propertyname: string) { + return (d: any, i: number) => { return d[propertyname] }; + }; } export class Dataset { private _data: any[]; private _metadata: any; - private _key: (datum: any, index: number) => any = KeyFunctions.byIndex; + private _key: (datum: any, index: number) => any = KeyFunctions.useIndex; private _callbacks: Utils.CallbackSet; /** From 08bd88783119e74391de8352e94737cb80860f7d Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 9 Oct 2015 17:40:22 +1100 Subject: [PATCH 15/19] tests updated for changed names --- plottable.d.ts | 15 +++++++++++++++ plottable.js | 22 +++++++++++++--------- src/core/dataset.ts | 16 ++++++++-------- src/drawers/drawer.ts | 4 ++-- test/core/datasetTests.ts | 8 ++++---- test/core/keyTests.ts | 28 ++++++++++++++-------------- 6 files changed, 56 insertions(+), 37 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index 4344bc6fbe..e3c98809ca 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -397,9 +397,16 @@ declare module Plottable { declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; + class KeyFunctions { + protected static counter: number; + static noConstancy: (d: any, i: number) => any; + static useIndex: (d: any, i: number) => any; + static useProperty(propertyname: string): (d: any, i: number) => any; + } class Dataset { private _data; private _metadata; + private _keyFunction; private _callbacks; /** * A Dataset contains an array of data and some metadata. @@ -450,6 +457,14 @@ declare module Plottable { * @returns {Dataset} The calling Dataset. */ metadata(metadata: any): Dataset; + keyFunction(): (datum: any, index: number) => any; + /** + * Sets the key. + * + * @param { (d: any, i: number) => any} key + * @returns {Dataset} The calling Dataset. + */ + keyFunction(keyFunction: (datum: any, index: number) => any): Dataset; } } diff --git a/plottable.js b/plottable.js index 5cd38bd0e0..6b841b88a7 100644 --- a/plottable.js +++ b/plottable.js @@ -3,7 +3,7 @@ Plottable 1.14.0 (https://github.com/palantir/plottable) Copyright 2014-2015 Palantir Technologies Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE) */ - +//# sourceURL=plottable.js (function(root, factory) { if(typeof exports === 'object') { module.exports = factory(require, exports, module); @@ -917,11 +917,15 @@ var Plottable; var KeyFunctions = (function () { function KeyFunctions() { } + KeyFunctions.useProperty = function (propertyname) { + return function (d, i) { return d[propertyname]; }; + }; + ; KeyFunctions.counter = 0; KeyFunctions.noConstancy = function (d, i) { return KeyFunctions.counter++; }; - KeyFunctions.byIndex = function (d, i) { + KeyFunctions.useIndex = function (d, i) { return i; }; return KeyFunctions; @@ -939,7 +943,7 @@ var Plottable; function Dataset(data, metadata) { if (data === void 0) { data = []; } if (metadata === void 0) { metadata = {}; } - this._key = KeyFunctions.byIndex; + this._keyFunction = KeyFunctions.useIndex; this._data = data; this._metadata = metadata; this._callbacks = new Plottable.Utils.CallbackSet(); @@ -984,12 +988,12 @@ var Plottable; return this; } }; - Dataset.prototype.key = function (key) { - if (key == null) { - return this._key; + Dataset.prototype.keyFunction = function (keyFunction) { + if (keyFunction == null) { + return this._keyFunction; } else { - this._key = key; + this._keyFunction = keyFunction; this._callbacks.callCallbacks(this); return this; } @@ -2690,8 +2694,8 @@ var Plottable; Drawer.prototype._bindSelectionData = function (data) { // if the dataset has a key, use it when binding the data var dataElements; - if (this._dataset && this._dataset.key()) { - dataElements = this.selection().data(data, this._dataset.key()); + if (this._dataset && this._dataset.keyFunction()) { + dataElements = this.selection().data(data, this._dataset.keyFunction()); } else { dataElements = this.selection().data(data); diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 4b6aeaf986..1955bbf6f8 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -13,14 +13,14 @@ export class KeyFunctions { return i; }; public static useProperty(propertyname: string) { - return (d: any, i: number) => { return d[propertyname] }; + return (d: any, i: number) => { return d[propertyname]; }; }; } export class Dataset { private _data: any[]; private _metadata: any; - private _key: (datum: any, index: number) => any = KeyFunctions.useIndex; + private _keyFunction: (datum: any, index: number) => any = KeyFunctions.useIndex; private _callbacks: Utils.CallbackSet; /** @@ -105,19 +105,19 @@ export class Dataset { } } - public key(): (datum: any, index: number) => any; + public keyFunction(): (datum: any, index: number) => any; /** * Sets the key. * * @param { (d: any, i: number) => any} key * @returns {Dataset} The calling Dataset. */ - public key(key: (datum: any, index: number) => any): Dataset; - public key(key?: (datum: any, index: number) => any): any { - if (key == null) { - return this._key; + public keyFunction(keyFunction: (datum: any, index: number) => any): Dataset; + public keyFunction(keyFunction?: (datum: any, index: number) => any): any { + if (keyFunction == null) { + return this._keyFunction; } else { - this._key = key; + this._keyFunction = keyFunction; this._callbacks.callCallbacks(this); return this; } diff --git a/src/drawers/drawer.ts b/src/drawers/drawer.ts index 02f753989c..eeb32723e6 100644 --- a/src/drawers/drawer.ts +++ b/src/drawers/drawer.ts @@ -78,8 +78,8 @@ export class Drawer { private _bindSelectionData(data: any[]) { // if the dataset has a key, use it when binding the data let dataElements: d3.selection.Update; - if (this._dataset && this._dataset.key()) { - dataElements = this.selection().data(data, this._dataset.key()); + if (this._dataset && this._dataset.keyFunction()) { + dataElements = this.selection().data(data, this._dataset.keyFunction()); } else { dataElements = this.selection().data(data); } diff --git a/test/core/datasetTests.ts b/test/core/datasetTests.ts index 2fd2db5e6a..b8fd961e82 100644 --- a/test/core/datasetTests.ts +++ b/test/core/datasetTests.ts @@ -56,8 +56,8 @@ describe("Dataset", () => { ds.data(newData2); assert.isFalse(callbackCalled, "callback was called when the data was changed"); }); - describe("key", () => { - it("Updates listeners when the key is changed", () => { + describe("keyFunction", () => { + it("Updates listeners when the keyFunction is changed", () => { let ds = new Plottable.Dataset(); let newKey = (d: any, i: number) => { return i * i; }; @@ -65,12 +65,12 @@ describe("Dataset", () => { let callbackCalled = false; let callback = (listenable: Plottable.Dataset) => { assert.strictEqual(listenable, ds, "Callback received the Dataset as the first argument"); - assert.deepEqual(ds.key(), newKey, "Dataset arrives with correct key"); + assert.deepEqual(ds.keyFunction(), newKey, "Dataset arrives with correct keyFunction"); callbackCalled = true; }; ds.onUpdate(callback); - ds.key(newKey); + ds.keyFunction(newKey); assert.isTrue(callbackCalled, "callback was called when the key was changed"); }); diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts index 971814223f..848ed981e2 100644 --- a/test/core/keyTests.ts +++ b/test/core/keyTests.ts @@ -4,36 +4,36 @@ describe("DatasetKey", () => { it(" is passed to Dataset", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); let key: (d: any, i: number) => number = (d: any, i: number) => { return i; }; - ds.key(key); - assert.deepEqual(ds.key(), key, "key is passed to dataset"); + ds.keyFunction(key); + assert.deepEqual(ds.keyFunction(), key, "key is passed to dataset"); }); it(" may accept noConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - ds.key(Plottable.KeyFunctions.noConstancy); + ds.keyFunction(Plottable.KeyFunctions.noConstancy); let d: any = { foo: "bar" }; - let a: number = ds.key()(d, 1); - let b: number = ds.key()(d, 1); + let a: number = ds.keyFunction()(d, 1); + let b: number = ds.keyFunction()(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); - it(" defaults to byIndex predefined key function", () => { + it(" defaults to useIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - assert.isTrue(ds.key() === Plottable.KeyFunctions.byIndex, "byIndex is default"); + assert.isTrue(ds.keyFunction() === Plottable.KeyFunctions.useIndex, "useIndex is default"); }); - it(" may accept ByIndex predefined key function", () => { + it(" may accept useIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - ds.key(Plottable.KeyFunctions.byIndex); + ds.keyFunction(Plottable.KeyFunctions.useIndex); let d: any = { foo: "bar" }; - let a: number = ds.key()(d, 1); - let b: number = ds.key()(d, 2); + let a: number = ds.keyFunction()(d, 1); + let b: number = ds.keyFunction()(d, 2); assert.isTrue(a === 1, "invocations return index"); assert.isTrue(b === 2, "invocations return index"); }); describe("DatasetKey noConstancy", () => { it("generates a different value each time invoked", () => { - let key = Plottable.KeyFunctions.noConstancy; + let keyFunction = Plottable.KeyFunctions.noConstancy; let d: any = { foo: "bar" }; - let a: number = key(d, 1); - let b: number = key(d, 1); + let a: number = keyFunction(d, 1); + let b: number = keyFunction(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); From b26e58adc46695a282579529ca6722b4bbec5052 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Fri, 9 Oct 2015 21:23:09 +1100 Subject: [PATCH 16/19] removing explicit typings --- plottable.d.ts | 11 +++++++---- plottable.js | 1 - src/core/dataset.ts | 13 ++++++++----- test/core/keyTests.ts | 20 ++++++++++---------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index e3c98809ca..399f365b1a 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -398,9 +398,9 @@ declare module Plottable { declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; class KeyFunctions { - protected static counter: number; - static noConstancy: (d: any, i: number) => any; - static useIndex: (d: any, i: number) => any; + private static counter; + static noConstancy: (d: any, i: number) => number; + static useIndex: (d: any, i: number) => number; static useProperty(propertyname: string): (d: any, i: number) => any; } class Dataset { @@ -459,7 +459,10 @@ declare module Plottable { metadata(metadata: any): Dataset; keyFunction(): (datum: any, index: number) => any; /** - * Sets the key. + * Sets the keyFunction. + * in d3, when binding data using selection.data(), a keyFunction may be supplied + * to generate a unique identifier for each datum. When data is updated, d3 uses this identifier to + * determine which data points have entered or exited the visualisation. * * @param { (d: any, i: number) => any} key * @returns {Dataset} The calling Dataset. diff --git a/plottable.js b/plottable.js index 6b841b88a7..a454c30bf7 100644 --- a/plottable.js +++ b/plottable.js @@ -3,7 +3,6 @@ Plottable 1.14.0 (https://github.com/palantir/plottable) Copyright 2014-2015 Palantir Technologies Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE) */ -//# sourceURL=plottable.js (function(root, factory) { if(typeof exports === 'object') { module.exports = factory(require, exports, module); diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 1955bbf6f8..84d83935e5 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -5,11 +5,11 @@ module Plottable { export type DatasetCallback = (dataset: Dataset) => void; export class KeyFunctions { - protected static counter: number = 0; - public static noConstancy: (d: any, i: number) => any = (d: any, i: number) => { + private static counter: number = 0; + public static noConstancy = (d: any, i: number) => { return KeyFunctions.counter++; }; - public static useIndex: (d: any, i: number) => any = (d: any, i: number) => { + public static useIndex = (d: any, i: number) => { return i; }; public static useProperty(propertyname: string) { @@ -20,7 +20,7 @@ export class KeyFunctions { export class Dataset { private _data: any[]; private _metadata: any; - private _keyFunction: (datum: any, index: number) => any = KeyFunctions.useIndex; + private _keyFunction = KeyFunctions.useIndex; private _callbacks: Utils.CallbackSet; /** @@ -107,7 +107,10 @@ export class Dataset { public keyFunction(): (datum: any, index: number) => any; /** - * Sets the key. + * Sets the keyFunction. + * in d3, when binding data using selection.data(), a keyFunction may be supplied + * to generate a unique identifier for each datum. When data is updated, d3 uses this identifier to + * determine which data points have entered or exited the visualisation. * * @param { (d: any, i: number) => any} key * @returns {Dataset} The calling Dataset. diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts index 848ed981e2..cba428be82 100644 --- a/test/core/keyTests.ts +++ b/test/core/keyTests.ts @@ -3,16 +3,16 @@ describe("DatasetKey", () => { it(" is passed to Dataset", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); - let key: (d: any, i: number) => number = (d: any, i: number) => { return i; }; + let key = (d: any, i: number) => { return i; }; ds.keyFunction(key); assert.deepEqual(ds.keyFunction(), key, "key is passed to dataset"); }); it(" may accept noConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); ds.keyFunction(Plottable.KeyFunctions.noConstancy); - let d: any = { foo: "bar" }; - let a: number = ds.keyFunction()(d, 1); - let b: number = ds.keyFunction()(d, 1); + let d = { foo: "bar" }; + let a = ds.keyFunction()(d, 1); + let b = ds.keyFunction()(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); it(" defaults to useIndex predefined key function", () => { @@ -22,18 +22,18 @@ describe("DatasetKey", () => { it(" may accept useIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); ds.keyFunction(Plottable.KeyFunctions.useIndex); - let d: any = { foo: "bar" }; - let a: number = ds.keyFunction()(d, 1); - let b: number = ds.keyFunction()(d, 2); + let d = { foo: "bar" }; + let a = ds.keyFunction()(d, 1); + let b = ds.keyFunction()(d, 2); assert.isTrue(a === 1, "invocations return index"); assert.isTrue(b === 2, "invocations return index"); }); describe("DatasetKey noConstancy", () => { it("generates a different value each time invoked", () => { let keyFunction = Plottable.KeyFunctions.noConstancy; - let d: any = { foo: "bar" }; - let a: number = keyFunction(d, 1); - let b: number = keyFunction(d, 1); + let d = { foo: "bar" }; + let a = keyFunction(d, 1); + let b = keyFunction(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); From 194ad73edc81f6970ba1306f9da9c42b21776a0a Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Sat, 10 Oct 2015 09:33:11 +1100 Subject: [PATCH 17/19] white space, minor fixups as requested --- plottable.d.ts | 18 ++++++++++++++++++ plottable.js | 1 + src/core/dataset.ts | 2 +- test/core/datasetTests.ts | 1 + test/core/keyTests.ts | 12 ++++++++---- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index 5a2b69c70e..eb2550607f 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -397,9 +397,16 @@ declare module Plottable { declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; + class KeyFunctions { + private static counter; + static noConstancy: (d: any, i: number) => number; + static useIndex: (d: any, i: number) => number; + static useProperty(propertyname: string): (d: any, i: number) => any; + } class Dataset { private _data; private _metadata; + private _keyFunction; private _callbacks; /** * A Dataset contains an array of data and some metadata. @@ -450,6 +457,17 @@ declare module Plottable { * @returns {Dataset} The calling Dataset. */ metadata(metadata: any): Dataset; + keyFunction(): (datum: any, index: number) => any; + /** + * Sets the keyFunction. + * in d3, when binding data using selection.data(), a keyFunction may be supplied + * to generate a unique identifier for each datum. When data is updated, d3 uses this identifier to + * determine which data points have entered or exited the visualisation. + * + * @param { (d: any, i: number) => any} keyFunction + * @returns {Dataset} The calling Dataset. + */ + keyFunction(keyFunction: (datum: any, index: number) => any): Dataset; } } diff --git a/plottable.js b/plottable.js index 53211e18d7..151258158e 100644 --- a/plottable.js +++ b/plottable.js @@ -3,6 +3,7 @@ Plottable 1.14.0 (https://github.com/palantir/plottable) Copyright 2014-2015 Palantir Technologies Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE) */ + (function(root, factory) { if(typeof exports === 'object') { module.exports = factory(require, exports, module); diff --git a/src/core/dataset.ts b/src/core/dataset.ts index 84d83935e5..fc25b75f5c 100644 --- a/src/core/dataset.ts +++ b/src/core/dataset.ts @@ -112,7 +112,7 @@ export class Dataset { * to generate a unique identifier for each datum. When data is updated, d3 uses this identifier to * determine which data points have entered or exited the visualisation. * - * @param { (d: any, i: number) => any} key + * @param { (d: any, i: number) => any} keyFunction * @returns {Dataset} The calling Dataset. */ public keyFunction(keyFunction: (datum: any, index: number) => any): Dataset; diff --git a/test/core/datasetTests.ts b/test/core/datasetTests.ts index b8fd961e82..20558e1950 100644 --- a/test/core/datasetTests.ts +++ b/test/core/datasetTests.ts @@ -56,6 +56,7 @@ describe("Dataset", () => { ds.data(newData2); assert.isFalse(callbackCalled, "callback was called when the data was changed"); }); + describe("keyFunction", () => { it("Updates listeners when the keyFunction is changed", () => { let ds = new Plottable.Dataset(); diff --git a/test/core/keyTests.ts b/test/core/keyTests.ts index cba428be82..e3293d0e19 100644 --- a/test/core/keyTests.ts +++ b/test/core/keyTests.ts @@ -1,13 +1,14 @@ /// describe("DatasetKey", () => { - it(" is passed to Dataset", () => { + it("is passed to Dataset", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); let key = (d: any, i: number) => { return i; }; ds.keyFunction(key); assert.deepEqual(ds.keyFunction(), key, "key is passed to dataset"); }); - it(" may accept noConstancy predefined key function", () => { + + it("may accept noConstancy predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); ds.keyFunction(Plottable.KeyFunctions.noConstancy); let d = { foo: "bar" }; @@ -15,11 +16,13 @@ describe("DatasetKey", () => { let b = ds.keyFunction()(d, 1); assert.isTrue(b - a === 1, "invocations give numerically increasing results"); }); - it(" defaults to useIndex predefined key function", () => { + + it("defaults to useIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); assert.isTrue(ds.keyFunction() === Plottable.KeyFunctions.useIndex, "useIndex is default"); }); - it(" may accept useIndex predefined key function", () => { + + it("may accept useIndex predefined key function", () => { let ds: Plottable.Dataset = new Plottable.Dataset(); ds.keyFunction(Plottable.KeyFunctions.useIndex); let d = { foo: "bar" }; @@ -28,6 +31,7 @@ describe("DatasetKey", () => { assert.isTrue(a === 1, "invocations return index"); assert.isTrue(b === 2, "invocations return index"); }); + describe("DatasetKey noConstancy", () => { it("generates a different value each time invoked", () => { let keyFunction = Plottable.KeyFunctions.noConstancy; From 6ae3357d96fb68887271795f9392dd7b56a12b6b Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Sat, 10 Oct 2015 15:43:09 +1100 Subject: [PATCH 18/19] restore ScatterPlot animateOnNextRender logic --- plottable.js | 5 +++++ src/plots/scatterPlot.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/plottable.js b/plottable.js index 151258158e..afef64fc54 100644 --- a/plottable.js +++ b/plottable.js @@ -8287,6 +8287,11 @@ var Plottable; }; Scatter.prototype._generateDrawSteps = function () { var drawSteps = []; + if (this._animateOnNextRender()) { + var resetAttrToProjector = this._generateAttrToProjector(); + resetAttrToProjector["d"] = function () { return ""; }; + drawSteps.push({ attrToProjector: resetAttrToProjector, animator: this._getAnimator(Plots.Animator.RESET) }); + } drawSteps.push({ attrToProjector: this._generateAttrToProjector(), animator: this._getAnimator(Plots.Animator.MAIN) }); return drawSteps; }; diff --git a/src/plots/scatterPlot.ts b/src/plots/scatterPlot.ts index c5cd209ec7..94c55d8bd4 100644 --- a/src/plots/scatterPlot.ts +++ b/src/plots/scatterPlot.ts @@ -83,6 +83,12 @@ export module Plots { protected _generateDrawSteps(): Drawers.DrawStep[] { let drawSteps: Drawers.DrawStep[] = []; + if (this._animateOnNextRender()) { + let resetAttrToProjector = this._generateAttrToProjector(); + resetAttrToProjector["d"] = () => ""; + drawSteps.push({attrToProjector: resetAttrToProjector, animator: this._getAnimator(Plots.Animator.RESET)}); + } + drawSteps.push({attrToProjector: this._generateAttrToProjector(), animator: this._getAnimator(Plots.Animator.MAIN)}); return drawSteps; } From 535799b70dbc11946f6ea96475cd9eb7e2718ae4 Mon Sep 17 00:00:00 2001 From: Brian Lewis Date: Mon, 12 Oct 2015 22:16:00 +1100 Subject: [PATCH 19/19] built using copy of gruntfile from #2851 --- plottable.d.ts | 206 +++-------------------- plottable.js | 435 ++++++++++--------------------------------------- 2 files changed, 108 insertions(+), 533 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index eb2550607f..a9e45e77dc 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -1,4 +1,5 @@ - +/// +/// declare module Plottable { module Utils { module Math { @@ -58,8 +59,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { /** @@ -78,8 +77,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { /** @@ -98,8 +95,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { module DOM { @@ -196,8 +191,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { module Color { @@ -226,8 +219,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { module Array { @@ -263,8 +254,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { /** @@ -277,8 +266,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { module Stacking { @@ -315,8 +302,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { module Window { @@ -349,8 +334,6 @@ declare module Plottable { } } } - - declare module Plottable { module Utils { class ClientToSVGTranslator { @@ -374,8 +357,6 @@ declare module Plottable { } } } - - declare module Plottable { module Configs { /** @@ -388,13 +369,9 @@ declare module Plottable { var ADD_TITLE_ELEMENTS: boolean; } } - - declare module Plottable { var version: string; } - - declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; class KeyFunctions { @@ -470,8 +447,6 @@ declare module Plottable { keyFunction(keyFunction: (datum: any, index: number) => any): Dataset; } } - - declare module Plottable { module RenderPolicies { /** @@ -505,8 +480,6 @@ declare module Plottable { } } } - - declare module Plottable { /** * The RenderController is responsible for enqueueing and synchronizing @@ -553,7 +526,6 @@ declare module Plottable { function flush(): void; } } - declare module Plottable { /** * Accesses a specific datum property. @@ -625,8 +597,6 @@ declare module Plottable { component: C; } } - - declare module Plottable { type Formatter = (d: any) => string; /** @@ -737,8 +707,6 @@ declare module Plottable { function relativeDate(baseValue?: number, increment?: number, label?: string): (d: any) => string; } } - - declare module Plottable { /** * A SymbolFactory is a function that takes in a symbolSize which is the edge length of the render area @@ -754,8 +722,6 @@ declare module Plottable { function triangleDown(): SymbolFactory; } } - - declare module Plottable { interface ScaleCallback> { (scale: S): any; @@ -878,8 +844,6 @@ declare module Plottable { removeIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; } } - - declare module Plottable { class QuantitativeScale extends Scale { protected static _DEFAULT_NUM_TICKS: number; @@ -1002,8 +966,6 @@ declare module Plottable { tickGenerator(generator: Scales.TickGenerators.TickGenerator): QuantitativeScale; } } - - declare module Plottable { module Scales { class Linear extends QuantitativeScale { @@ -1025,8 +987,6 @@ declare module Plottable { } } } - - declare module Plottable { module Scales { class ModifiedLog extends QuantitativeScale { @@ -1100,8 +1060,6 @@ declare module Plottable { } } } - - declare module Plottable { module Scales { class Category extends Scale { @@ -1182,8 +1140,6 @@ declare module Plottable { } } } - - declare module Plottable { module Scales { class Color extends Scale { @@ -1219,8 +1175,6 @@ declare module Plottable { } } } - - declare module Plottable { module Scales { class Time extends QuantitativeScale { @@ -1258,8 +1212,6 @@ declare module Plottable { } } } - - declare module Plottable { module Scales { class InterpolatedColor extends Scale { @@ -1294,8 +1246,6 @@ declare module Plottable { } } } - - declare module Plottable { module Scales { module TickGenerators { @@ -1326,8 +1276,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { /** @@ -1416,8 +1364,6 @@ declare module Plottable { selectionForIndex(index: number): d3.Selection; } } - - declare module Plottable { module Drawers { class Line extends Drawer { @@ -1427,8 +1373,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { class Area extends Drawer { @@ -1438,8 +1382,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { class Rectangle extends Drawer { @@ -1447,8 +1389,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { class Arc extends Drawer { @@ -1457,8 +1397,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { class ArcOutline extends Drawer { @@ -1467,8 +1405,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { class Symbol extends Drawer { @@ -1476,8 +1412,6 @@ declare module Plottable { } } } - - declare module Plottable { module Drawers { class Segment extends Drawer { @@ -1485,8 +1419,6 @@ declare module Plottable { } } } - - declare module Plottable { type ComponentCallback = (component: Component) => void; module Components { @@ -1743,8 +1675,6 @@ declare module Plottable { background(): d3.Selection; } } - - declare module Plottable { class ComponentContainer extends Component { private _detachCallback; @@ -1777,8 +1707,6 @@ declare module Plottable { destroy(): void; } } - - declare module Plottable { module Components { class Group extends ComponentContainer { @@ -1819,8 +1747,6 @@ declare module Plottable { } } } - - declare module Plottable { class Axis extends Component { /** @@ -2051,8 +1977,6 @@ declare module Plottable { showEndTickLabels(show: boolean): Axis; } } - - declare module Plottable { module TimeInterval { var second: string; @@ -2164,8 +2088,6 @@ declare module Plottable { } } } - - declare module Plottable { module Axes { class Numeric extends Axis { @@ -2243,8 +2165,6 @@ declare module Plottable { } } } - - declare module Plottable { module Axes { class Category extends Axis { @@ -2296,8 +2216,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class Label extends Component { @@ -2375,8 +2293,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class Legend extends Component { @@ -2506,8 +2422,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class InterpolatedColorLegend extends Component { @@ -2585,8 +2499,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class Gridlines extends Component { @@ -2610,8 +2522,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class Table extends ComponentContainer { @@ -2742,8 +2652,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { enum PropertyMode { @@ -2863,8 +2771,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class GuideLineLayer extends Component { @@ -2937,8 +2843,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { interface PlotEntity extends Entity { @@ -3113,8 +3017,6 @@ declare module Plottable { protected _animateOnNextRender(): boolean; } } - - declare module Plottable { module Plots { class Pie extends Plot { @@ -3241,8 +3143,6 @@ declare module Plottable { } } } - - declare module Plottable { class XYPlot extends Plot { protected static _X_KEY: string; @@ -3354,8 +3254,6 @@ declare module Plottable { protected _getDataToDraw(): Utils.Map; } } - - declare module Plottable { module Plots { class Rectangle extends XYPlot { @@ -3511,8 +3409,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Scatter extends XYPlot { @@ -3590,8 +3486,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Bar extends XYPlot { @@ -3749,8 +3643,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Line extends XYPlot { @@ -3857,8 +3749,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Area extends Line { @@ -3904,8 +3794,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class ClusteredBar extends Bar { @@ -3928,8 +3816,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class StackedArea extends Area { @@ -3985,8 +3871,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class StackedBar extends Bar { @@ -4019,8 +3903,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Segment extends XYPlot { @@ -4122,8 +4004,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Waterfall extends Bar { @@ -4175,8 +4055,6 @@ declare module Plottable { } } } - - declare module Plottable { module Plots { class Wheel extends Plot { @@ -4266,32 +4144,6 @@ declare module Plottable { } } } - - -declare module Plottable { - interface Animator { - /** - * Applies the supplied attributes to a d3.Selection with some animation. - * - * @param {d3.Selection} selection The update selection or transition selection that we wish to animate. - * @param {AttributeToAppliedProjector} attrToAppliedProjector The set of - * AppliedProjectors that we will use to set attributes on the selection. - * @return {any} Animators should return the selection or - * transition object so that plots may chain the transitions between - * animators. - */ - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection | d3.Transition; - /** - * Given the number of elements, return the total time the animation requires - * - * @param {number} numberofIterations The number of elements that will be drawn - * @returns {number} - */ - totalTime(numberOfIterations: number): number; - } -} - - declare module Plottable { module Animators { /** @@ -4304,8 +4156,6 @@ declare module Plottable { } } } - - declare module Plottable { module Animators { /** @@ -4425,8 +4275,6 @@ declare module Plottable { } } } - - declare module Plottable { class Dispatcher { protected _eventToCallback: { @@ -4441,8 +4289,6 @@ declare module Plottable { protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; } } - - declare module Plottable { module Dispatchers { type MouseCallback = (p: Point, event: MouseEvent) => void; @@ -4555,8 +4401,6 @@ declare module Plottable { } } } - - declare module Plottable { module Dispatchers { type TouchCallback = (ids: number[], idToPoint: { @@ -4649,8 +4493,6 @@ declare module Plottable { } } } - - declare module Plottable { module Dispatchers { type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; @@ -4703,8 +4545,6 @@ declare module Plottable { } } } - - declare module Plottable { class Interaction { protected _componentAttachedTo: Component; @@ -4758,8 +4598,6 @@ declare module Plottable { protected _isInsideComponent(p: Point): boolean; } } - - declare module Plottable { type ClickCallback = (point: Point) => void; module Interactions { @@ -4794,8 +4632,6 @@ declare module Plottable { } } } - - declare module Plottable { module Interactions { class DoubleClick extends Interaction { @@ -4835,8 +4671,6 @@ declare module Plottable { } } } - - declare module Plottable { type KeyCallback = (keyCode: number) => void; module Interactions { @@ -4896,8 +4730,6 @@ declare module Plottable { } } } - - declare module Plottable { type PointerCallback = (point: Point) => void; module Interactions { @@ -4960,8 +4792,6 @@ declare module Plottable { } } } - - declare module Plottable { module Interactions { class PanZoom extends Interaction { @@ -5097,8 +4927,6 @@ declare module Plottable { } } } - - declare module Plottable { type DragCallback = (start: Point, end: Point) => void; module Interactions { @@ -5191,8 +5019,6 @@ declare module Plottable { } } } - - declare module Plottable { type DragBoxCallback = (bounds: Bounds) => void; module Components { @@ -5324,8 +5150,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class XDragBoxLayer extends DragBoxLayer { @@ -5354,8 +5178,6 @@ declare module Plottable { } } } - - declare module Plottable { module Components { class YDragBoxLayer extends DragBoxLayer { @@ -5384,8 +5206,6 @@ declare module Plottable { } } } - - declare module Plottable { interface DragLineCallback { (dragLineLayer: Components.DragLineLayer): void; @@ -5474,3 +5294,25 @@ declare module Plottable { } } } +declare module Plottable { + interface Animator { + /** + * Applies the supplied attributes to a d3.Selection with some animation. + * + * @param {d3.Selection} selection The update selection or transition selection that we wish to animate. + * @param {AttributeToAppliedProjector} attrToAppliedProjector The set of + * AppliedProjectors that we will use to set attributes on the selection. + * @return {any} Animators should return the selection or + * transition object so that plots may chain the transitions between + * animators. + */ + animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection | d3.Transition; + /** + * Given the number of elements, return the total time the animation requires + * + * @param {number} numberofIterations The number of elements that will be drawn + * @returns {number} + */ + totalTime(numberOfIterations: number): number; + } +} diff --git a/plottable.js b/plottable.js index afef64fc54..f03bbb1257 100644 --- a/plottable.js +++ b/plottable.js @@ -118,7 +118,6 @@ var Plottable; })(Math = Utils.Math || (Utils.Math = {})); })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -204,7 +203,6 @@ var Plottable; Utils.Map = Map; })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -272,7 +270,6 @@ var Plottable; Utils.Set = Set; })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -476,7 +473,6 @@ var Plottable; })(DOM = Utils.DOM || (Utils.DOM = {})); })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -557,7 +553,6 @@ var Plottable; })(Color = Utils.Color || (Utils.Color = {})); })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -625,7 +620,6 @@ var Plottable; })(Array = Utils.Array || (Utils.Array = {})); })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -662,7 +656,6 @@ var Plottable; Utils.CallbackSet = CallbackSet; })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -745,7 +738,6 @@ var Plottable; })(Stacking = Utils.Stacking || (Utils.Stacking = {})); })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -815,7 +807,6 @@ var Plottable; })(Window = Utils.Window || (Utils.Window = {})); })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -888,7 +879,6 @@ var Plottable; Utils.ClientToSVGTranslator = ClientToSVGTranslator; })(Utils = Plottable.Utils || (Plottable.Utils = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -904,13 +894,11 @@ var Plottable; Configs.ADD_TITLE_ELEMENTS = true; })(Configs = Plottable.Configs || (Plottable.Configs = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { Plottable.version = "1.14.0"; })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -1002,7 +990,6 @@ var Plottable; })(); Plottable.Dataset = Dataset; })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -1051,7 +1038,6 @@ var Plottable; RenderPolicies.Timeout = Timeout; })(RenderPolicies = Plottable.RenderPolicies || (Plottable.RenderPolicies = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -1167,8 +1153,6 @@ var Plottable; RenderController.flush = flush; })(RenderController = Plottable.RenderController || (Plottable.RenderController = {})); })(Plottable || (Plottable = {})); - - /// var Plottable; (function (Plottable) { @@ -1443,7 +1427,6 @@ var Plottable; } })(Formatters = Plottable.Formatters || (Plottable.Formatters = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -1475,7 +1458,6 @@ var Plottable; SymbolFactories.triangleDown = triangleDown; })(SymbolFactories = Plottable.SymbolFactories || (Plottable.SymbolFactories = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -1624,13 +1606,7 @@ var Plottable; })(); Plottable.Scale = Scale; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var QuantitativeScale = (function (_super) { @@ -1861,13 +1837,7 @@ var Plottable; })(Plottable.Scale); Plottable.QuantitativeScale = QuantitativeScale; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Scales; @@ -1919,13 +1889,7 @@ var Plottable; Scales.Linear = Linear; })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Scales; @@ -2110,13 +2074,7 @@ var Plottable; Scales.ModifiedLog = ModifiedLog; })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Scales; @@ -2224,13 +2182,7 @@ var Plottable; Scales.Category = Category; })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Scales; @@ -2342,13 +2294,7 @@ var Plottable; Scales.Color = Color; })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Scales; @@ -2454,13 +2400,7 @@ var Plottable; Scales.Time = Time; })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Scales; @@ -2607,7 +2547,6 @@ var Plottable; Scales.InterpolatedColor = InterpolatedColor; })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -2655,7 +2594,6 @@ var Plottable; })(TickGenerators = Scales.TickGenerators || (Scales.TickGenerators = {})); })(Scales = Plottable.Scales || (Plottable.Scales = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -2797,13 +2735,7 @@ var Plottable; })(); Plottable.Drawer = Drawer; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2827,13 +2759,7 @@ var Plottable; Drawers.Line = Line; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2857,13 +2783,7 @@ var Plottable; Drawers.Area = Area; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2879,13 +2799,7 @@ var Plottable; Drawers.Rectangle = Rectangle; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2906,13 +2820,7 @@ var Plottable; Drawers.Arc = Arc; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2933,13 +2841,7 @@ var Plottable; Drawers.ArcOutline = ArcOutline; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2956,13 +2858,7 @@ var Plottable; Drawers.Symbol = Symbol; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Drawers; @@ -2978,7 +2874,6 @@ var Plottable; Drawers.Segment = Segment; })(Drawers = Plottable.Drawers || (Plottable.Drawers = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -3496,13 +3391,7 @@ var Plottable; })(); Plottable.Component = Component; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { /* @@ -3577,13 +3466,7 @@ var Plottable; })(Plottable.Component); Plottable.ComponentContainer = ComponentContainer; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -3675,13 +3558,7 @@ var Plottable; Components.Group = Group; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Axis = (function (_super) { @@ -4234,13 +4111,7 @@ var Plottable; })(Plottable.Component); Plottable.Axis = Axis; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var TimeInterval; @@ -4714,13 +4585,7 @@ var Plottable; Axes.Time = Time; })(Axes = Plottable.Axes || (Plottable.Axes = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Axes; @@ -5051,13 +4916,7 @@ var Plottable; Axes.Numeric = Numeric; })(Axes = Plottable.Axes || (Plottable.Axes = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Axes; @@ -5262,13 +5121,7 @@ var Plottable; Axes.Category = Category; })(Axes = Plottable.Axes || (Plottable.Axes = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -5418,13 +5271,7 @@ var Plottable; Components.AxisLabel = AxisLabel; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -5701,13 +5548,7 @@ var Plottable; Components.Legend = Legend; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -5943,13 +5784,7 @@ var Plottable; Components.InterpolatedColorLegend = InterpolatedColorLegend; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -6047,13 +5882,7 @@ var Plottable; Components.Gridlines = Gridlines; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -6411,13 +6240,7 @@ var Plottable; Components.Table = Table; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -6631,13 +6454,7 @@ var Plottable; Components.SelectionBoxLayer = SelectionBoxLayer; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -6782,13 +6599,7 @@ var Plottable; Components.GuideLineLayer = GuideLineLayer; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -7247,13 +7058,7 @@ var Plottable; })(Plottable.Component); Plottable.Plot = Plot; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -7575,13 +7380,7 @@ var Plottable; Plots.Pie = Pie; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var XYPlot = (function (_super) { @@ -7880,13 +7679,7 @@ var Plottable; })(Plottable.Plot); Plottable.XYPlot = XYPlot; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -8234,13 +8027,7 @@ var Plottable; Plots.Rectangle = Rectangle; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -8388,13 +8175,7 @@ var Plottable; Plots.Scatter = Scatter; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -9007,13 +8788,7 @@ var Plottable; Plots.Bar = Bar; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -9411,13 +9186,7 @@ var Plottable; Plots.Line = Line; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -9586,13 +9355,7 @@ var Plottable; Plots.Area = Area; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -9651,13 +9414,7 @@ var Plottable; Plots.ClusteredBar = ClusteredBar; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -9824,13 +9581,7 @@ var Plottable; Plots.StackedArea = StackedArea; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -9946,13 +9697,7 @@ var Plottable; Plots.StackedBar = StackedBar; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -10122,13 +9867,7 @@ var Plottable; Plots.Segment = Segment; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -10326,13 +10065,7 @@ var Plottable; Plots.Waterfall = Waterfall; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Plots; @@ -10486,9 +10219,6 @@ var Plottable; Plots.Wheel = Wheel; })(Plots = Plottable.Plots || (Plottable.Plots = {})); })(Plottable || (Plottable = {})); - -/// - /// var Plottable; (function (Plottable) { @@ -10512,7 +10242,6 @@ var Plottable; Animators.Null = Null; })(Animators = Plottable.Animators || (Plottable.Animators = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -10627,7 +10356,6 @@ var Plottable; Animators.Easing = Easing; })(Animators = Plottable.Animators || (Plottable.Animators = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -10673,13 +10401,7 @@ var Plottable; })(); Plottable.Dispatcher = Dispatcher; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Dispatchers; @@ -10863,13 +10585,7 @@ var Plottable; Dispatchers.Mouse = Mouse; })(Dispatchers = Plottable.Dispatchers || (Plottable.Dispatchers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Dispatchers; @@ -11030,13 +10746,7 @@ var Plottable; Dispatchers.Touch = Touch; })(Dispatchers = Plottable.Dispatchers || (Plottable.Dispatchers = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Dispatchers; @@ -11122,7 +10832,6 @@ var Plottable; Dispatchers.Key = Key; })(Dispatchers = Plottable.Dispatchers || (Plottable.Dispatchers = {})); })(Plottable || (Plottable = {})); - /// var Plottable; (function (Plottable) { @@ -11217,13 +10926,7 @@ var Plottable; })(); Plottable.Interaction = Interaction; })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Interactions; @@ -11299,13 +11002,7 @@ var Plottable; Interactions.Click = Click; })(Interactions = Plottable.Interactions || (Plottable.Interactions = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Interactions; @@ -11412,13 +11109,7 @@ var Plottable; Interactions.DoubleClick = DoubleClick; })(Interactions = Plottable.Interactions || (Plottable.Interactions = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Interactions; @@ -11531,13 +11222,7 @@ var Plottable; Interactions.Key = Key; })(Interactions = Plottable.Interactions || (Plottable.Interactions = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Interactions; @@ -11655,13 +11340,7 @@ var Plottable; Interactions.Pointer = Pointer; })(Interactions = Plottable.Interactions || (Plottable.Interactions = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Interactions; @@ -11979,13 +11658,7 @@ var Plottable; Interactions.PanZoom = PanZoom; })(Interactions = Plottable.Interactions || (Plottable.Interactions = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Interactions; @@ -12137,13 +11810,7 @@ var Plottable; Interactions.Drag = Drag; })(Interactions = Plottable.Interactions || (Plottable.Interactions = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -12510,13 +12177,7 @@ var Plottable; Components.DragBoxLayer = DragBoxLayer; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -12571,13 +12232,7 @@ var Plottable; Components.XDragBoxLayer = XDragBoxLayer; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { var Components; @@ -12632,13 +12287,7 @@ var Plottable; Components.YDragBoxLayer = YDragBoxLayer; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); - /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; var Plottable; (function (Plottable) { ; @@ -12815,6 +12464,90 @@ var Plottable; Components.DragLineLayer = DragLineLayer; })(Components = Plottable.Components || (Plottable.Components = {})); })(Plottable || (Plottable = {})); +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// /*! SVG Typewriter 0.3.0 (https://github.com/palantir/svg-typewriter)