diff --git a/.gitignore b/.gitignore index 591ac78cba..31cf2e6367 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ test/tests_multifile.js local/ .tscache/ quicktests/github_token.txt +quicktests/overlaying/list_of_quicktests.json .idea/ # Emacs .#* diff --git a/Gruntfile.js b/Gruntfile.js index 278e1bdc4c..fb20c83f74 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -223,6 +223,10 @@ module.exports = function(grunt) { "tests": { "tasks": ["test-compile"], "files": ["test/**/*.ts"] + }, + "quicktests": { + "tasks": ["update-qt"], + "files": ["quicktests/overlaying/tests/**/*.js"] } }, blanket_mocha: { @@ -333,7 +337,8 @@ module.exports = function(grunt) { "test-compile", "concat:plottable_multifile", "sed:plottable_multifile", - "clean:tscommand" + "clean:tscommand", + "update-qt" ]; grunt.registerTask("dev-compile", compile_task); @@ -369,4 +374,17 @@ module.exports = function(grunt) { "sed:sublime", ]); + var updateQuickTestsJSON = function() { + var qtJSON = []; + var rawtests = grunt.file.expand("quicktests/overlaying/tests/**/*.js"); + rawtests.forEach(function(value, index, array){ + qtJSON.push({path: value}); + }); + qtJSON = JSON.stringify(qtJSON); + qtJSON = qtJSON.split(",").join(",\n") + "\n"; + grunt.file.write("quicktests/overlaying/list_of_quicktests.json", qtJSON); + }; + + grunt.registerTask("update-qt", updateQuickTestsJSON); + }; diff --git a/bower.json b/bower.json index 4509d32503..4f36edfb89 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "plottable", "description": "A library for creating charts out of D3", - "version": "0.36.1", + "version": "0.37.0", "main": ["plottable.js", "plottable.css"], "license": "MIT", "ignore": [ diff --git a/package.json b/package.json index d02eb3ad8c..5a0d8f14c3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plottable.js", "description": "A library for creating charts out of D3", - "version": "0.36.1", + "version": "0.37.0", "repository": { "type": "git", "url": "https://github.com/palantir/plottable.git" diff --git a/plottable.d.ts b/plottable.d.ts index 06a83dfbaf..2ea1c93fb6 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -39,12 +39,6 @@ declare module Plottable { * and "activate" it by turning it into a function in (datum, index, metadata) */ function accessorize(accessor: any): _Accessor; - /** - * Take an accessor object, activate it, and partially apply it to a Plot's datasource's metadata. - * Temporarily always grabs the metadata of the first dataset. - * HACKHACK #1089 - The accessor currently only grabs the first dataset's metadata - */ - function _applyAccessor(accessor: _Accessor, plot: Plot.AbstractPlot): (d: any, i: number) => any; /** * Takes two sets and returns the union * @@ -506,11 +500,21 @@ declare module Plottable { */ function siSuffix(precision?: number): (d: any) => string; /** - * Creates a formatter that displays dates. + * 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(): (d: any) => string; + function time(specifier: string): Formatter; /** * Creates a formatter for relative dates. * @@ -694,7 +698,7 @@ declare module Plottable { * @returns {Dataset} The calling Dataset. */ metadata(metadata: any): Dataset; - _getExtent(accessor: _Accessor, typeCoercer: (d: any) => any): any[]; + _getExtent(accessor: _Accessor, typeCoercer: (d: any) => any, plotMetadata?: any): any[]; } } @@ -838,20 +842,28 @@ declare module Plottable { } declare module Plottable { + /** + * Access specific datum property. + */ interface _Accessor { - (datum: any, index?: number, metadata?: any): any; + (datum: any, index?: number, userMetadata?: any, plotMetadata?: Plot.PlotMetadata): any; } /** - * A function to map across the data in a DataSource. For example, if your - * data looked like `{foo: 5, bar: 6}`, then a popular function might be - * `function(d) { return d.foo; }`. - * - * Index, if used, will be the index of the datum in the array. + * Retrieves scaled datum property. */ - interface AppliedAccessor { - (datum?: any, index?: number): any; - } interface _Projector { + (datum: any, index: number, userMetadata: any, plotMetadata: Plot.PlotMetadata): any; + } + /** + * Projector with applied user and plot metadata + */ + interface _AppliedProjector { + (datum: any, index: number): any; + } + /** + * Defines a way how specific attribute needs be retrieved before rendering. + */ + interface _Projection { accessor: _Accessor; scale?: Scale.AbstractScale; attribute: string; @@ -865,7 +877,10 @@ declare module Plottable { * function(d) { return foo + bar; }`. */ interface AttributeToProjector { - [attrToSet: string]: AppliedAccessor; + [attrToSet: string]: _Projector; + } + interface _AttributeToAppliedProjector { + [attrToSet: string]: _AppliedProjector; } /** * A simple bounding box. @@ -906,14 +921,6 @@ declare module Plottable { x: number; y: number; } - /** - * A key that is also coupled with a dataset and a drawer. - */ - interface DatasetDrawerKey { - dataset: Dataset; - drawer: _Drawer.AbstractDrawer; - key: string; - } } @@ -1579,6 +1586,10 @@ declare module Plottable { attrToProjector: AttributeToProjector; animator: Animator.PlotAnimator; } + interface AppliedDrawStep { + attrToProjector: _AttributeToAppliedProjector; + animator: Animator.PlotAnimator; + } class AbstractDrawer { _renderArea: D3.Selection; _className: string; @@ -1610,17 +1621,21 @@ declare module Plottable { /** * Draws data using one step * - * @param{DataStep} step The step, how data should be drawn. + * @param{AppliedDrawStep} step The step, how data should be drawn. */ - _drawStep(step: DrawStep): void; + _drawStep(step: AppliedDrawStep): void; _numberOfAnimationIterations(data: any[]): number; + _prepareDrawSteps(drawSteps: AppliedDrawStep[]): void; + _prepareData(data: any[], drawSteps: AppliedDrawStep[]): any[]; /** - * Draws the data into the renderArea using the spefic steps + * 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 + * @param{any} userMetadata The metadata provided by user + * @param{any} plotMetadata The metadata provided by plot */ - draw(data: any[], drawSteps: DrawStep[]): number; + draw(data: any[], drawSteps: DrawStep[], userMetadata: any, plotMetadata: Plot.PlotMetadata): number; } } } @@ -1632,7 +1647,7 @@ declare module Plottable { _enterData(data: any[]): void; setup(area: D3.Selection): void; _numberOfAnimationIterations(data: any[]): number; - _drawStep(step: DrawStep): void; + _drawStep(step: AppliedDrawStep): void; } } } @@ -1649,7 +1664,7 @@ declare module Plottable { */ drawLine(draw: boolean): Area; setup(area: D3.Selection): void; - _drawStep(step: DrawStep): void; + _drawStep(step: AppliedDrawStep): void; } } } @@ -1666,9 +1681,10 @@ declare module Plottable { */ svgElement(tag: string): Element; _getDrawSelection(): D3.Selection; - _drawStep(step: DrawStep): void; + _drawStep(step: AppliedDrawStep): void; _enterData(data: any[]): void; - draw(data: any[], drawSteps: DrawStep[]): number; + _prepareDrawSteps(drawSteps: AppliedDrawStep[]): void; + _prepareData(data: any[], drawSteps: AppliedDrawStep[]): any[]; } } } @@ -1682,7 +1698,7 @@ declare module Plottable { constructor(key: string, isVertical: boolean); setup(area: D3.Selection): void; removeLabels(): void; - drawText(data: any[], attrToProjector: AttributeToProjector): void; + drawText(data: any[], attrToProjector: AttributeToProjector, userMetadata: any, plotMetadata: Plot.PlotMetadata): void; } } } @@ -1692,8 +1708,8 @@ declare module Plottable { module _Drawer { class Arc extends Element { constructor(key: string); - _drawStep(step: DrawStep): void; - draw(data: any[], drawSteps: DrawStep[]): number; + _drawStep(step: AppliedDrawStep): void; + draw(data: any[], drawSteps: DrawStep[], userMetadata: any, plotMetadata: Plot.PlotMetadata): number; } } } @@ -2121,17 +2137,28 @@ declare module Plottable { declare module Plottable { module Axis { - interface _TimeInterval { - timeUnit: D3.Time.Interval; + /** + * 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. + */ + interface TimeAxisTierConfiguration { + interval: D3.Time.Interval; step: number; - formatString: string; + formatter: Formatter; + } + /** + * An array of linked TimeAxisTierConfigurations. + * Each configuration will be shown on a different tier. + * Currently, up to two tiers are supported. + */ + interface TimeAxisConfiguration { + tierConfigurations: TimeAxisTierConfiguration[]; } class Time extends AbstractAxis { - _majorTickLabels: D3.Selection; - _minorTickLabels: D3.Selection; _scale: Scale.Time; - static _minorIntervals: _TimeInterval[]; - static _majorIntervals: _TimeInterval[]; /** * Constructs a TimeAxis. * @@ -2142,13 +2169,27 @@ declare module Plottable { * @param {string} orientation The orientation of the Axis (top/bottom) */ constructor(scale: Scale.Time, orientation: string); + /** + * Gets the possible Axis configurations. + * + * @returns {TimeAxisConfiguration[]} The possible tier configurations. + */ + axisConfigurations(): TimeAxisConfiguration[]; + /** + * Sets possible Axis configurations. + * The axis will choose the most precise configuration that will display in + * its current width. + * + * @param {TimeAxisConfiguration[]} configurations Possible axis configurations. + * @returns {Axis.Time} The calling Axis.Time. + */ + axisConfigurations(configurations: TimeAxisConfiguration[]): Time; orient(): string; orient(orientation: string): Time; _computeHeight(): number; _setup(): void; - _getTickIntervalValues(interval: _TimeInterval): any[]; _getTickValues(): any[]; - _measureTextHeight(container: D3.Selection): number; + _measureTextHeight(): number; _doRender(): Time; } } @@ -2601,13 +2642,25 @@ declare module Plottable { declare module Plottable { module Plot { + /** + * A key that is also coupled with a dataset, a drawer and a metadata in Plot. + */ + interface PlotDatasetKey { + dataset: Dataset; + drawer: _Drawer.AbstractDrawer; + plotMetadata: PlotMetadata; + key: string; + } + interface PlotMetadata { + datasetKey: string; + } class AbstractPlot extends Component.AbstractComponent { _dataChanged: boolean; - _key2DatasetDrawerKey: D3.Map; + _key2PlotDatasetKey: D3.Map; _datasetKeysInOrder: string[]; _renderArea: D3.Selection; - _projectors: { - [x: string]: _Projector; + _projections: { + [x: string]: _Projection; }; _animate: boolean; _animators: Animator.PlotAnimatorMap; @@ -2683,7 +2736,7 @@ declare module Plottable { animate(enabled: boolean): AbstractPlot; detach(): AbstractPlot; /** - * This function makes sure that all of the scales in this._projectors + * This function makes sure that all of the scales in this._projections * have an extent that includes all the data that is projected onto them. */ _updateScaleExtents(): void; @@ -2745,6 +2798,12 @@ declare module Plottable { _generateDrawSteps(): _Drawer.DrawStep[]; _additionalPaint(time: number): void; _getDataToDraw(): D3.Map; + /** + * Gets the new plot metadata for new dataset with provided key + * + * @param {string} key The key of new dataset + */ + _getPlotMetadataForDataset(key: string): PlotMetadata; } } } @@ -2963,20 +3022,25 @@ declare module Plottable { */ barLabelFormatter(formatter: Formatter): AbstractBarPlot; /** - * Selects the bar under the given pixel position (if [xValOrExtent] + * Gets all the bars in the bar plot + * + * @returns {D3.Selection} All of the bars in the bar plot. + */ + getAllBars(): D3.Selection; + /** + * Gets the bar under the given pixel position (if [xValOrExtent] * and [yValOrExtent] are {number}s), under a given line (if only one * of [xValOrExtent] or [yValOrExtent] are {Extent}s) or are under a * 2D area (if [xValOrExtent] and [yValOrExtent] are both {Extent}s). * * @param {any} xValOrExtent The pixel x position, or range of x values. * @param {any} yValOrExtent The pixel y position, or range of y values. - * @param {boolean} [select] Whether or not to select the bar (by classing it "selected"); * @returns {D3.Selection} The selected bar, or null if no bar was selected. */ - selectBar(xValOrExtent: Extent, yValOrExtent: Extent, select?: boolean): D3.Selection; - selectBar(xValOrExtent: number, yValOrExtent: Extent, select?: boolean): D3.Selection; - selectBar(xValOrExtent: Extent, yValOrExtent: number, select?: boolean): D3.Selection; - selectBar(xValOrExtent: number, yValOrExtent: number, select?: boolean): D3.Selection; + getBars(xValOrExtent: Extent, yValOrExtent: Extent): D3.Selection; + getBars(xValOrExtent: number, yValOrExtent: Extent): D3.Selection; + getBars(xValOrExtent: Extent, yValOrExtent: number): D3.Selection; + getBars(xValOrExtent: number, yValOrExtent: number): D3.Selection; /** * Deselects all bars. * @returns {AbstractBarPlot} The calling AbstractBarPlot. @@ -3090,9 +3154,9 @@ declare module Plottable { */ constructor(xScale: Scale.AbstractQuantitative, yScale: Scale.AbstractQuantitative); _setup(): void; - _rejectNullsAndNaNs(d: any, i: number, projector: AppliedAccessor): boolean; + _rejectNullsAndNaNs(d: any, i: number, userMetdata: any, plotMetadata: any, accessor: _Accessor): boolean; _getDrawer(key: string): _Drawer.Line; - _getResetYFunction(): (d: any, i: number) => number; + _getResetYFunction(): (d: any, i: number, u: any, m: PlotMetadata) => number; _generateDrawSteps(): _Drawer.DrawStep[]; _generateAttrToProjector(): AttributeToProjector; _wholeDatumAttributes(): string[]; @@ -3126,7 +3190,7 @@ declare module Plottable { _getDrawer(key: string): _Drawer.Area; _updateYDomainer(): void; project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): Area; - _getResetYFunction(): AppliedAccessor; + _getResetYFunction(): _Projector; _wholeDatumAttributes(): string[]; } } @@ -3181,8 +3245,8 @@ declare module Plottable { _getDomainKeys(): string[]; _generateDefaultMapArray(): D3.Map[]; _updateScaleExtents(): void; - _keyAccessor(): AppliedAccessor; - _valueAccessor(): AppliedAccessor; + _keyAccessor(): _Accessor; + _valueAccessor(): _Accessor; } } } @@ -3242,8 +3306,8 @@ declare module Plottable { _getDomainKeys(): any; _generateDefaultMapArray(): D3.Map[]; _updateScaleExtents(): void; - _keyAccessor(): AppliedAccessor; - _valueAccessor(): AppliedAccessor; + _keyAccessor(): _Accessor; + _valueAccessor(): _Accessor; _getBarPixelWidth(): any; } } @@ -3416,7 +3480,7 @@ declare module Plottable { isReverse: boolean; constructor(isVertical?: boolean, isReverse?: boolean); animate(selection: any, attrToProjector: AttributeToProjector): any; - _startMovingProjector(attrToProjector: AttributeToProjector): AppliedAccessor; + _startMovingProjector(attrToProjector: AttributeToProjector): _Projector; } } } @@ -3670,54 +3734,12 @@ declare module Plottable { } -declare module Plottable { - module Interaction { - class BarHover extends AbstractInteraction { - _componentToListenTo: Plot.AbstractBarPlot; - _anchor(barPlot: Plot.AbstractBarPlot, hitBox: D3.Selection): void; - /** - * Gets the current hover mode. - * - * @return {string} The current hover mode. - */ - hoverMode(): string; - /** - * Sets the hover mode for the interaction. There are two modes: - * - "point": Selects the bar under the mouse cursor (default). - * - "line" : Selects any bar that would be hit by a line extending - * in the same direction as the bar and passing through - * the cursor. - * - * @param {string} mode If provided, the desired hover mode. - * @return {BarHover} The calling BarHover. - */ - hoverMode(mode: string): BarHover; - /** - * Attaches an callback to be called when the user mouses over a bar. - * - * @param {(datum: any, bar: D3.Selection) => any} callback The callback to be called. - * The callback will be passed the data from the hovered-over bar. - * @return {BarHover} The calling BarHover. - */ - onHover(callback: (datum: any, bar: D3.Selection) => any): BarHover; - /** - * Attaches a callback to be called when the user mouses off of a bar. - * - * @param {(datum: any, bar: D3.Selection) => any} callback The callback to be called. - * The callback will be passed the data from the last-hovered bar. - * @return {BarHover} The calling BarHover. - */ - onUnhover(callback: (datum: any, bar: D3.Selection) => any): BarHover; - } - } -} - - declare module Plottable { module Interaction { class Drag extends AbstractInteraction { - _origin: number[]; - _location: number[]; + _isDragging: boolean; + _constrainX: (n: number) => number; + _constrainY: (n: number) => number; /** * Constructs a Drag. A Drag will signal its callbacks on mouse drag. */ @@ -3725,42 +3747,46 @@ declare module Plottable { /** * Gets the callback that is called when dragging starts. * - * @returns {(startLocation: Point) => void} The callback called when dragging starts. + * @returns {(start: Point) => void} The callback called when dragging starts. */ - dragstart(): (startLocation: Point) => void; + dragstart(): (start: Point) => void; /** * Sets the callback to be called when dragging starts. * - * @param {(startLocation: Point) => any} cb If provided, the function to be called. Takes in a Point in pixels. + * @param {(start: Point) => any} cb If provided, the function to be called. Takes in a Point in pixels. * @returns {Drag} The calling Drag. */ - dragstart(cb: (startLocation: Point) => any): Drag; + dragstart(cb: (start: Point) => any): Drag; + _setOrigin(x: number, y: number): void; + _getOrigin(): number[]; + _setLocation(x: number, y: number): void; + _getLocation(): number[]; /** * Gets the callback that is called during dragging. * - * @returns {(startLocation: Point, endLocation: Point) => void} The callback called during dragging. + * @returns {(start: Point, end: Point) => void} The callback called during dragging. */ - drag(): (startLocation: Point, endLocation: Point) => void; + drag(): (start: Point, end: Point) => void; /** * Adds a callback to be called during dragging. * - * @param {(startLocation: Point, endLocation: Point) => any} cb If provided, the function to be called. Takes in Points in pixels. + * @param {(start: Point, end: Point) => any} cb If provided, the function to be called. Takes in Points in pixels. * @returns {Drag} The calling Drag. */ - drag(cb: (startLocation: Point, endLocation: Point) => any): Drag; + drag(cb: (start: Point, end: Point) => any): Drag; /** * Gets the callback that is called when dragging ends. * - * @returns {(startLocation: Point, endLocation: Point) => void} The callback called when dragging ends. + * @returns {(start: Point, end: Point) => void} The callback called when dragging ends. */ - dragend(): (startLocation: Point, endLocation: Point) => void; + dragend(): (start: Point, end: Point) => void; /** * Adds a callback to be called when the dragging ends. * - * @param {(startLocation: Point, endLocation: Point) => any} cb If provided, the function to be called. Takes in Points in pixels. + * @param {(start: Point, end: Point) => any} cb If provided, the function to be called. Takes in points in pixels. * @returns {Drag} The calling Drag. */ - dragend(cb: (startLocation: Point, endLocation: Point) => any): Drag; + dragend(cb: (start: Point, end: Point) => any): Drag; _dragstart(): void; _doDragstart(): void; _drag(): void; @@ -3784,21 +3810,57 @@ declare module Plottable { declare module Plottable { module Interaction { - /** - * A DragBox is an interaction that automatically draws a box across the - * element you attach it to when you drag. - */ class DragBox extends Drag { + static RESIZE_PADDING: number; + static _CAN_RESIZE_X: boolean; + static _CAN_RESIZE_Y: boolean; /** * The DOM element of the box that is drawn. When no box is drawn, it is * null. */ dragBox: D3.Selection; + _boxIsDrawn: boolean; + _resizeXEnabled: boolean; + _resizeYEnabled: boolean; + /** + * Gets whether resizing is enabled or not. + * + * @returns {boolean} + */ + resizeEnabled(): boolean; + /** + * Enables or disables resizing. + * + * @param {boolean} enabled + */ + resizeEnabled(enabled: boolean): DragBox; + /** + * Return true if box is resizing on the X dimension. + * + * @returns {boolean} + */ + isResizingX(): boolean; + /** + * Return true if box is resizing on the Y dimension. + * + * @returns {boolean} + */ + isResizingY(): boolean; /** * Whether or not dragBox has been rendered in a visible area. + * + * @returns {boolean} + */ + boxIsDrawn(): boolean; + /** + * Return true if box is resizing. + * + * @returns {boolean} */ - boxIsDrawn: boolean; + isResizing(): boolean; _dragstart(): void; + _drag(): void; + _dragend(): void; /** * Clears the highlighted drag-selection box drawn by the DragBox. * @@ -3817,6 +3879,7 @@ declare module Plottable { */ setBox(x0: number, x1: number, y0: number, y1: number): DragBox; _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): DragBox; + _hover(): void; } } } @@ -3825,8 +3888,9 @@ declare module Plottable { declare module Plottable { module Interaction { class XDragBox extends DragBox { - _drag(): void; - setBox(x0: number, x1: number): XDragBox; + static _CAN_RESIZE_Y: boolean; + _setOrigin(x: number, y: number): void; + _setLocation(x: number, y: number): void; } } } @@ -3835,7 +3899,7 @@ declare module Plottable { declare module Plottable { module Interaction { class XYDragBox extends DragBox { - _drag(): void; + constructor(); } } } @@ -3844,8 +3908,9 @@ declare module Plottable { declare module Plottable { module Interaction { class YDragBox extends DragBox { - _drag(): void; - setBox(y0: number, y1: number): YDragBox; + static _CAN_RESIZE_X: boolean; + _setOrigin(x: number, y: number): void; + _setLocation(x: number, y: number): void; } } } diff --git a/plottable.js b/plottable.js index 2b7b39f495..11cf658c6b 100644 --- a/plottable.js +++ b/plottable.js @@ -1,5 +1,5 @@ /*! -Plottable 0.36.1 (https://github.com/palantir/plottable) +Plottable 0.37.0 (https://github.com/palantir/plottable) Copyright 2014 Palantir Technologies Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE) */ @@ -91,21 +91,6 @@ var Plottable; ; } Methods.accessorize = accessorize; - /** - * Take an accessor object, activate it, and partially apply it to a Plot's datasource's metadata. - * Temporarily always grabs the metadata of the first dataset. - * HACKHACK #1089 - The accessor currently only grabs the first dataset's metadata - */ - function _applyAccessor(accessor, plot) { - var activatedAccessor = accessorize(accessor); - return function (d, i) { - var datasets = plot.datasets(); - var dataset = datasets.length > 0 ? datasets[0] : null; - var metadata = dataset ? dataset.metadata() : null; - return activatedAccessor(d, i, metadata); - }; - } - Methods._applyAccessor = _applyAccessor; /** * Takes two sets and returns the union * @@ -1312,11 +1297,11 @@ var Plottable; } Formatters.siSuffix = siSuffix; /** - * Creates a formatter that displays dates. + * Creates a multi time formatter that displays dates. * * @returns {Formatter} A formatter for time/date values. */ - function time() { + function multiTime() { var numFormats = 8; // these defaults were taken from d3 // https://github.com/mbostock/d3/wiki/Time-Formatting#format_multi @@ -1361,6 +1346,19 @@ var Plottable; } }; } + Formatters.multiTime = multiTime; + /** + * 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) { + return d3.time.format(specifier); + } Formatters.time = time; /** * Creates a formatter for relative dates. @@ -1405,7 +1403,7 @@ var Plottable; /// var Plottable; (function (Plottable) { - Plottable.version = "0.36.1"; + Plottable.version = "0.37.0"; })(Plottable || (Plottable = {})); /// @@ -1603,16 +1601,19 @@ var Plottable; return this; } }; - Dataset.prototype._getExtent = function (accessor, typeCoercer) { + Dataset.prototype._getExtent = function (accessor, typeCoercer, plotMetadata) { + if (plotMetadata === void 0) { plotMetadata = {}; } var cachedExtent = this.accessor2cachedExtent.get(accessor); if (cachedExtent === undefined) { - cachedExtent = this.computeExtent(accessor, typeCoercer); + cachedExtent = this.computeExtent(accessor, typeCoercer, plotMetadata); this.accessor2cachedExtent.set(accessor, cachedExtent); } return cachedExtent; }; - Dataset.prototype.computeExtent = function (accessor, typeCoercer) { - var mappedData = this._data.map(accessor).map(typeCoercer); + Dataset.prototype.computeExtent = function (accessor, typeCoercer, plotMetadata) { + var _this = this; + var appliedAccessor = function (d, i) { return accessor(d, i, _this._metadata, plotMetadata); }; + var mappedData = this._data.map(appliedAccessor).map(typeCoercer); if (mappedData.length === 0) { return []; } @@ -3203,7 +3204,7 @@ var Plottable; /** * Draws data using one step * - * @param{DataStep} step The step, how data should be drawn. + * @param{AppliedDrawStep} step The step, how data should be drawn. */ AbstractDrawer.prototype._drawStep = function (step) { // no-op @@ -3211,18 +3212,41 @@ var Plottable; AbstractDrawer.prototype._numberOfAnimationIterations = function (data) { return data.length; }; + AbstractDrawer.prototype.applyMetadata = function (attrToProjector, userMetadata, plotMetadata) { + var modifiedAttrToProjector = {}; + d3.keys(attrToProjector).forEach(function (attr) { + modifiedAttrToProjector[attr] = function (datum, index) { return attrToProjector[attr](datum, index, userMetadata, plotMetadata); }; + }); + return modifiedAttrToProjector; + }; + AbstractDrawer.prototype._prepareDrawSteps = function (drawSteps) { + // no-op + }; + AbstractDrawer.prototype._prepareData = function (data, drawSteps) { + return data; + }; /** - * Draws the data into the renderArea using the spefic steps + * 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 + * @param{any} userMetadata The metadata provided by user + * @param{any} plotMetadata The metadata provided by plot */ - AbstractDrawer.prototype.draw = function (data, drawSteps) { + AbstractDrawer.prototype.draw = function (data, drawSteps, userMetadata, plotMetadata) { var _this = this; - this._enterData(data); - var numberOfIterations = this._numberOfAnimationIterations(data); + var appliedDrawSteps = drawSteps.map(function (dr) { + return { + attrToProjector: _this.applyMetadata(dr.attrToProjector, userMetadata, plotMetadata), + animator: dr.animator + }; + }); + var preparedData = this._prepareData(data, appliedDrawSteps); + this._prepareDrawSteps(appliedDrawSteps); + this._enterData(preparedData); + var numberOfIterations = this._numberOfAnimationIterations(preparedData); var delay = 0; - drawSteps.forEach(function (drawStep, i) { + appliedDrawSteps.forEach(function (drawStep, i) { Plottable._Util.Methods.setTimeout(function () { return _this._drawStep(drawStep); }, delay); delay += drawStep.animator.getTiming(numberOfIterations); }); @@ -3263,7 +3287,7 @@ var Plottable; }; Line.prototype.createLine = function (xFunction, yFunction, definedFunction) { if (!definedFunction) { - definedFunction = function () { return true; }; + definedFunction = function (d, i) { return true; }; } return d3.svg.line().x(xFunction).y(yFunction).defined(definedFunction); }; @@ -3278,10 +3302,10 @@ var Plottable; var definedFunction = attrToProjector["defined"]; delete attrToProjector["x"]; delete attrToProjector["y"]; - attrToProjector["d"] = this.createLine(xFunction, yFunction, attrToProjector["defined"]); if (attrToProjector["defined"]) { delete attrToProjector["defined"]; } + attrToProjector["d"] = this.createLine(xFunction, yFunction, definedFunction); if (attrToProjector["fill"]) { this.pathSelection.attr("fill", attrToProjector["fill"]); // so colors don't animate } @@ -3358,10 +3382,10 @@ var Plottable; delete attrToProjector["x"]; delete attrToProjector["y0"]; delete attrToProjector["y"]; - attrToProjector["d"] = this.createArea(xFunction, y0Function, y1Function, attrToProjector["defined"]); if (attrToProjector["defined"]) { delete attrToProjector["defined"]; } + attrToProjector["d"] = this.createArea(xFunction, y0Function, y1Function, definedFunction); if (attrToProjector["fill"]) { this.areaSelection.attr("fill", attrToProjector["fill"]); // so colors don't animate } @@ -3421,19 +3445,18 @@ var Plottable; Element.prototype.filterDefinedData = function (data, definedFunction) { return definedFunction ? data.filter(definedFunction) : data; }; - Element.prototype.draw = function (data, drawSteps) { - var _this = this; - var modifiedDrawSteps = []; - drawSteps.forEach(function (d, i) { - modifiedDrawSteps[i] = { animator: d.animator, attrToProjector: Plottable._Util.Methods.copyMap(d.attrToProjector) }; - }); - var definedData = modifiedDrawSteps.reduce(function (data, drawStep) { return _this.filterDefinedData(data, drawStep.attrToProjector["defined"]); }, data); - modifiedDrawSteps.forEach(function (d) { + // HACKHACK To prevent populating undesired attribute to d3, we delete them here. + Element.prototype._prepareDrawSteps = function (drawSteps) { + _super.prototype._prepareDrawSteps.call(this, drawSteps); + drawSteps.forEach(function (d) { if (d.attrToProjector["defined"]) { delete d.attrToProjector["defined"]; } }); - return _super.prototype.draw.call(this, definedData, modifiedDrawSteps); + }; + Element.prototype._prepareData = function (data, drawSteps) { + var _this = this; + return drawSteps.reduce(function (data, drawStep) { return _this.filterDefinedData(data, drawStep.attrToProjector["defined"]); }, _super.prototype._prepareData.call(this, data, drawSteps)); }; return Element; })(_Drawer.AbstractDrawer); @@ -3471,17 +3494,17 @@ var Plottable; Rect.prototype.removeLabels = function () { this.textArea.selectAll("g").remove(); }; - Rect.prototype.drawText = function (data, attrToProjector) { + Rect.prototype.drawText = function (data, attrToProjector, userMetadata, plotMetadata) { var _this = this; var labelTooWide = data.map(function (d, i) { - var text = attrToProjector["label"](d, i).toString(); - var w = attrToProjector["width"](d, i); - var h = attrToProjector["height"](d, i); - var x = attrToProjector["x"](d, i); - var y = attrToProjector["y"](d, i); - var positive = attrToProjector["positive"](d, i); + var text = attrToProjector["label"](d, i, userMetadata, plotMetadata).toString(); + var w = attrToProjector["width"](d, i, userMetadata, plotMetadata); + var h = attrToProjector["height"](d, i, userMetadata, plotMetadata); + var x = attrToProjector["x"](d, i, userMetadata, plotMetadata); + var y = attrToProjector["y"](d, i, userMetadata, plotMetadata); + var positive = attrToProjector["positive"](d, i, userMetadata, plotMetadata); var measurement = _this.measurer(text); - var color = attrToProjector["fill"](d, i); + var color = attrToProjector["fill"](d, i, userMetadata, plotMetadata); var dark = Plottable._Util.Color.contrast("white", color) * 1.6 < Plottable._Util.Color.contrast("black", color); var primary = _this._isVertical ? h : w; var primarySpace = _this._isVertical ? measurement.height : measurement.width; @@ -3561,11 +3584,12 @@ var Plottable; attrToProjector["d"] = this.createArc(innerRadiusF, outerRadiusF); return _super.prototype._drawStep.call(this, { attrToProjector: attrToProjector, animator: step.animator }); }; - Arc.prototype.draw = function (data, drawSteps) { - var valueAccessor = drawSteps[0].attrToProjector["value"]; + Arc.prototype.draw = function (data, drawSteps, userMetadata, plotMetadata) { + // HACKHACK Applying metadata should be done in base class + var valueAccessor = function (d, i) { return drawSteps[0].attrToProjector["value"](d, i, userMetadata, plotMetadata); }; var pie = d3.layout.pie().sort(null).value(valueAccessor)(data); drawSteps.forEach(function (s) { return delete s.attrToProjector["value"]; }); - return _super.prototype.draw.call(this, pie, drawSteps); + return _super.prototype.draw.call(this, pie, drawSteps, userMetadata, plotMetadata); }; return Arc; })(_Drawer.Element); @@ -4598,9 +4622,146 @@ var Plottable; */ function Time(scale, orientation) { _super.call(this, scale, orientation); + /* + * Default possible axis configurations. + */ + this.possibleTimeAxisConfigurations = [ + { tierConfigurations: [ + { interval: d3.time.second, step: 1, formatter: Plottable.Formatters.time("%I:%M:%S %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.second, step: 5, formatter: Plottable.Formatters.time("%I:%M:%S %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.second, step: 10, formatter: Plottable.Formatters.time("%I:%M:%S %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.second, step: 15, formatter: Plottable.Formatters.time("%I:%M:%S %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.second, step: 30, formatter: Plottable.Formatters.time("%I:%M:%S %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.minute, step: 1, formatter: Plottable.Formatters.time("%I:%M %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.minute, step: 5, formatter: Plottable.Formatters.time("%I:%M %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.minute, step: 10, formatter: Plottable.Formatters.time("%I:%M %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.minute, step: 15, formatter: Plottable.Formatters.time("%I:%M %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.minute, step: 30, formatter: Plottable.Formatters.time("%I:%M %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.hour, step: 1, formatter: Plottable.Formatters.time("%I %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.hour, step: 3, formatter: Plottable.Formatters.time("%I %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.hour, step: 6, formatter: Plottable.Formatters.time("%I %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.hour, step: 12, formatter: Plottable.Formatters.time("%I %p") }, + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%B %e, %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%a %e") }, + { interval: d3.time.month, step: 1, formatter: Plottable.Formatters.time("%B %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.day, step: 1, formatter: Plottable.Formatters.time("%e") }, + { interval: d3.time.month, step: 1, formatter: Plottable.Formatters.time("%B %Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.month, step: 1, formatter: Plottable.Formatters.time("%B") }, + { interval: d3.time.year, step: 1, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.month, step: 1, formatter: Plottable.Formatters.time("%b") }, + { interval: d3.time.year, step: 1, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.month, step: 3, formatter: Plottable.Formatters.time("%b") }, + { interval: d3.time.year, step: 1, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.month, step: 6, formatter: Plottable.Formatters.time("%b") }, + { interval: d3.time.year, step: 1, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 1, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 1, formatter: Plottable.Formatters.time("%y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 5, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 25, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 50, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 100, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 200, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 500, formatter: Plottable.Formatters.time("%Y") } + ] }, + { tierConfigurations: [ + { interval: d3.time.year, step: 1000, formatter: Plottable.Formatters.time("%Y") } + ] } + ]; this.classed("time-axis", true); this.tickLabelPadding(5); } + Time.prototype.axisConfigurations = function (configurations) { + if (configurations == null) { + return this.possibleTimeAxisConfigurations; + } + this.possibleTimeAxisConfigurations = configurations; + this._invalidateLayout(); + return this; + }; + /** + * Gets the index of the most precise TimeAxisConfiguration that will fit in the current width. + */ + Time.prototype.getMostPreciseConfigurationIndex = function () { + var _this = this; + var mostPreciseIndex = this.possibleTimeAxisConfigurations.length; + this.possibleTimeAxisConfigurations.forEach(function (interval, index) { + if (index < mostPreciseIndex && interval.tierConfigurations.every(function (tier) { return _this.checkTimeAxisTierConfigurationWidth(tier); })) { + mostPreciseIndex = index; + } + }); + if (mostPreciseIndex === this.possibleTimeAxisConfigurations.length) { + Plottable._Util.Methods.warn("zoomed out too far: could not find suitable interval to display labels"); + --mostPreciseIndex; + } + return mostPreciseIndex; + }; Time.prototype.orient = function (orientation) { if (orientation && (orientation.toLowerCase() === "right" || orientation.toLowerCase() === "left")) { throw new Error(orientation + " is not a supported orientation for TimeAxis - only horizontal orientations are supported"); @@ -4611,21 +4772,15 @@ var Plottable; if (this._computedHeight !== null) { return this._computedHeight; } - var textHeight = this._measureTextHeight(this._majorTickLabels) + this._measureTextHeight(this._minorTickLabels); + var textHeight = this._measureTextHeight() * 2; this.tickLength(textHeight); this.endTickLength(textHeight); this._computedHeight = this._maxLabelTickLength() + 2 * this.tickLabelPadding(); return this._computedHeight; }; - Time.prototype.calculateWorstWidth = function (container, format) { - // returns the worst case width for a format - // September 29, 9999 at 12:59.9999 PM Wednesday - var longDate = new Date(9999, 8, 29, 12, 59, 9999); - return this.measurer(d3.time.format(format)(longDate)).width; - }; - Time.prototype.getIntervalLength = function (interval) { + Time.prototype.getIntervalLength = function (config) { var startDate = this._scale.domain()[0]; - var endDate = interval.timeUnit.offset(startDate, interval.step); + var endDate = config.interval.offset(startDate, config.step); if (endDate > this._scale.domain()[1]) { // this offset is too large, so just return available width return this.width(); @@ -4634,54 +4789,43 @@ var Plottable; var stepLength = Math.abs(this._scale.scale(endDate) - this._scale.scale(startDate)); return stepLength; }; - Time.prototype.isEnoughSpace = function (container, interval) { - // compute number of ticks - // if less than a certain threshold - var worst = this.calculateWorstWidth(container, interval.formatString) + 2 * this.tickLabelPadding(); - var stepLength = Math.min(this.getIntervalLength(interval), this.width()); - return worst < stepLength; + Time.prototype.maxWidthForInterval = function (config) { + return this.measurer(config.formatter(Time.LONG_DATE)).width; + }; + /** + * Check if tier configuration fits in the current width. + */ + Time.prototype.checkTimeAxisTierConfigurationWidth = function (config) { + var worstWidth = this.maxWidthForInterval(config) + 2 * this.tickLabelPadding(); + return Math.min(this.getIntervalLength(config), this.width()) >= worstWidth; }; Time.prototype._setup = function () { _super.prototype._setup.call(this); - this._majorTickLabels = this._content.append("g").classed(Axis.AbstractAxis.TICK_LABEL_CLASS, true); - this._minorTickLabels = this._content.append("g").classed(Axis.AbstractAxis.TICK_LABEL_CLASS, true); - this.measurer = Plottable._Util.Text.getTextMeasurer(this._majorTickLabels.append("text")); - }; - // returns a number to index into the major/minor intervals - Time.prototype.getTickLevel = function () { - for (var i = 0; i < Time._minorIntervals.length; i++) { - if (this.isEnoughSpace(this._minorTickLabels, Time._minorIntervals[i]) && this.isEnoughSpace(this._majorTickLabels, Time._majorIntervals[i])) { - break; - } - } - if (i >= Time._minorIntervals.length) { - Plottable._Util.Methods.warn("zoomed out too far: could not find suitable interval to display labels"); - i = Time._minorIntervals.length - 1; + this.tierLabelContainers = []; + for (var i = 0; i < Time.NUM_TIERS; ++i) { + this.tierLabelContainers.push(this._content.append("g").classed(Axis.AbstractAxis.TICK_LABEL_CLASS, true)); } - return i; + this.measurer = Plottable._Util.Text.getTextMeasurer(this.tierLabelContainers[0].append("text")); }; - Time.prototype._getTickIntervalValues = function (interval) { - return this._scale._tickInterval(interval.timeUnit, interval.step); + Time.prototype.getTickIntervalValues = function (config) { + return this._scale._tickInterval(config.interval, config.step); }; Time.prototype._getTickValues = function () { - var index = this.getTickLevel(); - var minorTicks = this._getTickIntervalValues(Time._minorIntervals[index]); - var majorTicks = this._getTickIntervalValues(Time._majorIntervals[index]); - return minorTicks.concat(majorTicks); + var _this = this; + return this.possibleTimeAxisConfigurations[this.mostPreciseConfigIndex].tierConfigurations.reduce(function (ticks, config) { return ticks.concat(_this.getTickIntervalValues(config)); }, []); }; - Time.prototype._measureTextHeight = function (container) { - var fakeTickLabel = container.append("g").classed(Axis.AbstractAxis.TICK_LABEL_CLASS, true); - var textHeight = this.measurer(Plottable._Util.Text.HEIGHT_TEXT).height; - fakeTickLabel.remove(); - return textHeight; + Time.prototype._measureTextHeight = function () { + return this.measurer(Plottable._Util.Text.HEIGHT_TEXT).height; }; - Time.prototype.renderTickLabels = function (container, interval, height) { - var _this = this; + Time.prototype.cleanContainer = function (container) { container.selectAll("." + Axis.AbstractAxis.TICK_LABEL_CLASS).remove(); - var tickPos = this._scale._tickInterval(interval.timeUnit, interval.step); + }; + Time.prototype.renderTierLabels = function (container, config, height) { + var _this = this; + var tickPos = this._scale._tickInterval(config.interval, config.step); tickPos.splice(0, 0, this._scale.domain()[0]); tickPos.push(this._scale.domain()[1]); - var shouldCenterText = interval.step === 1; + var shouldCenterText = config.step === 1; // only center when the label should span the whole interval var labelPos = []; if (shouldCenterText) { @@ -4695,7 +4839,14 @@ var Plottable; else { labelPos = tickPos; } - labelPos = labelPos.filter(function (d) { return _this.canFitLabelFilter(container, d, d3.time.format(interval.formatString)(d), shouldCenterText); }); + var filteredTicks = []; + labelPos = labelPos.filter(function (d, i) { + var fits = _this.canFitLabelFilter(container, d, tickPos.slice(i, i + 2), config.formatter(d), shouldCenterText); + if (fits) { + filteredTicks.push(tickPos[i]); + } + return fits; + }); var tickLabels = container.selectAll("." + Axis.AbstractAxis.TICK_LABEL_CLASS).data(labelPos, function (d) { return d.valueOf(); }); var tickLabelsEnter = tickLabels.enter().append("g").classed(Axis.AbstractAxis.TICK_LABEL_CLASS, true); tickLabelsEnter.append("text"); @@ -4708,12 +4859,15 @@ var Plottable; tickLabels.exit().remove(); tickLabels.attr("transform", function (d) { return "translate(" + _this._scale.scale(d) + ",0)"; }); var anchor = shouldCenterText ? "middle" : "start"; - tickLabels.selectAll("text").text(function (d) { return d3.time.format(interval.formatString)(d); }).style("text-anchor", anchor); + tickLabels.selectAll("text").text(config.formatter).style("text-anchor", anchor); + return filteredTicks; }; - Time.prototype.canFitLabelFilter = function (container, position, label, isCentered) { + Time.prototype.canFitLabelFilter = function (container, position, bounds, label, isCentered) { var endPosition; var startPosition; var width = this.measurer(label).width + this.tickLabelPadding(); + var leftBound = this._scale.scale(bounds[0]); + var rightBound = this._scale.scale(bounds[1]); if (isCentered) { endPosition = this._scale.scale(position) + width / 2; startPosition = this._scale.scale(position) - width / 2; @@ -4722,109 +4876,52 @@ var Plottable; endPosition = this._scale.scale(position) + width; startPosition = this._scale.scale(position); } - return endPosition < this.width() && startPosition > 0; + return endPosition <= rightBound && startPosition >= leftBound; }; - Time.prototype.adjustTickLength = function (height, interval) { - var tickValues = this._getTickIntervalValues(interval); + Time.prototype.adjustTickLength = function (tickValues, height) { var selection = this._tickMarkContainer.selectAll("." + Axis.AbstractAxis.TICK_MARK_CLASS).filter(function (d) { return tickValues.map(function (x) { return x.valueOf(); }).indexOf(d.valueOf()) >= 0; }); if (this._orientation === "top") { height = this.height() - height; } selection.attr("y2", height); }; - Time.prototype.generateLabellessTicks = function (index) { - if (index < 0) { - return; + Time.prototype.generateLabellessTicks = function () { + if (this.mostPreciseConfigIndex < 1) { + return []; } - var smallTicks = this._getTickIntervalValues(Time._minorIntervals[index]); - var allTicks = this._getTickValues().concat(smallTicks); - var tickMarks = this._tickMarkContainer.selectAll("." + Axis.AbstractAxis.TICK_MARK_CLASS).data(allTicks); + return this.getTickIntervalValues(this.possibleTimeAxisConfigurations[this.mostPreciseConfigIndex - 1].tierConfigurations[0]); + }; + Time.prototype.createTickMarks = function (ticks) { + var tickMarks = this._tickMarkContainer.selectAll("." + Axis.AbstractAxis.TICK_MARK_CLASS).data(ticks); tickMarks.enter().append("line").classed(Axis.AbstractAxis.TICK_MARK_CLASS, true); tickMarks.attr(this._generateTickMarkAttrHash()); tickMarks.exit().remove(); - this.adjustTickLength(this.tickLabelPadding(), Time._minorIntervals[index]); }; Time.prototype._doRender = function () { + var _this = this; + this.mostPreciseConfigIndex = this.getMostPreciseConfigurationIndex(); _super.prototype._doRender.call(this); - var index = this.getTickLevel(); - this.renderTickLabels(this._minorTickLabels, Time._minorIntervals[index], 1); - this.renderTickLabels(this._majorTickLabels, Time._majorIntervals[index], 2); + var tierConfigs = this.possibleTimeAxisConfigurations[this.mostPreciseConfigIndex].tierConfigurations; + this.tierLabelContainers.forEach(this.cleanContainer); + var tierTicks = tierConfigs.map(function (config, i) { return _this.renderTierLabels(_this.tierLabelContainers[i], config, i + 1); }); + var ticks = tierTicks.slice(); + var labelLessTicks = []; var domain = this._scale.domain(); var totalLength = this._scale.scale(domain[1]) - this._scale.scale(domain[0]); - if (this.getIntervalLength(Time._minorIntervals[index]) * 1.5 >= totalLength) { - this.generateLabellessTicks(index - 1); + if (this.getIntervalLength(tierConfigs[0]) * 1.5 >= totalLength) { + labelLessTicks = this.generateLabellessTicks(); } - // make minor ticks shorter - this.adjustTickLength(this._maxLabelTickLength() / 2, Time._minorIntervals[index]); - // however, we need to make major ticks longer, since they may have overlapped with some minor ticks - this.adjustTickLength(this._maxLabelTickLength(), Time._majorIntervals[index]); + ticks.push(labelLessTicks); + this.createTickMarks(Plottable._Util.Methods.flatten(ticks)); + this.adjustTickLength(labelLessTicks, this.tickLabelPadding()); + tierConfigs.forEach(function (config, i) { return _this.adjustTickLength(tierTicks[i], _this._maxLabelTickLength() * (i + 1) / Time.NUM_TIERS); }); return this; }; - // default intervals - // these are for minor tick labels - Time._minorIntervals = [ - { timeUnit: d3.time.second, step: 1, formatString: "%I:%M:%S %p" }, - { timeUnit: d3.time.second, step: 5, formatString: "%I:%M:%S %p" }, - { timeUnit: d3.time.second, step: 10, formatString: "%I:%M:%S %p" }, - { timeUnit: d3.time.second, step: 15, formatString: "%I:%M:%S %p" }, - { timeUnit: d3.time.second, step: 30, formatString: "%I:%M:%S %p" }, - { timeUnit: d3.time.minute, step: 1, formatString: "%I:%M %p" }, - { timeUnit: d3.time.minute, step: 5, formatString: "%I:%M %p" }, - { timeUnit: d3.time.minute, step: 10, formatString: "%I:%M %p" }, - { timeUnit: d3.time.minute, step: 15, formatString: "%I:%M %p" }, - { timeUnit: d3.time.minute, step: 30, formatString: "%I:%M %p" }, - { timeUnit: d3.time.hour, step: 1, formatString: "%I %p" }, - { timeUnit: d3.time.hour, step: 3, formatString: "%I %p" }, - { timeUnit: d3.time.hour, step: 6, formatString: "%I %p" }, - { timeUnit: d3.time.hour, step: 12, formatString: "%I %p" }, - { timeUnit: d3.time.day, step: 1, formatString: "%a %e" }, - { timeUnit: d3.time.day, step: 1, formatString: "%e" }, - { timeUnit: d3.time.month, step: 1, formatString: "%B" }, - { timeUnit: d3.time.month, step: 1, formatString: "%b" }, - { timeUnit: d3.time.month, step: 3, formatString: "%B" }, - { timeUnit: d3.time.month, step: 6, formatString: "%B" }, - { timeUnit: d3.time.year, step: 1, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 1, formatString: "%y" }, - { timeUnit: d3.time.year, step: 5, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 25, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 50, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 100, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 200, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 500, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 1000, formatString: "%Y" } - ]; - // these are for major tick labels - Time._majorIntervals = [ - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.day, step: 1, formatString: "%B %e, %Y" }, - { timeUnit: d3.time.month, step: 1, formatString: "%B %Y" }, - { timeUnit: d3.time.month, step: 1, formatString: "%B %Y" }, - { timeUnit: d3.time.year, step: 1, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 1, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 1, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 1, formatString: "%Y" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" }, - { timeUnit: d3.time.year, step: 100000, formatString: "" } - ]; + Time.LONG_DATE = new Date(9999, 8, 29, 12, 59, 9999); + /** + * Number of possible tiers. + */ + Time.NUM_TIERS = 2; return Time; })(Axis.AbstractAxis); Axis.Time = Time; @@ -6227,14 +6324,14 @@ var Plottable; function AbstractPlot() { _super.call(this); this._dataChanged = false; - this._projectors = {}; + this._projections = {}; this._animate = false; this._animators = {}; this._ANIMATION_DURATION = 250; // milliseconds this._animateOnNextRender = true; this.clipPathEnabled = true; this.classed("plot", true); - this._key2DatasetDrawerKey = d3.map(); + this._key2PlotDatasetKey = d3.map(); this._datasetKeysInOrder = []; this.nextSeriesIndex = 0; } @@ -6256,9 +6353,9 @@ var Plottable; _super.prototype.remove.call(this); this._datasetKeysInOrder.forEach(function (k) { return _this.removeDataset(k); }); // deregister from all scales - var properties = Object.keys(this._projectors); + var properties = Object.keys(this._projections); properties.forEach(function (property) { - var projector = _this._projectors[property]; + var projector = _this._projections[property]; if (projector.scale) { projector.scale.broadcaster.deregisterListener(_this); } @@ -6279,14 +6376,15 @@ var Plottable; }; AbstractPlot.prototype._addDataset = function (key, dataset) { var _this = this; - if (this._key2DatasetDrawerKey.has(key)) { + if (this._key2PlotDatasetKey.has(key)) { this.removeDataset(key); } ; var drawer = this._getDrawer(key); - var ddk = { drawer: drawer, dataset: dataset, key: key }; + var metadata = this._getPlotMetadataForDataset(key); + var pdk = { drawer: drawer, dataset: dataset, key: key, plotMetadata: metadata }; this._datasetKeysInOrder.push(key); - this._key2DatasetDrawerKey.set(key, ddk); + this._key2PlotDatasetKey.set(key, pdk); if (this._isSetup) { drawer.setup(this._renderArea.append("g")); } @@ -6342,7 +6440,7 @@ var Plottable; AbstractPlot.prototype.project = function (attrToSet, accessor, scale) { var _this = this; attrToSet = attrToSet.toLowerCase(); - var currentProjection = this._projectors[attrToSet]; + var currentProjection = this._projections[attrToSet]; var existingScale = currentProjection && currentProjection.scale; if (existingScale) { this._datasetKeysInOrder.forEach(function (key) { @@ -6353,8 +6451,8 @@ var Plottable; if (scale) { scale.broadcaster.registerListener(this, function () { return _this._render(); }); } - var activatedAccessor = Plottable._Util.Methods._applyAccessor(accessor, this); - this._projectors[attrToSet] = { accessor: activatedAccessor, scale: scale, attribute: attrToSet }; + accessor = Plottable._Util.Methods.accessorize(accessor); + this._projections[attrToSet] = { accessor: accessor, scale: scale, attribute: attrToSet }; this._updateScaleExtent(attrToSet); this._render(); // queue a re-render upon changing projector return this; @@ -6362,11 +6460,11 @@ var Plottable; AbstractPlot.prototype._generateAttrToProjector = function () { var _this = this; var h = {}; - d3.keys(this._projectors).forEach(function (a) { - var projector = _this._projectors[a]; - var accessor = projector.accessor; - var scale = projector.scale; - var fn = scale ? function (d, i) { return scale.scale(accessor(d, i)); } : accessor; + d3.keys(this._projections).forEach(function (a) { + var projection = _this._projections[a]; + var accessor = projection.accessor; + var scale = projection.scale; + var fn = scale ? function (d, i, u, m) { return scale.scale(accessor(d, i, u, m)); } : accessor; h[a] = fn; }); return h; @@ -6394,19 +6492,19 @@ var Plottable; return this; }; /** - * This function makes sure that all of the scales in this._projectors + * This function makes sure that all of the scales in this._projections * have an extent that includes all the data that is projected onto them. */ AbstractPlot.prototype._updateScaleExtents = function () { var _this = this; - d3.keys(this._projectors).forEach(function (attr) { return _this._updateScaleExtent(attr); }); + d3.keys(this._projections).forEach(function (attr) { return _this._updateScaleExtent(attr); }); }; AbstractPlot.prototype._updateScaleExtent = function (attr) { var _this = this; - var projector = this._projectors[attr]; + var projector = this._projections[attr]; if (projector.scale) { - this._key2DatasetDrawerKey.forEach(function (key, ddk) { - var extent = ddk.dataset._getExtent(projector.accessor, projector.scale._typeCoercer); + this._key2PlotDatasetKey.forEach(function (key, pdk) { + var extent = pdk.dataset._getExtent(projector.accessor, projector.scale._typeCoercer, pdk.plotMetadata); var scaleKey = _this._plottableID.toString() + "_" + key; if (extent.length === 0 || !_this._isAnchored) { projector.scale._removeExtent(scaleKey, attr); @@ -6459,30 +6557,30 @@ var Plottable; return this._removeDataset(key); }; AbstractPlot.prototype._removeDataset = function (key) { - if (key != null && this._key2DatasetDrawerKey.has(key)) { - var ddk = this._key2DatasetDrawerKey.get(key); - ddk.drawer.remove(); - var projectors = d3.values(this._projectors); + if (key != null && this._key2PlotDatasetKey.has(key)) { + var pdk = this._key2PlotDatasetKey.get(key); + pdk.drawer.remove(); + var projectors = d3.values(this._projections); var scaleKey = this._plottableID.toString() + "_" + key; projectors.forEach(function (p) { if (p.scale != null) { p.scale._removeExtent(scaleKey, p.attribute); } }); - ddk.dataset.broadcaster.deregisterListener(this); + pdk.dataset.broadcaster.deregisterListener(this); this._datasetKeysInOrder.splice(this._datasetKeysInOrder.indexOf(key), 1); - this._key2DatasetDrawerKey.remove(key); + this._key2PlotDatasetKey.remove(key); this._onDatasetUpdate(); } return this; }; AbstractPlot.prototype.datasets = function () { var _this = this; - return this._datasetKeysInOrder.map(function (k) { return _this._key2DatasetDrawerKey.get(k).dataset; }); + return this._datasetKeysInOrder.map(function (k) { return _this._key2PlotDatasetKey.get(k).dataset; }); }; AbstractPlot.prototype._getDrawersInOrder = function () { var _this = this; - return this._datasetKeysInOrder.map(function (k) { return _this._key2DatasetDrawerKey.get(k).drawer; }); + return this._datasetKeysInOrder.map(function (k) { return _this._key2PlotDatasetKey.get(k).drawer; }); }; AbstractPlot.prototype._generateDrawSteps = function () { return [{ attrToProjector: this._generateAttrToProjector(), animator: new Plottable.Animator.Null() }]; @@ -6494,15 +6592,27 @@ var Plottable; var _this = this; var datasets = d3.map(); this._datasetKeysInOrder.forEach(function (key) { - datasets.set(key, _this._key2DatasetDrawerKey.get(key).dataset.data()); + datasets.set(key, _this._key2PlotDatasetKey.get(key).dataset.data()); }); return datasets; }; + /** + * Gets the new plot metadata for new dataset with provided key + * + * @param {string} key The key of new dataset + */ + AbstractPlot.prototype._getPlotMetadataForDataset = function (key) { + return { + datasetKey: key + }; + }; AbstractPlot.prototype.paint = function () { + var _this = this; var drawSteps = this._generateDrawSteps(); var dataToDraw = this._getDataToDraw(); var drawers = this._getDrawersInOrder(); - var times = this._datasetKeysInOrder.map(function (k, i) { return drawers[i].draw(dataToDraw.get(k), drawSteps); }); + // TODO: Use metadata instead of dataToDraw #1297. + var times = this._datasetKeysInOrder.map(function (k, i) { return drawers[i].draw(dataToDraw.get(k), drawSteps, _this._key2PlotDatasetKey.get(k).dataset.metadata(), _this._key2PlotDatasetKey.get(k).plotMetadata); }); var maxTime = Plottable._Util.Methods.max(times, 0); this._additionalPaint(maxTime); }; @@ -6565,7 +6675,7 @@ var Plottable; attrToProjector["fill"] = function (d, i) { return _this.colorScale.scale(String(i)); }; } var defaultAccessor = function (d) { return d.value; }; - var valueProjector = this._projectors["value"]; + var valueProjector = this._projections["value"]; attrToProjector["value"] = valueProjector ? valueProjector.accessor : defaultAccessor; return attrToProjector; }; @@ -6680,9 +6790,9 @@ var Plottable; var attrToProjector = _super.prototype._generateAttrToProjector.call(this); var positionXFn = attrToProjector["x"]; var positionYFn = attrToProjector["y"]; - attrToProjector["defined"] = function (d, i) { - var positionX = positionXFn(d, i); - var positionY = positionYFn(d, i); + attrToProjector["defined"] = function (d, i, u, m) { + var positionX = positionXFn(d, i, u, m); + var positionY = positionYFn(d, i, u, m); return positionX != null && positionX === positionX && positionY != null && positionY === positionY; }; return attrToProjector; @@ -6747,12 +6857,16 @@ var Plottable; } }; AbstractXYPlot.prototype.normalizeDatasets = function (fromX) { - var flattenDatasets = Plottable._Util.Methods.flatten(this.datasets().map(function (d) { return d.data(); })); - var aAccessor = this._projectors[fromX ? "x" : "y"].accessor; - var bAccessor = this._projectors[fromX ? "y" : "x"].accessor; - return flattenDatasets.map(function (d, i) { - return { a: aAccessor(d, i), b: bAccessor(d, i) }; - }); + var _this = this; + var aAccessor = this._projections[fromX ? "x" : "y"].accessor; + var bAccessor = this._projections[fromX ? "y" : "x"].accessor; + return Plottable._Util.Methods.flatten(this._datasetKeysInOrder.map(function (key) { + var dataset = _this._key2PlotDatasetKey.get(key).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(key).plotMetadata; + return dataset.data().map(function (d, i) { + return { a: aAccessor(d, i, dataset.metadata(), plotMetadata), b: bAccessor(d, i, dataset.metadata(), plotMetadata) }; + }); + })); }; AbstractXYPlot.prototype.adjustDomainOverVisiblePoints = function (values, fromDomain) { var bVals = values.filter(function (v) { return fromDomain[0] <= v.a && v.a <= fromDomain[1]; }).map(function (v) { return v.b; }); @@ -6831,12 +6945,13 @@ var Plottable; drawSteps.push({ attrToProjector: this._generateAttrToProjector(), animator: this._getAnimator("circles") }); return drawSteps; }; + // HACKHACK User and plot metada should be applied - #1306. Scatter.prototype._getClosestStruckPoint = function (p, range) { var drawers = this._getDrawersInOrder(); var attrToProjector = this._generateAttrToProjector(); var getDistSq = function (d, i) { - var dx = attrToProjector["cx"](d, i) - p.x; - var dy = attrToProjector["cy"](d, i) - p.y; + var dx = attrToProjector["cx"](d, i, null, null) - p.x; + var dy = attrToProjector["cy"](d, i, null, null) - p.y; return (dx * dx + dy * dy); }; var overAPoint = false; @@ -6846,7 +6961,7 @@ var Plottable; drawers.forEach(function (drawer) { drawer._getDrawSelection().each(function (d, i) { var distSq = getDistSq(d, i); - var r = attrToProjector["r"](d, i); + var r = attrToProjector["r"](d, i, null, null); if (distSq < r * r) { if (!overAPoint || distSq < minDistSq) { closestElement = this; @@ -6872,8 +6987,8 @@ var Plottable; var closestSelection = d3.select(closestElement); var closestData = closestSelection.data(); var closestPoint = { - x: attrToProjector["cx"](closestData[0], closestIndex), - y: attrToProjector["cy"](closestData[0], closestIndex) + x: attrToProjector["cx"](closestData[0], closestIndex, null, null), + y: attrToProjector["cy"](closestData[0], closestIndex, null, null) }; return { selection: closestSelection, @@ -6952,7 +7067,7 @@ var Plottable; Grid.prototype.project = function (attrToSet, accessor, scale) { _super.prototype.project.call(this, attrToSet, accessor, scale); if (attrToSet === "fill") { - this._colorScale = this._projectors["fill"].scale; + this._colorScale = this._projections["fill"].scale; } return this; }; @@ -7074,12 +7189,19 @@ var Plottable; return this; } }; - AbstractBarPlot.prototype.selectBar = function (xValOrExtent, yValOrExtent, select) { - if (select === void 0) { select = true; } + /** + * Gets all the bars in the bar plot + * + * @returns {D3.Selection} All of the bars in the bar plot. + */ + AbstractBarPlot.prototype.getAllBars = function () { + return this._renderArea.selectAll("rect"); + }; + AbstractBarPlot.prototype.getBars = function (xValOrExtent, yValOrExtent) { if (!this._isSetup) { - return null; + return d3.select(); } - var selectedBars = []; + var bars = []; var xExtent = this.parseExtent(xValOrExtent); var yExtent = this.parseExtent(yValOrExtent); // the SVGRects are positioned with sub-pixel accuracy (the default unit @@ -7092,18 +7214,11 @@ var Plottable; d._renderArea.selectAll("rect").each(function (d) { var bbox = this.getBBox(); if (bbox.x + bbox.width >= xExtent.min - tolerance && bbox.x <= xExtent.max + tolerance && bbox.y + bbox.height >= yExtent.min - tolerance && bbox.y <= yExtent.max + tolerance) { - selectedBars.push(this); + bars.push(this); } }); }); - if (selectedBars.length > 0) { - var selection = d3.selectAll(selectedBars); - selection.classed("selected", select); - return selection; - } - else { - return null; - } + return d3.selectAll(bars); }; /** * Deselects all bars. @@ -7165,10 +7280,11 @@ var Plottable; } }; AbstractBarPlot.prototype._drawLabels = function () { + var _this = this; var drawers = this._getDrawersInOrder(); var attrToProjector = this._generateAttrToProjector(); var dataToDraw = this._getDataToDraw(); - this._datasetKeysInOrder.forEach(function (k, i) { return drawers[i].drawText(dataToDraw.get(k), attrToProjector); }); + this._datasetKeysInOrder.forEach(function (k, i) { return drawers[i].drawText(dataToDraw.get(k), attrToProjector, _this._key2PlotDatasetKey.get(k).dataset.metadata(), _this._key2PlotDatasetKey.get(k).plotMetadata); }); if (this.hideBarsIfAnyAreTooWide && drawers.some(function (d) { return d._someLabelsTooWide; })) { drawers.forEach(function (d) { return d.removeLabels(); }); } @@ -7205,29 +7321,29 @@ var Plottable; var widthF = attrToProjector["width"]; var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) && secondaryScale.rangeType() === "bands"; if (!bandsMode) { - attrToProjector[secondaryAttr] = function (d, i) { return positionF(d, i) - widthF(d, i) * _this._barAlignmentFactor; }; + attrToProjector[secondaryAttr] = function (d, i, u, m) { return positionF(d, i, u, m) - widthF(d, i, u, m) * _this._barAlignmentFactor; }; } else { var bandWidth = secondaryScale.rangeBand(); - attrToProjector[secondaryAttr] = function (d, i) { return positionF(d, i) - widthF(d, i) / 2 + bandWidth / 2; }; + attrToProjector[secondaryAttr] = function (d, i, u, m) { return positionF(d, i, u, m) - widthF(d, i, u, m) / 2 + bandWidth / 2; }; } var originalPositionFn = attrToProjector[primaryAttr]; - attrToProjector[primaryAttr] = function (d, i) { - var originalPos = originalPositionFn(d, i); + attrToProjector[primaryAttr] = function (d, i, u, m) { + var originalPos = originalPositionFn(d, i, u, m); // If it is past the baseline, it should start at the baselin then width/height // carries it over. If it's not past the baseline, leave it at original position and // then width/height carries it to baseline return (originalPos > scaledBaseline) ? scaledBaseline : originalPos; }; - attrToProjector["height"] = function (d, i) { - return Math.abs(scaledBaseline - originalPositionFn(d, i)); + attrToProjector["height"] = function (d, i, u, m) { + return Math.abs(scaledBaseline - originalPositionFn(d, i, u, m)); }; - var primaryAccessor = this._projectors[primaryAttr].accessor; + var primaryAccessor = this._projections[primaryAttr].accessor; if (this.barLabelsEnabled && this.barLabelFormatter) { - attrToProjector["label"] = function (d, i) { - return _this._barLabelFormatter(primaryAccessor(d, i)); + attrToProjector["label"] = function (d, i, u, m) { + return _this._barLabelFormatter(primaryAccessor(d, i, u, m)); }; - attrToProjector["positive"] = function (d, i) { return originalPositionFn(d, i) <= scaledBaseline; }; + attrToProjector["positive"] = function (d, i, u, m) { return originalPositionFn(d, i, u, m) <= scaledBaseline; }; } return attrToProjector; }; @@ -7240,6 +7356,7 @@ var Plottable; * If the position scale of the plot is a QuantitativeScale, then _getMinimumDataWidth is scaled to compute the barPixelWidth */ AbstractBarPlot.prototype._getBarPixelWidth = function () { + var _this = this; var barPixelWidth; var barScale = this._isVertical ? this._xScale : this._yScale; if (barScale instanceof Plottable.Scale.Ordinal) { @@ -7258,15 +7375,19 @@ var Plottable; } } else { - var barAccessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; - var barAccessorData = d3.set(Plottable._Util.Methods.flatten(this.datasets().map(function (dataset) { - return dataset.data().map(function (d, i) { return barAccessor(d, i); }); + var barAccessor = this._isVertical ? this._projections["x"].accessor : this._projections["y"].accessor; + var barAccessorData = d3.set(Plottable._Util.Methods.flatten(this._datasetKeysInOrder.map(function (k) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + return dataset.data().map(function (d, i) { return barAccessor(d, i, dataset.metadata(), plotMetadata); }); }))).values(); if (barAccessorData.some(function (datum) { return datum === "undefined"; })) { return -1; } - var numberBarAccessorData = d3.set(Plottable._Util.Methods.flatten(this.datasets().map(function (dataset) { - return dataset.data().map(function (d, i) { return barAccessor(d, i).valueOf(); }); + var numberBarAccessorData = d3.set(Plottable._Util.Methods.flatten(this._datasetKeysInOrder.map(function (k) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + return dataset.data().map(function (d, i) { return barAccessor(d, i, dataset.metadata(), plotMetadata).valueOf(); }); }))).values().map(function (value) { return +value; }); numberBarAccessorData.sort(function (a, b) { return a - b; }); var barAccessorDataPairs = d3.pairs(numberBarAccessorData); @@ -7300,6 +7421,7 @@ var Plottable; AbstractBarPlot.prototype._hoverOutComponent = function (p) { this.clearHoverSelection(); }; + // HACKHACK User and plot metadata should be applied here - #1306. AbstractBarPlot.prototype._doHover = function (p) { var _this = this; var xPositionOrExtent = p.x; @@ -7313,12 +7435,12 @@ var Plottable; xPositionOrExtent = maxExtent; } } - var selectedBars = this.selectBar(xPositionOrExtent, yPositionOrExtent, false); - if (selectedBars) { + var bars = this.getBars(xPositionOrExtent, yPositionOrExtent); + if (!bars.empty()) { this._getDrawersInOrder().forEach(function (d, i) { d._renderArea.selectAll("rect").classed({ "hovered": false, "not-hovered": true }); }); - selectedBars.classed({ "hovered": true, "not-hovered": false }); + bars.classed({ "hovered": true, "not-hovered": false }); } else { this.clearHoverSelection(); @@ -7330,24 +7452,24 @@ var Plottable; } var points = []; var projectors = this._generateAttrToProjector(); - selectedBars.each(function (d, i) { + bars.each(function (d, i) { if (_this._isVertical) { points.push({ - x: projectors["x"](d, i) + projectors["width"](d, i) / 2, - y: projectors["y"](d, i) + (projectors["positive"](d, i) ? 0 : projectors["height"](d, i)) + x: projectors["x"](d, i, null, null) + projectors["width"](d, i, null, null) / 2, + y: projectors["y"](d, i, null, null) + (projectors["positive"](d, i, null, null) ? 0 : projectors["height"](d, i, null, null)) }); } else { points.push({ - x: projectors["x"](d, i) + (projectors["positive"](d, i) ? 0 : projectors["width"](d, i)), - y: projectors["y"](d, i) + projectors["height"](d, i) / 2 + x: projectors["x"](d, i, null, null) + (projectors["positive"](d, i, null, null) ? 0 : projectors["width"](d, i, null, null)), + y: projectors["y"](d, i, null, null) + projectors["height"](d, i, null, null) / 2 }); } }); return { - data: selectedBars.data(), + data: bars.data(), pixelPositions: points, - selection: selectedBars + selection: bars }; }; AbstractBarPlot._BarAlignmentToFactor = {}; @@ -7486,8 +7608,8 @@ var Plottable; _super.prototype._setup.call(this); this.hoverTarget = this._foregroundContainer.append("circle").classed("hover-target", true).style("visibility", "hidden"); }; - Line.prototype._rejectNullsAndNaNs = function (d, i, projector) { - var value = projector(d, i); + Line.prototype._rejectNullsAndNaNs = function (d, i, userMetdata, plotMetadata, accessor) { + var value = accessor(d, i, userMetdata, plotMetadata); return value != null && value === value; }; Line.prototype._getDrawer = function (key) { @@ -7502,7 +7624,7 @@ var Plottable; // avoids lines zooming on from offscreen. var startValue = (domainMax < 0 && domainMax) || (domainMin > 0 && domainMin) || 0; var scaledStartValue = this._yScale.scale(startValue); - return function (d, i) { return scaledStartValue; }; + return function (d, i, u, m) { return scaledStartValue; }; }; Line.prototype._generateDrawSteps = function () { var drawSteps = []; @@ -7522,23 +7644,24 @@ var Plottable; var singleDatumAttributes = d3.keys(attrToProjector).filter(isSingleDatumAttr); singleDatumAttributes.forEach(function (attribute) { var projector = attrToProjector[attribute]; - attrToProjector[attribute] = function (data, i) { return data.length > 0 ? projector(data[0], i) : null; }; + attrToProjector[attribute] = function (data, i, u, m) { return data.length > 0 ? projector(data[0], i, u, m) : null; }; }); var xFunction = attrToProjector["x"]; var yFunction = attrToProjector["y"]; - attrToProjector["defined"] = function (d, i) { return _this._rejectNullsAndNaNs(d, i, xFunction) && _this._rejectNullsAndNaNs(d, i, yFunction); }; + attrToProjector["defined"] = function (d, i, u, m) { return _this._rejectNullsAndNaNs(d, i, u, m, xFunction) && _this._rejectNullsAndNaNs(d, i, u, m, yFunction); }; return attrToProjector; }; Line.prototype._wholeDatumAttributes = function () { return ["x", "y"]; }; + // HACKHACK User and plot metadata should be applied here - #1306. Line.prototype._getClosestWithinRange = function (p, range) { var attrToProjector = this._generateAttrToProjector(); var xProjector = attrToProjector["x"]; var yProjector = attrToProjector["y"]; var getDistSq = function (d, i) { - var dx = +xProjector(d, i) - p.x; - var dy = +yProjector(d, i) - p.y; + var dx = +xProjector(d, i, null, null) - p.x; + var dy = +yProjector(d, i, null, null) - p.y; return (dx * dx + dy * dy); }; var closestOverall; @@ -7550,8 +7673,8 @@ var Plottable; if (distSq < closestDistSq) { closestOverall = d; closestPoint = { - x: xProjector(d, i), - y: yProjector(d, i) + x: xProjector(d, i, null, null), + y: yProjector(d, i, null, null) }; closestDistSq = distSq; } @@ -7643,7 +7766,7 @@ var Plottable; var _this = this; _super.prototype._updateYDomainer.call(this); var constantBaseline; - var y0Projector = this._projectors["y0"]; + var y0Projector = this._projections["y0"]; var y0Accessor = y0Projector && y0Projector.accessor; if (y0Accessor != null) { var extents = this.datasets().map(function (d) { return d._getExtent(y0Accessor, _this._yScale._typeCoercer); }); @@ -7729,13 +7852,14 @@ var Plottable; }; ClusteredBar.prototype._getDataToDraw = function () { var _this = this; - var accessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; + var accessor = this._isVertical ? this._projections["x"].accessor : this._projections["y"].accessor; var innerScale = this.makeInnerScale(); var clusters = d3.map(); this._datasetKeysInOrder.forEach(function (key) { - var data = _this._key2DatasetDrawerKey.get(key).dataset.data(); - clusters.set(key, data.map(function (d, i) { - var val = accessor(d, i); + var dataset = _this._key2PlotDatasetKey.get(key).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(key).plotMetadata; + clusters.set(key, dataset.data().map(function (d, i) { + var val = accessor(d, i, dataset.metadata(), plotMetadata); var primaryScale = _this._isVertical ? _this._xScale : _this._yScale; // TODO: store position information in metadata. var copyD = Plottable._Util.Methods.copyMap(d); @@ -7749,18 +7873,19 @@ var Plottable; var innerScale = new Plottable.Scale.Ordinal(); innerScale.domain(this._datasetKeysInOrder); // TODO: it might be replaced with _getBarPixelWidth call after closing #1180. - if (!this._projectors["width"]) { + if (!this._projections["width"]) { var secondaryScale = this._isVertical ? this._xScale : this._yScale; var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) && secondaryScale.rangeType() === "bands"; var constantWidth = bandsMode ? secondaryScale.rangeBand() : Plot.AbstractBarPlot._DEFAULT_WIDTH; innerScale.range([0, constantWidth]); } else { - var projector = this._projectors["width"]; - var accessor = projector.accessor; - var scale = projector.scale; - var fn = scale ? function (d, i) { return scale.scale(accessor(d, i)); } : accessor; - innerScale.range([0, fn(null, 0)]); + var projection = this._projections["width"]; + var accessor = projection.accessor; + var scale = projection.scale; + // HACKHACK Metadata should be passed + var fn = scale ? function (d, i, u, m) { return scale.scale(accessor(d, i, u, m)); } : accessor; + innerScale.range([0, fn(null, 0, null, null)]); } return innerScale; }; @@ -7789,7 +7914,7 @@ var Plottable; } AbstractStacked.prototype.project = function (attrToSet, accessor, scale) { _super.prototype.project.call(this, attrToSet, accessor, scale); - if (this._projectors["x"] && this._projectors["y"] && (attrToSet === "x" || attrToSet === "y")) { + if (this._projections["x"] && this._projections["y"] && (attrToSet === "x" || attrToSet === "y")) { this._updateStackOffsets(); } return this; @@ -7797,7 +7922,7 @@ var Plottable; AbstractStacked.prototype._onDatasetUpdate = function () { _super.prototype._onDatasetUpdate.call(this); // HACKHACK Caused since onDataSource is called before projectors are set up. Should be fixed by #803 - if (this._datasetKeysInOrder && this._projectors["x"] && this._projectors["y"]) { + if (this._datasetKeysInOrder && this._projections["x"] && this._projections["y"]) { this._updateStackOffsets(); } }; @@ -7818,16 +7943,21 @@ var Plottable; this._updateStackExtents(); }; AbstractStacked.prototype._updateStackExtents = function () { + var _this = this; var datasets = this.datasets(); var valueAccessor = this._valueAccessor(); - var maxStackExtent = Plottable._Util.Methods.max(datasets, function (dataset) { - return Plottable._Util.Methods.max(dataset.data(), function (datum) { - return +valueAccessor(datum) + datum["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]; + var maxStackExtent = Plottable._Util.Methods.max(this._datasetKeysInOrder, function (k) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + return Plottable._Util.Methods.max(dataset.data(), function (datum, i) { + return +valueAccessor(datum, i, dataset.metadata(), plotMetadata) + datum["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]; }, 0); }, 0); - var minStackExtent = Plottable._Util.Methods.min(datasets, function (dataset) { - return Plottable._Util.Methods.min(dataset.data(), function (datum) { - return +valueAccessor(datum) + datum["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]; + var minStackExtent = Plottable._Util.Methods.min(this._datasetKeysInOrder, function (k) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + return Plottable._Util.Methods.min(dataset.data(), function (datum, i) { + return +valueAccessor(datum, i, dataset.metadata(), plotMetadata) + datum["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]; }, 0); }, 0); this.stackedExtent = [Math.min(minStackExtent, 0), Math.max(0, maxStackExtent)]; @@ -7849,16 +7979,19 @@ var Plottable; * to be determined correctly on the overall datasets */ AbstractStacked.prototype._setDatasetStackOffsets = function (positiveDataMapArray, negativeDataMapArray) { + var _this = this; var keyAccessor = this._keyAccessor(); var valueAccessor = this._valueAccessor(); - this.datasets().forEach(function (dataset, datasetIndex) { - var positiveDataMap = positiveDataMapArray[datasetIndex]; - var negativeDataMap = negativeDataMapArray[datasetIndex]; - var isAllNegativeValues = dataset.data().every(function (datum) { return valueAccessor(datum) <= 0; }); + this._datasetKeysInOrder.forEach(function (k, index) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + var positiveDataMap = positiveDataMapArray[index]; + var negativeDataMap = negativeDataMapArray[index]; + var isAllNegativeValues = dataset.data().every(function (datum, i) { return valueAccessor(datum, i, dataset.metadata(), plotMetadata) <= 0; }); dataset.data().forEach(function (datum, datumIndex) { - var positiveOffset = positiveDataMap.get(keyAccessor(datum)).offset; - var negativeOffset = negativeDataMap.get(keyAccessor(datum)).offset; - var value = valueAccessor(datum); + var positiveOffset = positiveDataMap.get(keyAccessor(datum, datumIndex, dataset.metadata(), plotMetadata)).offset; + var negativeOffset = negativeDataMap.get(keyAccessor(datum, datumIndex, dataset.metadata(), plotMetadata)).offset; + var value = valueAccessor(datum, datumIndex, dataset.metadata(), plotMetadata); if (value === 0) { datum["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"] = isAllNegativeValues ? negativeOffset : positiveOffset; } @@ -7869,17 +8002,21 @@ var Plottable; }); }; AbstractStacked.prototype._getDomainKeys = function () { + var _this = this; var keyAccessor = this._keyAccessor(); var domainKeys = d3.set(); var datasets = this.datasets(); - datasets.forEach(function (dataset) { - dataset.data().forEach(function (datum) { - domainKeys.add(keyAccessor(datum)); + this._datasetKeysInOrder.forEach(function (k) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + dataset.data().forEach(function (datum, index) { + domainKeys.add(keyAccessor(datum, index, dataset.metadata(), plotMetadata)); }); }); return domainKeys.values(); }; AbstractStacked.prototype._generateDefaultMapArray = function () { + var _this = this; var keyAccessor = this._keyAccessor(); var valueAccessor = this._valueAccessor(); var datasets = this.datasets(); @@ -7889,10 +8026,12 @@ var Plottable; return { key: domainKey, value: 0 }; }); }); - datasets.forEach(function (dataset, datasetIndex) { - dataset.data().forEach(function (datum) { - var key = keyAccessor(datum); - var value = valueAccessor(datum); + this._datasetKeysInOrder.forEach(function (k, datasetIndex) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + dataset.data().forEach(function (datum, index) { + var key = keyAccessor(datum, index, dataset.metadata(), plotMetadata); + var value = valueAccessor(datum, index, dataset.metadata(), plotMetadata); dataMapArray[datasetIndex].set(key, { key: key, value: value }); }); }); @@ -7912,10 +8051,10 @@ var Plottable; } }; AbstractStacked.prototype._keyAccessor = function () { - return this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; + return this._isVertical ? this._projections["x"].accessor : this._projections["y"].accessor; }; AbstractStacked.prototype._valueAccessor = function () { - return this._isVertical ? this._projectors["y"].accessor : this._projectors["x"].accessor; + return this._isVertical ? this._projections["y"].accessor : this._projections["x"].accessor; }; return AbstractStacked; })(Plot.AbstractXYPlot); @@ -7959,9 +8098,14 @@ var Plottable; this._baseline = this._renderArea.append("line").classed("baseline", true); }; StackedArea.prototype._updateStackOffsets = function () { + var _this = this; var domainKeys = this._getDomainKeys(); - var keyAccessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; - var keySets = this.datasets().map(function (dataset) { return d3.set(dataset.data().map(function (datum, i) { return keyAccessor(datum, i).toString(); })).values(); }); + var keyAccessor = this._isVertical ? this._projections["x"].accessor : this._projections["y"].accessor; + var keySets = this._datasetKeysInOrder.map(function (k) { + var dataset = _this._key2PlotDatasetKey.get(k).dataset; + var plotMetadata = _this._key2PlotDatasetKey.get(k).plotMetadata; + return d3.set(dataset.data().map(function (datum, i) { return keyAccessor(datum, i, dataset.metadata(), plotMetadata).toString(); })).values(); + }); if (keySets.some(function (keySet) { return keySet.length !== domainKeys.length; })) { Plottable._Util.Methods.warn("the domains across the datasets are not the same. Plot may produce unintended behavior."); } @@ -7998,11 +8142,11 @@ var Plottable; var singleDatumAttributes = d3.keys(attrToProjector).filter(isSingleDatumAttr); singleDatumAttributes.forEach(function (attribute) { var projector = attrToProjector[attribute]; - attrToProjector[attribute] = function (data, i) { return data.length > 0 ? projector(data[0], i) : null; }; + attrToProjector[attribute] = function (data, i, u, m) { return data.length > 0 ? projector(data[0], i, u, m) : null; }; }); - var yAccessor = this._projectors["y"].accessor; - attrToProjector["y"] = function (d) { return _this._yScale.scale(+yAccessor(d) + d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; - attrToProjector["y0"] = function (d) { return _this._yScale.scale(d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; + var yAccessor = this._projections["y"].accessor; + attrToProjector["y"] = function (d, i, u, m) { return _this._yScale.scale(+yAccessor(d, i, u, m) + d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; + attrToProjector["y0"] = function (d, i, u, m) { return _this._yScale.scale(d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; return attrToProjector; }; StackedArea.prototype._wholeDatumAttributes = function () { @@ -8065,15 +8209,15 @@ var Plottable; var attrToProjector = Plot.AbstractBarPlot.prototype._generateAttrToProjector.apply(this); var primaryAttr = this._isVertical ? "y" : "x"; var primaryScale = this._isVertical ? this._yScale : this._xScale; - var primaryAccessor = this._projectors[primaryAttr].accessor; - var getStart = function (d) { return primaryScale.scale(d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; - var getEnd = function (d) { return primaryScale.scale(+primaryAccessor(d) + d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; - var heightF = function (d) { return Math.abs(getEnd(d) - getStart(d)); }; + var primaryAccessor = this._projections[primaryAttr].accessor; + var getStart = function (d, i, u, m) { return primaryScale.scale(d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; + var getEnd = function (d, i, u, m) { return primaryScale.scale(+primaryAccessor(d, i, u, m) + d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); }; + var heightF = function (d, i, u, m) { return Math.abs(getEnd(d, i, u, m) - getStart(d, i, u, m)); }; var widthF = attrToProjector["width"]; attrToProjector["height"] = this._isVertical ? heightF : widthF; attrToProjector["width"] = this._isVertical ? widthF : heightF; - var attrFunction = function (d) { return +primaryAccessor(d) < 0 ? getStart(d) : getEnd(d); }; - attrToProjector[primaryAttr] = function (d) { return _this._isVertical ? attrFunction(d) : attrFunction(d) - heightF(d); }; + var attrFunction = function (d, i, u, m) { return +primaryAccessor(d, i, u, m) < 0 ? getStart(d, i, u, m) : getEnd(d, i, u, m); }; + attrToProjector[primaryAttr] = function (d, i, u, m) { return _this._isVertical ? attrFunction(d, i, u, m) : attrFunction(d, i, u, m) - heightF(d, i, u, m); }; return attrToProjector; }; StackedBar.prototype._generateDrawSteps = function () { @@ -8304,7 +8448,7 @@ var Plottable; } var movingAttrProjector = attrToProjector[this.getMovingAttr()]; var growingAttrProjector = attrToProjector[this.getGrowingAttr()]; - return function (d, i) { return movingAttrProjector(d, i) + growingAttrProjector(d, i); }; + return function (d, i, u, m) { return movingAttrProjector(d, i, u, m) + growingAttrProjector(d, i, u, m); }; }; Rect.prototype.getGrowingAttr = function () { return this.isVertical ? "height" : "width"; @@ -8780,116 +8924,6 @@ var Plottable; var Interaction = Plottable.Interaction; })(Plottable || (Plottable = {})); -/// -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Plottable; -(function (Plottable) { - (function (Interaction) { - var BarHover = (function (_super) { - __extends(BarHover, _super); - function BarHover() { - _super.apply(this, arguments); - this.currentBar = null; - this._hoverMode = "point"; - } - BarHover.prototype._anchor = function (barPlot, hitBox) { - var _this = this; - _super.prototype._anchor.call(this, barPlot, hitBox); - Plottable._Util.Methods.warn("Interaction.BarHover is deprecated; please use Interaction.Hover instead"); - this.plotIsVertical = this._componentToListenTo._isVertical; - this.dispatcher = new Plottable.Dispatcher.Mouse(this._hitBox); - this.dispatcher.mousemove(function (p) { - var selectedBar = _this.getHoveredBar(p); - if (selectedBar == null) { - _this._hoverOut(); - } - else { - if (_this.currentBar != null) { - if (_this.currentBar.node() === selectedBar.node()) { - return; // no message if bar is the same - } - else { - _this._hoverOut(); - } - } - _this.getBars().classed("not-hovered", true).classed("hovered", false); - selectedBar.classed("not-hovered", false).classed("hovered", true); - if (_this.hoverCallback != null) { - _this.hoverCallback(selectedBar.data()[0], selectedBar); - } - } - _this.currentBar = selectedBar; - }); - this.dispatcher.mouseout(function (p) { return _this._hoverOut(); }); - this.dispatcher.connect(); - }; - BarHover.prototype.getBars = function () { - return this._componentToListenTo._renderArea.selectAll("rect"); - }; - BarHover.prototype._hoverOut = function () { - this.getBars().classed("not-hovered hovered", false); - if (this.unhoverCallback != null && this.currentBar != null) { - this.unhoverCallback(this.currentBar.data()[0], this.currentBar); // last known information - } - this.currentBar = null; - }; - BarHover.prototype.getHoveredBar = function (p) { - if (this._hoverMode === "point") { - return this._componentToListenTo.selectBar(p.x, p.y, false); - } - var maxExtent = { min: -Infinity, max: Infinity }; - if (this.plotIsVertical) { - return this._componentToListenTo.selectBar(p.x, maxExtent, false); - } - else { - return this._componentToListenTo.selectBar(maxExtent, p.y, false); - } - }; - BarHover.prototype.hoverMode = function (mode) { - if (mode == null) { - return this._hoverMode; - } - var modeLC = mode.toLowerCase(); - if (modeLC !== "point" && modeLC !== "line") { - throw new Error(mode + " is not a valid hover mode for Interaction.BarHover"); - } - this._hoverMode = modeLC; - return this; - }; - /** - * Attaches an callback to be called when the user mouses over a bar. - * - * @param {(datum: any, bar: D3.Selection) => any} callback The callback to be called. - * The callback will be passed the data from the hovered-over bar. - * @return {BarHover} The calling BarHover. - */ - BarHover.prototype.onHover = function (callback) { - this.hoverCallback = callback; - return this; - }; - /** - * Attaches a callback to be called when the user mouses off of a bar. - * - * @param {(datum: any, bar: D3.Selection) => any} callback The callback to be called. - * The callback will be passed the data from the last-hovered bar. - * @return {BarHover} The calling BarHover. - */ - BarHover.prototype.onUnhover = function (callback) { - this.unhoverCallback = callback; - return this; - }; - return BarHover; - })(Interaction.AbstractInteraction); - Interaction.BarHover = BarHover; - })(Plottable.Interaction || (Plottable.Interaction = {})); - var Interaction = Plottable.Interaction; -})(Plottable || (Plottable = {})); - /// var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -8909,8 +8943,9 @@ var Plottable; var _this = this; _super.call(this); this.dragInitialized = false; - this._origin = [0, 0]; - this._location = [0, 0]; + this.origin = [0, 0]; + this.location = [0, 0]; + this._isDragging = false; this.dragBehavior = d3.behavior.drag(); this.dragBehavior.on("dragstart", function () { return _this._dragstart(); }); this.dragBehavior.on("drag", function () { return _this._drag(); }); @@ -8925,6 +8960,21 @@ var Plottable; return this; } }; + // we access origin and location through setOrigin and setLocation so that on XDragBox and YDragBox we can overwrite so that + // we always have the uncontrolled dimension of the box extending across the entire component + // this ensures that the callback values are synchronized with the actual box being drawn + Drag.prototype._setOrigin = function (x, y) { + this.origin = [x, y]; + }; + Drag.prototype._getOrigin = function () { + return this.origin.slice(); + }; + Drag.prototype._setLocation = function (x, y) { + this.location = [x, y]; + }; + Drag.prototype._getLocation = function () { + return this.location.slice(); + }; Drag.prototype.drag = function (cb) { if (cb === undefined) { return this.ondrag; @@ -8944,46 +8994,44 @@ var Plottable; } }; Drag.prototype._dragstart = function () { + this._isDragging = true; var width = this._componentToListenTo.width(); var height = this._componentToListenTo.height(); // the constraint functions ensure that the selection rectangle will not exceed the hit box var constraintFunction = function (min, max) { return function (x) { return Math.min(Math.max(x, min), max); }; }; - this.constrainX = constraintFunction(0, width); - this.constrainY = constraintFunction(0, height); + this._constrainX = constraintFunction(0, width); + this._constrainY = constraintFunction(0, height); + var origin = d3.mouse(this._hitBox[0][0].parentNode); + this._setOrigin(origin[0], origin[1]); + this._doDragstart(); }; Drag.prototype._doDragstart = function () { if (this.ondragstart != null) { - this.ondragstart({ x: this._origin[0], y: this._origin[1] }); + this.ondragstart({ x: this._getOrigin()[0], y: this._getOrigin()[1] }); } }; Drag.prototype._drag = function () { - if (!this.dragInitialized) { - this._origin = [d3.event.x, d3.event.y]; - this.dragInitialized = true; - this._doDragstart(); - } - this._location = [this.constrainX(d3.event.x), this.constrainY(d3.event.y)]; + this._setLocation(this._constrainX(d3.event.x), this._constrainY(d3.event.y)); this._doDrag(); }; Drag.prototype._doDrag = function () { if (this.ondrag != null) { - var startLocation = { x: this._origin[0], y: this._origin[1] }; - var endLocation = { x: this._location[0], y: this._location[1] }; - this.ondrag(startLocation, endLocation); + var start = { x: this._getOrigin()[0], y: this._getOrigin()[1] }; + var end = { x: this._getLocation()[0], y: this._getLocation()[1] }; + this.ondrag(start, end); } }; Drag.prototype._dragend = function () { - if (!this.dragInitialized) { - return; - } - this.dragInitialized = false; + var location = d3.mouse(this._hitBox[0][0].parentNode); + this._setLocation(location[0], location[1]); + this._isDragging = false; this._doDragend(); }; Drag.prototype._doDragend = function () { if (this.ondragend != null) { - var startLocation = { x: this._origin[0], y: this._origin[1] }; - var endLocation = { x: this._location[0], y: this._location[1] }; - this.ondragend(startLocation, endLocation); + var start = { x: this._getOrigin()[0], y: this._getOrigin()[1] }; + var end = { x: this._getLocation()[0], y: this._getLocation()[1] }; + this.ondragend(start, end); } }; Drag.prototype._anchor = function (component, hitBox) { @@ -9047,23 +9095,148 @@ var __extends = this.__extends || function (d, b) { var Plottable; (function (Plottable) { (function (Interaction) { - /** - * A DragBox is an interaction that automatically draws a box across the - * element you attach it to when you drag. - */ var DragBox = (function (_super) { __extends(DragBox, _super); function DragBox() { _super.apply(this, arguments); - /** - * Whether or not dragBox has been rendered in a visible area. - */ - this.boxIsDrawn = false; + this._boxIsDrawn = false; + this._resizeXEnabled = false; + this._resizeYEnabled = false; + this.cursorStyle = ""; } + DragBox.prototype.resizeEnabled = function (enabled) { + if (enabled == null) { + return this._resizeXEnabled || this._resizeYEnabled; + } + else { + this._resizeXEnabled = enabled && this.constructor._CAN_RESIZE_X; + this._resizeYEnabled = enabled && this.constructor._CAN_RESIZE_Y; + return this; + } + }; + /** + * Return true if box is resizing on the X dimension. + * + * @returns {boolean} + */ + DragBox.prototype.isResizingX = function () { + return !!this.xResizing; + }; + /** + * Return true if box is resizing on the Y dimension. + * + * @returns {boolean} + */ + DragBox.prototype.isResizingY = function () { + return !!this.yResizing; + }; + /** + * Whether or not dragBox has been rendered in a visible area. + * + * @returns {boolean} + */ + DragBox.prototype.boxIsDrawn = function () { + return this._boxIsDrawn; + }; + /** + * Return true if box is resizing. + * + * @returns {boolean} + */ + DragBox.prototype.isResizing = function () { + return this.isResizingX() || this.isResizingY(); + }; DragBox.prototype._dragstart = function () { + var mouse = d3.mouse(this._hitBox[0][0].parentNode); + if (this.boxIsDrawn()) { + var resizeInfo = this.getResizeInfo(mouse[0], mouse[1]); + this.xResizing = resizeInfo.xResizing; + this.yResizing = resizeInfo.yResizing; + if (this.isResizing()) { + // we are resizing; don't clear the box, don't call the dragstart callback + return; + } + } _super.prototype._dragstart.call(this); this.clearBox(); }; + DragBox.prototype.getResizeInfo = function (xPosition, yPosition) { + var xResizing = null; + var yResizing = null; + var xStart = this._getOrigin()[0]; + var yStart = this._getOrigin()[1]; + var xEnd = this._getLocation()[0]; + var yEnd = this._getLocation()[1]; + function inPaddedRange(position, start, end, padding) { + return Math.min(start, end) - padding <= position && position <= Math.max(start, end) + padding; + } + function getResizeDimension(origin, destination, position, padding) { + // origin: where the drag began + // destination: where the drag ended + // position: where the cursor currently is (possibly the start of a resize) + var min = Math.min(origin, destination); + var max = Math.max(origin, destination); + var interiorPadding = Math.min(padding, (max - min) / 2); + if (min - padding < position && position < min + interiorPadding) { + return { offset: position - min, positive: false, origin: origin === min }; + } + if (max - interiorPadding < position && position < max + padding) { + return { offset: position - max, positive: true, origin: origin === max }; + } + return null; + } + if (this._resizeXEnabled && inPaddedRange(yPosition, yStart, yEnd, DragBox.RESIZE_PADDING)) { + xResizing = getResizeDimension(xStart, xEnd, xPosition, DragBox.RESIZE_PADDING); + } + if (this._resizeYEnabled && inPaddedRange(xPosition, xStart, xEnd, DragBox.RESIZE_PADDING)) { + yResizing = getResizeDimension(yStart, yEnd, yPosition, DragBox.RESIZE_PADDING); + } + return { xResizing: xResizing, yResizing: yResizing }; + }; + DragBox.prototype._drag = function () { + if (this.isResizing()) { + // Eases the mouse into the center of the dragging line, in case dragging started with the mouse + // away from the center due to `DragBox.RESIZE_PADDING`. + if (this.isResizingX()) { + var diffX = this.xResizing.offset; + var x = d3.event.x; + if (diffX !== 0) { + x += diffX; + this.xResizing.offset += diffX > 0 ? -1 : 1; + } + if (this.xResizing.origin) { + this._setOrigin(this._constrainX(x), this._getOrigin()[1]); + } + else { + this._setLocation(this._constrainX(x), this._getLocation()[1]); + } + } + if (this.isResizingY()) { + var diffY = this.yResizing.offset; + var y = d3.event.y; + if (diffY !== 0) { + y += diffY; + this.yResizing.offset += diffY > 0 ? -1 : 1; + } + if (this.yResizing.origin) { + this._setOrigin(this._getOrigin()[0], this._constrainY(y)); + } + else { + this._setLocation(this._getLocation()[0], this._constrainY(y)); + } + } + this._doDrag(); + } + else { + _super.prototype._drag.call(this); + } + this.setBox(this._getOrigin()[0], this._getLocation()[0], this._getOrigin()[1], this._getLocation()[1]); + }; + DragBox.prototype._dragend = function () { + this.xResizing = null; + this.yResizing = null; + _super.prototype._dragend.call(this); + }; /** * Clears the highlighted drag-selection box drawn by the DragBox. * @@ -9074,7 +9247,7 @@ var Plottable; return; } // HACKHACK #593 this.dragBox.attr("height", 0).attr("width", 0); - this.boxIsDrawn = false; + this._boxIsDrawn = false; return this; }; /** @@ -9096,17 +9269,54 @@ var Plottable; var xo = Math.min(x0, x1); var yo = Math.min(y0, y1); this.dragBox.attr({ x: xo, y: yo, width: w, height: h }); - this.boxIsDrawn = (w > 0 && h > 0); + this._boxIsDrawn = (w > 0 && h > 0); return this; }; DragBox.prototype._anchor = function (component, hitBox) { + var _this = this; _super.prototype._anchor.call(this, component, hitBox); var cname = DragBox.CLASS_DRAG_BOX; var background = this._componentToListenTo._backgroundContainer; this.dragBox = background.append("rect").classed(cname, true).attr("x", 0).attr("y", 0); + hitBox.on("mousemove", function () { return _this._hover(); }); return this; }; + DragBox.prototype._hover = function () { + if (this.resizeEnabled() && !this._isDragging && this._boxIsDrawn) { + var position = d3.mouse(this._hitBox[0][0].parentNode); + this.cursorStyle = this.getCursorStyle(position[0], position[1]); + } + else if (!this._boxIsDrawn) { + this.cursorStyle = ""; + } + this._hitBox.style("cursor", this.cursorStyle); + }; + DragBox.prototype.getCursorStyle = function (xOrigin, yOrigin) { + var resizeInfo = this.getResizeInfo(xOrigin, yOrigin); + var left = resizeInfo.xResizing && !resizeInfo.xResizing.positive; + var right = resizeInfo.xResizing && resizeInfo.xResizing.positive; + var top = resizeInfo.yResizing && !resizeInfo.yResizing.positive; + var bottom = resizeInfo.yResizing && resizeInfo.yResizing.positive; + if (left && top || bottom && right) { + return "nwse-resize"; + } + else if (top && right || bottom && left) { + return "nesw-resize"; + } + else if (left || right) { + return "ew-resize"; + } + else if (top || bottom) { + return "ns-resize"; + } + else { + return ""; + } + }; DragBox.CLASS_DRAG_BOX = "drag-box"; + DragBox.RESIZE_PADDING = 10; + DragBox._CAN_RESIZE_X = true; + DragBox._CAN_RESIZE_Y = true; return DragBox; })(Interaction.Drag); Interaction.DragBox = DragBox; @@ -9129,14 +9339,13 @@ var Plottable; function XDragBox() { _super.apply(this, arguments); } - XDragBox.prototype._drag = function () { - _super.prototype._drag.call(this); - this.setBox(this._origin[0], this._location[0]); + XDragBox.prototype._setOrigin = function (x, y) { + _super.prototype._setOrigin.call(this, x, 0); }; - XDragBox.prototype.setBox = function (x0, x1) { - _super.prototype.setBox.call(this, x0, x1, 0, this._componentToListenTo.height()); - return this; + XDragBox.prototype._setLocation = function (x, y) { + _super.prototype._setLocation.call(this, x, this._componentToListenTo.height()); }; + XDragBox._CAN_RESIZE_Y = false; return XDragBox; })(Interaction.DragBox); Interaction.XDragBox = XDragBox; @@ -9157,12 +9366,9 @@ var Plottable; var XYDragBox = (function (_super) { __extends(XYDragBox, _super); function XYDragBox() { - _super.apply(this, arguments); + Plottable._Util.Methods.warn("XYDragBox is deprecated; use DragBox instead"); + _super.call(this); } - XYDragBox.prototype._drag = function () { - _super.prototype._drag.call(this); - this.setBox(this._origin[0], this._location[0], this._origin[1], this._location[1]); - }; return XYDragBox; })(Interaction.DragBox); Interaction.XYDragBox = XYDragBox; @@ -9185,14 +9391,13 @@ var Plottable; function YDragBox() { _super.apply(this, arguments); } - YDragBox.prototype._drag = function () { - _super.prototype._drag.call(this); - this.setBox(this._origin[1], this._location[1]); + YDragBox.prototype._setOrigin = function (x, y) { + _super.prototype._setOrigin.call(this, 0, y); }; - YDragBox.prototype.setBox = function (y0, y1) { - _super.prototype.setBox.call(this, 0, this._componentToListenTo.width(), y0, y1); - return this; + YDragBox.prototype._setLocation = function (x, y) { + _super.prototype._setLocation.call(this, this._componentToListenTo.width(), y); }; + YDragBox._CAN_RESIZE_X = false; return YDragBox; })(Interaction.DragBox); Interaction.YDragBox = YDragBox; diff --git a/plottable.min.js b/plottable.min.js index 70db948f2a..c2eac8e9c1 100644 --- a/plottable.min.js +++ b/plottable.min.js @@ -1,5 +1,5 @@ -var Plottable;!function(a){!function(b){!function(b){function c(a,b,c){return Math.min(b,c)<=a&&a<=Math.max(b,c)}function d(b){a.Config.SHOW_WARNINGS&&null!=window.console&&(null!=window.console.warn?console.warn(b):null!=window.console.log&&console.log(b))}function e(a,b){if(a.length!==b.length)throw new Error("attempted to add arrays of unequal length");return a.map(function(c,d){return a[d]+b[d]})}function f(a,b){var c=d3.set();return a.forEach(function(a){b.has(a)&&c.add(a)}),c}function g(a){return"function"==typeof a?a:"string"==typeof a&&"#"!==a[0]?function(b){return b[a]}:function(){return a}}function h(a,b){var c=g(a);return function(a,d){var e=b.datasets(),f=e.length>0?e[0]:null,g=f?f.metadata():null;return c(a,d,g)}}function i(a,b){var c=d3.set();return a.forEach(function(a){return c.add(a)}),b.forEach(function(a){return c.add(a)}),c}function j(a,b){var c=d3.map();return a.forEach(function(a,d){c.set(a,b(a,d))}),c}function k(a){var b=d3.set(),c=[];return a.forEach(function(a){b.has(a)||(b.add(a),c.push(a))}),c}function l(a,b){for(var c=[],d=0;b>d;d++)c[d]="function"==typeof a?a(d):a;return c}function m(a){return Array.prototype.concat.apply([],a)}function n(a,b){if(null==a||null==b)return a===b;if(a.length!==b.length)return!1;for(var c=0;cf;++f)e[f]=a+c*f;return e}function t(a,b){for(var c=[],d=2;db?"0"+c:c});if(4===d.length&&"00"===d[3])return null;var e="#"+d.join("");return a.classed(b,!1),e}b.inRange=c,b.warn=d,b.addArrays=e,b.intersection=f,b.accessorize=g,b._applyAccessor=h,b.union=i,b.populateMap=j,b.uniq=k,b.createFilledArray=l,b.flatten=m,b.arrayEq=n,b.objEq=o,b.max=p,b.min=q,b.copyMap=r,b.range=s,b.setTimeout=t,b.colorTest=u}(b.Methods||(b.Methods={}));b.Methods}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a,b,c){for(var d=0,e=b.length;e>d;){var f=d+e>>>1,g=null==c?b[f]:c(b[f]);a>g?d=f+1:e=f}return d}a.sortedIndex=b}(a.OpenSource||(a.OpenSource={}));a.OpenSource}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.counter={}}return a.prototype.setDefault=function(a){null==this.counter[a]&&(this.counter[a]=0)},a.prototype.increment=function(a){return this.setDefault(a),++this.counter[a]},a.prototype.decrement=function(a){return this.setDefault(a),--this.counter[a]},a.prototype.get=function(a){return this.setDefault(a),this.counter[a]},a}();a.IDCounter=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.keyValuePairs=[]}return a.prototype.set=function(a,b){if(a!==a)throw new Error("NaN may not be used as a key to the StrictEqualityAssociativeArray");for(var c=0;cb){var h=e("."),i=Math.floor(b/h);return"...".substr(0,i)}for(;f+g>b;)d=d.substr(0,d.length-1).trim(),f=e(d);if(e(d+"...")>b)throw new Error("addEllipsesToLine failed :(");return d+"..."}function i(b,c,d,e,f,g){void 0===f&&(f="left"),void 0===g&&(g="top");var h={left:0,center:.5,right:1},i={top:0,center:.5,bottom:1};if(void 0===h[f]||void 0===i[g])throw new Error("unrecognized alignment x:"+f+", y:"+g);var j=c.append("g"),k=j.append("text");k.text(b);var l=a.DOM.getBBox(k),m=l.height,n=l.width;if(n>d||m>e)return a.Methods.warn("Insufficient space to fit text: "+b),k.text(""),{width:0,height:0};var o={left:"start",center:"middle",right:"end"},p=o[f],q=d*h[f],r=e*i[g],s=.85-i[g];return k.attr("text-anchor",p).attr("y",s+"em"),a.DOM.translate(j,q,r),{width:n,height:m}}function j(a,b,c,d,e,f,g){if(void 0===e&&(e="left"),void 0===f&&(f="top"),void 0===g&&(g="right"),"right"!==g&&"left"!==g)throw new Error("unrecognized rotation: "+g);var h="right"===g,j={left:"bottom",right:"top",center:"center",top:"left",bottom:"right"},k={left:"top",right:"bottom",center:"center",top:"right",bottom:"left"},l=h?j:k,m=b.append("g"),n=i(a,m,d,c,l[f],l[e]),o=d3.transform("");return o.rotate="right"===g?90:-90,o.translate=[h?c:0,h?0:d],m.attr("transform",o.toString()),m.classed("rotated-"+g,!0),{width:n.height,height:n.width}}function k(d,e,f,g,h,j){void 0===h&&(h="left"),void 0===j&&(j="top");var k=c(e.append("text"))(b.HEIGHT_TEXT).height,l=0,m=e.append("g");d.forEach(function(b,c){var d=m.append("g");a.DOM.translate(d,0,c*k);var e=i(b,d,f,k,h,j);e.width>l&&(l=e.width)});var n=k*d.length,o=g-n,p={center:.5,top:0,bottom:1};return a.DOM.translate(m,0,o*p[j]),{width:l,height:n}}function l(d,e,f,g,h,i,k){void 0===h&&(h="left"),void 0===i&&(i="top"),void 0===k&&(k="left");var l=c(e.append("text"))(b.HEIGHT_TEXT).height,m=0,n=e.append("g");d.forEach(function(b,c){var d=n.append("g");a.DOM.translate(d,c*l,0);var e=j(b,d,l,g,h,i,k);e.height>m&&(m=e.height)});var o=l*d.length,p=f-o,q={center:.5,left:0,right:1};return a.DOM.translate(n,p*q[h],0),{width:o,height:m}}function m(b,c,d,e,f,g){if(void 0===f&&(f="horizontal"),-1===["left","right","horizontal"].indexOf(f))throw new Error("Unrecognized orientation to writeText: "+f);var h="horizontal"===f,i=h?c:d,j=h?d:c,m=a.WordWrap.breakTextToFitRect(b,i,j,e);if(0===m.lines.length)return{textFits:m.textFits,usedWidth:0,usedHeight:0};var n,o;if(null==g){var p=h?a.Methods.max:d3.sum,q=h?d3.sum:a.Methods.max,r=function(a){return h?e(a).height:e(a).width},s=function(a){return h?e(a).width:e(a).height};n=p(m.lines,s,0),o=q(m.lines,r,0)}else{var t=g.g.append("g").classed("writeText-inner-g",!0),u=h?k:l,v=u.call(this,m.lines,t,c,d,g.xAlign,g.yAlign,f);n=v.width,o=v.height}return{textFits:m.textFits,usedWidth:n,usedHeight:o}}b.HEIGHT_TEXT="bqpdl",b.getTextMeasurer=c;var n="a",o=function(){function b(b){var g=this;this.cache=new a.Cache(c(b),n,a.Methods.objEq),this.measure=d(e(f(function(a){return g.cache.get(a)})))}return b.prototype.clear=function(){return this.cache.clear(),this},b}();b.CachingCharacterMeasurer=o,b.getTruncatedText=g,b.addEllipsesToLine=h,b.writeLineHorizontally=i,b.writeLineVertically=j,b.writeText=m}(a.Text||(a.Text={}));a.Text}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(b){function c(b,c,e,f){var g=function(a){return f(a).width},h=d(b,c,g),i=f("hello world").height,j=Math.floor(e/i),k=j>=h.length;return k||(h=h.splice(0,j),j>0&&(h[j-1]=a.Text.addEllipsesToLine(h[j-1],c,f))),{originalText:b,lines:h,textFits:k}}function d(a,b,c){for(var d=[],e=a.split("\n"),g=0,h=e.length;h>g;g++){var i=e[g];null!==i?d=d.concat(f(i,b,c)):d.push("")}return d}function e(b,c,d){var e=h(b),f=e.map(d),g=a.Methods.max(f,0);return c>=g}function f(a,b,c){for(var d,e=[],f=h(a),i="",j=0;d||je;e++){var g=a[e];""===c||j(c[0],g,d)?c+=g:(b.push(c),c=g),d=g}return c&&b.push(c),b}function i(a){return null==a?!0:""===a.trim()}function j(a,b,c){return m.test(a)&&m.test(b)?!0:m.test(a)||m.test(b)?!1:l.test(c)||k.test(b)?!1:!0}var k=/[{\[]/,l=/[!"%),-.:;?\]}]/,m=/^\s+$/;b.breakTextToFitRect=c,b.canWrapWithoutBreakingWords=e}(a.WordWrap||(a.WordWrap={}));a.WordWrap}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b;try{b=a.node().getBBox()}catch(c){b={x:0,y:0,width:0,height:0}}return b}function c(b){null!=window.requestAnimationFrame?window.requestAnimationFrame(b):setTimeout(b,a.POLYFILL_TIMEOUT_MSEC)}function d(a,b){var c=a.getPropertyValue(b),d=parseFloat(c);return d!==d?0:d}function e(a){for(var b=a.node();null!==b&&"svg"!==b.nodeName;)b=b.parentNode;return null==b}function f(a){var b=window.getComputedStyle(a);return d(b,"width")+d(b,"padding-left")+d(b,"padding-right")+d(b,"border-left-width")+d(b,"border-right-width")}function g(a){var b=window.getComputedStyle(a);return d(b,"height")+d(b,"padding-top")+d(b,"padding-bottom")+d(b,"border-top-width")+d(b,"border-bottom-width")}function h(a){var b=a.node().clientWidth;if(0===b){var c=a.attr("width");if(-1!==c.indexOf("%")){for(var d=a.node().parentNode;null!=d&&0===d.clientWidth;)d=d.parentNode;if(null==d)throw new Error("Could not compute width of element");b=d.clientWidth*parseFloat(c)/100}else b=parseFloat(c)}return b}function i(a,b,c){var d=d3.transform(a.attr("transform"));return null==b?d.translate:(c=null==c?0:c,d.translate[0]=b,d.translate[1]=c,a.attr("transform",d.toString()),a)}function j(a,b){return a.rightb.right?!1:a.bottomb.bottom?!1:!0}a.getBBox=b,a.POLYFILL_TIMEOUT_MSEC=1e3/60,a.requestAnimationFramePolyfill=c,a.isSelectionRemovedFromSVG=e,a.getElementWidth=f,a.getElementHeight=g,a.getSVGPixelWidth=h,a.translate=i,a.boxesOverlap=j}(a.DOM||(a.DOM={}));a.DOM}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b=d3.rgb(a),c=function(a){return a/=255,.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4)},d=c(b.r),e=c(b.g),f=c(b.b);return.2126*d+.7152*e+.0722*f}function c(a,c){var d=b(a)+.05,e=b(c)+.05;return d>e?d/e:e/d}a.contrast=c}(a.Color||(a.Color={}));a.Color}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){a.MILLISECONDS_IN_ONE_DAY=864e5,function(b){function c(a,c,d){void 0===a&&(a=2),void 0===c&&(c="$"),void 0===d&&(d=!0);var e=b.fixed(a);return function(a){var b=e(Math.abs(a));return""!==b&&(d?b=c+b:b+=c,0>a&&(b="-"+b)),b}}function d(a){return void 0===a&&(a=3),k(a),function(b){return b.toFixed(a)}}function e(a){return void 0===a&&(a=3),k(a),function(b){if("number"==typeof b){var c=Math.pow(10,a);return String(Math.round(b*c)/c)}return String(b)}}function f(){return function(a){return String(a)}}function g(a){void 0===a&&(a=0);var c=b.fixed(a);return function(a){var b=100*a,d=a.toString(),e=Math.pow(10,d.length-(d.indexOf(".")+1));return b=parseInt((b*e).toString(),10)/e,c(b)+"%"}}function h(a){return void 0===a&&(a=3),k(a),function(b){return d3.format("."+a+"s")(b)}}function i(){var a=8,b={};return b[0]={format:".%L",filter:function(a){return 0!==a.getMilliseconds()}},b[1]={format:":%S",filter:function(a){return 0!==a.getSeconds()}},b[2]={format:"%I:%M",filter:function(a){return 0!==a.getMinutes()}},b[3]={format:"%I %p",filter:function(a){return 0!==a.getHours()}},b[4]={format:"%a %d",filter:function(a){return 0!==a.getDay()&&1!==a.getDate()}},b[5]={format:"%b %d",filter:function(a){return 1!==a.getDate()}},b[6]={format:"%b",filter:function(a){return 0!==a.getMonth()}},b[7]={format:"%Y",filter:function(){return!0}},function(c){for(var d=0;a>d;d++)if(b[d].filter(c))return d3.time.format(b[d].format)(c)}}function j(b,c,d){return void 0===b&&(b=0),void 0===c&&(c=a.MILLISECONDS_IN_ONE_DAY),void 0===d&&(d=""),function(a){var e=Math.round((a.valueOf()-b)/c);return e.toString()+d}}function k(a){if(0>a||a>20)throw new RangeError("Formatter precision must be between 0 and 20")}b.currency=c,b.fixed=d,b.general=e,b.identity=f,b.percentage=g,b.siSuffix=h,b.time=i,b.relativeDate=j}(a.Formatters||(a.Formatters={}));a.Formatters}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){a.SHOW_WARNINGS=!0}(a.Config||(a.Config={}));a.Config}(Plottable||(Plottable={}));var Plottable;!function(a){a.version="0.36.1"}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.CORAL_RED="#fd373e",a.INDIGO="#5279c7",a.ROBINS_EGG_BLUE="#06cccc",a.FERN="#63c261",a.BURNING_ORANGE="#ff7939",a.ROYAL_HEATH="#962565",a.CONIFER="#99ce50",a.CERISE_RED="#db2e65",a.BRIGHT_SUN="#fad419",a.JACARTA="#2c2b6f",a.PLOTTABLE_COLORS=[a.INDIGO,a.CORAL_RED,a.FERN,a.BRIGHT_SUN,a.JACARTA,a.BURNING_ORANGE,a.CERISE_RED,a.CONIFER,a.ROYAL_HEATH,a.ROBINS_EGG_BLUE],a}();a.Colors=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._plottableID=a.nextID++}return a.nextID=0,a}();a.PlottableObject=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this.key2callback=new a._Util.StrictEqualityAssociativeArray,this.listenable=c}return __extends(c,b),c.prototype.registerListener=function(a,b){return this.key2callback.set(a,b),this},c.prototype.broadcast=function(){for(var a=this,b=[],c=0;c0){var f=d.valueOf();return d instanceof Date?[f-b.ONE_DAY,f+b.ONE_DAY]:[f-b.PADDING_FOR_IDENTICAL_DOMAIN,f+b.PADDING_FOR_IDENTICAL_DOMAIN]}if(a.domain()[0]===a.domain()[1])return c;var g=this.padProportion/2,h=a.invert(a.scale(d)-(a.scale(e)-a.scale(d))*g),i=a.invert(a.scale(e)+(a.scale(e)-a.scale(d))*g),j=this.paddingExceptions.values().concat(this.unregisteredPaddingExceptions.values()),k=d3.set(j);return k.has(d)&&(h=d),k.has(e)&&(i=e),[h,i]},b.prototype.niceDomain=function(a,b){return this.doNice?a._niceDomain(b,this.niceCount):b},b.prototype.includeDomain=function(a){var b=this.includedValues.values().concat(this.unregisteredIncludedValues.values());return b.reduce(function(a,b){return[Math.min(a[0],b),Math.max(a[1],b)]},a)},b.PADDING_FOR_IDENTICAL_DOMAIN=1,b.ONE_DAY=864e5,b}();a.Domainer=b}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this._autoDomainAutomatically=!0,this.broadcaster=new a.Core.Broadcaster(this),this._rendererAttrID2Extent={},this._typeCoercer=function(a){return a},this._domainModificationInProgress=!1,this._d3Scale=c}return __extends(c,b),c.prototype._getAllExtents=function(){return d3.values(this._rendererAttrID2Extent)},c.prototype._getExtent=function(){return[]},c.prototype.autoDomain=function(){return this._autoDomainAutomatically=!0,this._setDomain(this._getExtent()),this},c.prototype._autoDomainIfAutomaticMode=function(){this._autoDomainAutomatically&&this.autoDomain()},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype.domain=function(a){return null==a?this._getDomain():(this._autoDomainAutomatically=!1,this._setDomain(a),this)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setDomain=function(a){this._domainModificationInProgress||(this._domainModificationInProgress=!0,this._d3Scale.domain(a),this.broadcaster.broadcast(),this._domainModificationInProgress=!1)},c.prototype.range=function(a){return null==a?this._d3Scale.range():(this._d3Scale.range(a),this)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._updateExtent=function(a,b,c){return this._rendererAttrID2Extent[a+b]=c,this._autoDomainIfAutomaticMode(),this},c.prototype._removeExtent=function(a,b){return delete this._rendererAttrID2Extent[a+b],this._autoDomainIfAutomaticMode(),this},c}(a.Core.PlottableObject);b.AbstractScale=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this,c),this._numTicks=10,this._PADDING_FOR_IDENTICAL_DOMAIN=1,this._userSetDomainer=!1,this._domainer=new a.Domainer,this._typeCoercer=function(a){return+a},this._tickGenerator=function(a){return a.getDefaultTicks()}}return __extends(c,b),c.prototype._getExtent=function(){return this._domainer.computeDomain(this._getAllExtents(),this)},c.prototype.invert=function(a){return this._d3Scale.invert(a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(c){var d=function(a){return a!==a||1/0===a||a===-1/0};return d(c[0])||d(c[1])?void a._Util.Methods.warn("Warning: QuantitativeScales cannot take NaN or Infinity as a domain value. Ignoring."):void b.prototype._setDomain.call(this,c)},c.prototype.interpolate=function(a){return null==a?this._d3Scale.interpolate():(this._d3Scale.interpolate(a),this)},c.prototype.rangeRound=function(a){return this._d3Scale.rangeRound(a),this},c.prototype.getDefaultTicks=function(){return this._d3Scale.ticks(this.numTicks())},c.prototype.clamp=function(a){return null==a?this._d3Scale.clamp():(this._d3Scale.clamp(a),this)},c.prototype.ticks=function(){return this._tickGenerator(this)},c.prototype.numTicks=function(a){return null==a?this._numTicks:(this._numTicks=a,this)},c.prototype._niceDomain=function(a,b){return this._d3Scale.copy().domain(a).nice(b).domain()},c.prototype.domainer=function(a){return null==a?this._domainer:(this._domainer=a,this._userSetDomainer=!0,this._autoDomainIfAutomaticMode(),this)},c.prototype._defaultExtent=function(){return[0,1]},c.prototype.tickGenerator=function(a){return null==a?this._tickGenerator:(this._tickGenerator=a,this)},c}(b.AbstractScale);b.AbstractQuantitative=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){a.call(this,null==b?d3.scale.linear():b)}return __extends(b,a),b.prototype.copy=function(){return new b(this._d3Scale.copy())},b}(a.AbstractQuantitative);a.Linear=b}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(d){b.call(this,null==d?d3.scale.log():d),c.warned||(c.warned=!0,a._Util.Methods.warn("Plottable.Scale.Log is deprecated. If possible, use Plottable.Scale.ModifiedLog instead."))}return __extends(c,b),c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){return[1,10]},c.warned=!1,c}(b.AbstractQuantitative);b.Log=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(void 0===a&&(a=10),b.call(this,d3.scale.linear()),this._showIntermediateTicks=!1,this.base=a,this.pivot=this.base,this.untransformedDomain=this._defaultExtent(),this._numTicks=10,1>=a)throw new Error("ModifiedLogScale: The base must be > 1")}return __extends(c,b),c.prototype.adjustedLog=function(a){var b=0>a?-1:1;return a*=b,aa?-1:1;return a*=b,a=Math.pow(this.base,a),a=d&&e>=a}),m=j.concat(l).concat(k);return m.length<=1&&(m=d3.scale.linear().domain([d,e]).ticks(b)),m},c.prototype.logTicks=function(b,c){var d=this,e=this.howManyTicks(b,c);if(0===e)return[];var f=Math.floor(Math.log(b)/Math.log(this.base)),g=Math.ceil(Math.log(c)/Math.log(this.base)),h=d3.range(g,f,-Math.ceil((g-f)/e)),i=this._showIntermediateTicks?Math.floor(e/h.length):1,j=d3.range(this.base,1,-(this.base-1)/i).map(Math.floor),k=a._Util.Methods.uniq(j),l=h.map(function(a){return k.map(function(b){return Math.pow(d.base,a-1)*b})}),m=a._Util.Methods.flatten(l),n=m.filter(function(a){return a>=b&&c>=a}),o=n.sort(function(a,b){return a-b});return o},c.prototype.howManyTicks=function(b,c){var d=this.adjustedLog(a._Util.Methods.min(this.untransformedDomain,0)),e=this.adjustedLog(a._Util.Methods.max(this.untransformedDomain,0)),f=this.adjustedLog(b),g=this.adjustedLog(c),h=(g-f)/(e-d),i=Math.ceil(h*this._numTicks);return i},c.prototype.copy=function(){return new c(this.base)},c.prototype._niceDomain=function(a){return a},c.prototype.showIntermediateTicks=function(a){return null==a?this._showIntermediateTicks:void(this._showIntermediateTicks=a)},c}(b.AbstractQuantitative);b.ModifiedLog=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(b.call(this,null==a?d3.scale.ordinal():a),this._range=[0,1],this._rangeType="bands",this._innerPadding=.3,this._outerPadding=.5,this._typeCoercer=function(a){return null!=a&&a.toString?a.toString():a},this._innerPadding>this._outerPadding)throw new Error("outerPadding must be >= innerPadding so cat axis bands work out reasonably")}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents();return a._Util.Methods.uniq(a._Util.Methods.flatten(b))},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(a){b.prototype._setDomain.call(this,a),this.range(this.range())},c.prototype.range=function(a){return null==a?this._range:(this._range=a,"points"===this._rangeType?this._d3Scale.rangePoints(a,2*this._outerPadding):"bands"===this._rangeType&&this._d3Scale.rangeBands(a,this._innerPadding,this._outerPadding),this)},c.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},c.prototype.innerPadding=function(){var a=this.domain(); -if(a.length<2)return 0;var b=Math.abs(this.scale(a[1])-this.scale(a[0]));return b-this.rangeBand()},c.prototype.fullBandStartAndWidth=function(a){var b=this.scale(a)-this.innerPadding()/2,c=this.rangeBand()+this.innerPadding();return[b,c]},c.prototype.rangeType=function(a,b,c){if(null==a)return this._rangeType;if("points"!==a&&"bands"!==a)throw new Error("Unsupported range type: "+a);return this._rangeType=a,null!=b&&(this._outerPadding=b),null!=c&&(this._innerPadding=c),this.range(this.range()),this.broadcaster.broadcast(),this},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c}(b.AbstractScale);b.Ordinal=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var d;switch(a){case null:case void 0:d=d3.scale.ordinal().range(c.getPlottableColors());break;case"Category10":case"category10":case"10":d=d3.scale.category10();break;case"Category20":case"category20":case"20":d=d3.scale.category20();break;case"Category20b":case"category20b":case"20b":d=d3.scale.category20b();break;case"Category20c":case"category20c":case"20c":d=d3.scale.category20c();break;default:throw new Error("Unsupported ColorScale type")}b.call(this,d)}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents(),c=[];return b.forEach(function(a){c=c.concat(a)}),a._Util.Methods.uniq(c)},c.getPlottableColors=function(){for(var b,c=[],d=d3.select("body").append("div"),e=0;null!==(b=a._Util.Methods.colorTest(d,"plottable-colors-"+e));)c.push(b),e++;return d.remove(),c},c}(b.AbstractScale);b.Color=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,null==a?d3.time.scale():a),this._typeCoercer=function(a){return a&&a._isAMomentObject||a instanceof Date?a:new Date(a)}}return __extends(c,b),c.prototype._tickInterval=function(a,b){var c=d3.time.scale();return c.domain(this.domain()),c.range(this.range()),c.ticks(a.range,b)},c.prototype._setDomain=function(a){return a=a.map(this._typeCoercer),b.prototype._setDomain.call(this,a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){var b=(new Date).valueOf(),c=b-a.MILLISECONDS_IN_ONE_DAY;return[c,b]},c}(b.AbstractQuantitative);b.Time=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,d){void 0===a&&(a="reds"),void 0===d&&(d="linear"),this._colorRange=this._resolveColorValues(a),this._scaleType=d,b.call(this,c.getD3InterpolatedScale(this._colorRange,this._scaleType))}return __extends(c,b),c.getD3InterpolatedScale=function(a,b){var d;switch(b){case"linear":d=d3.scale.linear();break;case"log":d=d3.scale.log();break;case"sqrt":d=d3.scale.sqrt();break;case"pow":d=d3.scale.pow()}if(null==d)throw new Error("unknown Quantitative scale type "+b);return d.range([0,1]).interpolate(c.interpolateColors(a))},c.interpolateColors=function(a){if(a.length<2)throw new Error("Color scale arrays must have at least two elements.");return function(){return function(b){b=Math.max(0,Math.min(1,b));var c=b*(a.length-1),d=Math.floor(c),e=Math.ceil(c),f=c-d;return d3.interpolateLab(a[d],a[e])(f)}}},c.prototype.colorRange=function(a){return null==a?this._colorRange:(this._colorRange=this._resolveColorValues(a),this._resetScale(),this)},c.prototype.scaleType=function(a){return null==a?this._scaleType:(this._scaleType=a,this._resetScale(),this)},c.prototype._resetScale=function(){this._d3Scale=c.getD3InterpolatedScale(this._colorRange,this._scaleType),this._autoDomainIfAutomaticMode(),this.broadcaster.broadcast()},c.prototype._resolveColorValues=function(a){return a instanceof Array?a:null!=c.COLOR_SCALES[a]?c.COLOR_SCALES[a]:c.COLOR_SCALES.reds},c.prototype.autoDomain=function(){var b=this._getAllExtents();return b.length>0&&this._setDomain([a._Util.Methods.min(b,function(a){return a[0]},0),a._Util.Methods.max(b,function(a){return a[1]},0)]),this},c.COLOR_SCALES={reds:["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],blues:["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],posneg:["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"]},c}(b.AbstractScale);b.InterpolatedColor=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(a){var b=this;if(this.rescaleInProgress=!1,null==a)throw new Error("ScaleDomainCoordinator requires scales to coordinate");this.scales=a,this.scales.forEach(function(a){return a.broadcaster.registerListener(b,function(a){return b.rescale(a)})})}return a.prototype.rescale=function(a){if(!this.rescaleInProgress){this.rescaleInProgress=!0;var b=a.domain();this.scales.forEach(function(a){return a.domain(b)}),this.rescaleInProgress=!1}},a}();a.ScaleDomainCoordinator=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){!function(b){function c(b){if(0>=b)throw new Error("interval must be positive number");return function(c){var d=c.domain(),e=Math.min(d[0],d[1]),f=Math.max(d[0],d[1]),g=Math.ceil(e/b)*b,h=Math.floor((f-g)/b)+1,i=e%b===0?[]:[e],j=a._Util.Methods.range(0,h).map(function(a){return g+a*b}),k=f%b===0?[]:[f];return i.concat(j).concat(k)}}function d(){return function(a){var b=a.getDefaultTicks();return b.filter(function(a,c){return a%1===0||0===c||c===b.length-1})}}b.intervalTickGenerator=c,b.integerTickGenerator=d}(b.TickGenerators||(b.TickGenerators={}));b.TickGenerators}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){var c=function(){function b(a){this.key=a}return b.prototype.setClass=function(a){return this._className=a,this},b.prototype.setup=function(a){this._renderArea=a},b.prototype.remove=function(){null!=this._renderArea&&this._renderArea.remove()},b.prototype._enterData=function(){},b.prototype._drawStep=function(){},b.prototype._numberOfAnimationIterations=function(a){return a.length},b.prototype.draw=function(b,c){var d=this;this._enterData(b);var e=this._numberOfAnimationIterations(b),f=0;return c.forEach(function(b){a._Util.Methods.setTimeout(function(){return d._drawStep(b)},f),f+=b.animator.getTiming(e)}),f},b}();b.AbstractDrawer=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments)}return __extends(c,b),c.prototype._enterData=function(a){b.prototype._enterData.call(this,a),this.pathSelection.datum(a)},c.prototype.setup=function(a){this.pathSelection=a.append("path").classed("line",!0).style({fill:"none","vector-effect":"non-scaling-stroke"}),b.prototype.setup.call(this,a)},c.prototype.createLine=function(a,b,c){return c||(c=function(){return!0}),d3.svg.line().x(a).y(b).defined(c)},c.prototype._numberOfAnimationIterations=function(){return 1},c.prototype._drawStep=function(c){{var d=(b.prototype._drawStep.call(this,c),a._Util.Methods.copyMap(c.attrToProjector)),e=d.x,f=d.y;d.defined}delete d.x,delete d.y,d.d=this.createLine(e,f,d.defined),d.defined&&delete d.defined,d.fill&&this.pathSelection.attr("fill",d.fill),c.animator.animate(this.pathSelection,d)},c}(b.AbstractDrawer);b.Line=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(){c.apply(this,arguments),this._drawLine=!0}return __extends(d,c),d.prototype._enterData=function(a){this._drawLine?c.prototype._enterData.call(this,a):b.AbstractDrawer.prototype._enterData.call(this,a),this.areaSelection.datum(a)},d.prototype.drawLine=function(a){return this._drawLine=a,this},d.prototype.setup=function(a){this.areaSelection=a.append("path").classed("area",!0).style({stroke:"none"}),this._drawLine?c.prototype.setup.call(this,a):b.AbstractDrawer.prototype.setup.call(this,a)},d.prototype.createArea=function(a,b,c,d){return d||(d=function(){return!0}),d3.svg.area().x(a).y0(b).y1(c).defined(d)},d.prototype._drawStep=function(d){this._drawLine?c.prototype._drawStep.call(this,d):b.AbstractDrawer.prototype._drawStep.call(this,d);{var e=a._Util.Methods.copyMap(d.attrToProjector),f=e.x,g=e.y0,h=e.y;e.defined}delete e.x,delete e.y0,delete e.y,e.d=this.createArea(f,g,h,e.defined),e.defined&&delete e.defined,e.fill&&this.areaSelection.attr("fill",e.fill),d.animator.animate(this.areaSelection,e)},d}(b.Line);b.Area=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments)}return __extends(c,b),c.prototype.svgElement=function(a){return this._svgElement=a,this},c.prototype._getDrawSelection=function(){return this._renderArea.selectAll(this._svgElement)},c.prototype._drawStep=function(a){b.prototype._drawStep.call(this,a);var c=this._getDrawSelection();a.attrToProjector.fill&&c.attr("fill",a.attrToProjector.fill),a.animator.animate(c,a.attrToProjector)},c.prototype._enterData=function(a){b.prototype._enterData.call(this,a);var c=this._getDrawSelection().data(a);c.enter().append(this._svgElement),null!=this._className&&c.classed(this._className,!0),c.exit().remove()},c.prototype.filterDefinedData=function(a,b){return b?a.filter(b):a},c.prototype.draw=function(c,d){var e=this,f=[];d.forEach(function(b,c){f[c]={animator:b.animator,attrToProjector:a._Util.Methods.copyMap(b.attrToProjector)}});var g=f.reduce(function(a,b){return e.filterDefinedData(a,b.attrToProjector.defined)},c);return f.forEach(function(a){a.attrToProjector.defined&&delete a.attrToProjector.defined}),b.prototype.draw.call(this,g,f)},c}(b.AbstractDrawer);b.Element=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=5,d=5,e=function(b){function e(a,c){b.call(this,a),this._someLabelsTooWide=!1,this.svgElement("rect"),this._isVertical=c}return __extends(e,b),e.prototype.setup=function(c){b.prototype.setup.call(this,c.append("g").classed("bar-area",!0)),this.textArea=c.append("g").classed("bar-label-text-area",!0),this.measurer=new a._Util.Text.CachingCharacterMeasurer(this.textArea.append("text")).measure},e.prototype.removeLabels=function(){this.textArea.selectAll("g").remove()},e.prototype.drawText=function(b,e){var f=this,g=b.map(function(b,g){var h=e.label(b,g).toString(),i=e.width(b,g),j=e.height(b,g),k=e.x(b,g),l=e.y(b,g),m=e.positive(b,g),n=f.measurer(h),o=e.fill(b,g),p=1.6*a._Util.Color.contrast("white",o)t;if(n.height<=j&&n.width<=i){var v=Math.min((q-r)/2,c);m||(v=-1*v),f._isVertical?l+=v:k+=v;var w=f.textArea.append("g").attr("transform","translate("+k+","+l+")"),x=p?"dark-label":"light-label";w.classed(x,!0);var y,z;f._isVertical?(y="center",z=m?"top":"bottom"):(y=m?"left":"right",z="center"),a._Util.Text.writeLineHorizontally(h,w,i,j,y,z)}return u});this._someLabelsTooWide=g.some(function(a){return a})},e}(b.Element);b.Rect=e}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,a),this._svgElement="path"}return __extends(c,b),c.prototype.createArc=function(a,b){return d3.svg.arc().innerRadius(a).outerRadius(b)},c.prototype.retargetProjectors=function(a){var b={};return d3.entries(a).forEach(function(a){b[a.key]=function(b,c){return a.value(b.data,c)}}),b},c.prototype._drawStep=function(c){var d=a._Util.Methods.copyMap(c.attrToProjector);d=this.retargetProjectors(d);var e=d["inner-radius"],f=d["outer-radius"];return delete d["inner-radius"],delete d["outer-radius"],d.d=this.createArc(e,f),b.prototype._drawStep.call(this,{attrToProjector:d,animator:c.animator})},c.prototype.draw=function(a,c){var d=c[0].attrToProjector.value,e=d3.layout.pie().sort(null).value(d)(a);return c.forEach(function(a){return delete a.attrToProjector.value}),b.prototype.draw.call(this,e,c)},c}(b.Element);b.Arc=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.clipPathEnabled=!1,this._xAlignProportion=0,this._yAlignProportion=0,this._fixedHeightFlag=!1,this._fixedWidthFlag=!1,this._isSetup=!1,this._isAnchored=!1,this.interactionsToRegister=[],this.boxes=[],this.isTopLevelComponent=!1,this._width=0,this._height=0,this._xOffset=0,this._yOffset=0,this.cssClasses=["component"],this.removed=!1,this._autoResize=c.AUTORESIZE_BY_DEFAULT}return __extends(c,b),c.prototype._anchor=function(a){if(this.removed)throw new Error("Can't reuse remove()-ed components!");"svg"===a.node().nodeName&&(this.rootSVG=a,this.rootSVG.classed("plottable",!0),this.rootSVG.style("overflow","visible"),this.isTopLevelComponent=!0),null!=this._element?a.node().appendChild(this._element.node()):(this._element=a.append("g"),this._setup()),this._isAnchored=!0},c.prototype._setup=function(){var a=this;this._isSetup||(this.cssClasses.forEach(function(b){a._element.classed(b,!0)}),this.cssClasses=null,this._backgroundContainer=this._element.append("g").classed("background-container",!0),this._content=this._element.append("g").classed("content",!0),this._foregroundContainer=this._element.append("g").classed("foreground-container",!0),this.boxContainer=this._element.append("g").classed("box-container",!0),this.clipPathEnabled&&this.generateClipPath(),this.addBox("bounding-box"),this.interactionsToRegister.forEach(function(b){return a.registerInteraction(b)}),this.interactionsToRegister=null,this.isTopLevelComponent&&this.autoResize(this._autoResize),this._isSetup=!0)},c.prototype._requestedSpace=function(){return{width:0,height:0,wantsWidth:!1,wantsHeight:!1}},c.prototype._computeLayout=function(b,c,d,e){var f=this;if(null==b||null==c||null==d||null==e){if(null==this._element)throw new Error("anchor must be called before computeLayout");if(!this.isTopLevelComponent)throw new Error("null arguments cannot be passed to _computeLayout() on a non-root node");b=0,c=0,null==this.rootSVG.attr("width")&&this.rootSVG.attr("width","100%"),null==this.rootSVG.attr("height")&&this.rootSVG.attr("height","100%");var g=this.rootSVG.node();d=a._Util.DOM.getElementWidth(g),e=a._Util.DOM.getElementHeight(g)}this.xOrigin=b,this.yOrigin=c;var h=this._requestedSpace(d,e);this._width=this._isFixedWidth()?Math.min(d,h.width):d,this._height=this._isFixedHeight()?Math.min(e,h.height):e;var i=this.xOrigin+this._xOffset,j=this.yOrigin+this._yOffset;i+=(d-this.width())*this._xAlignProportion,j+=(e-h.height)*this._yAlignProportion,this._element.attr("transform","translate("+i+","+j+")"),this.boxes.forEach(function(a){return a.attr("width",f.width()).attr("height",f.height())})},c.prototype._render=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToRender(this)},c.prototype._scheduleComputeLayout=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToComputeLayout(this)},c.prototype._doRender=function(){},c.prototype._invalidateLayout=function(){this._isAnchored&&this._isSetup&&(this.isTopLevelComponent?this._scheduleComputeLayout():this._parent._invalidateLayout())},c.prototype.renderTo=function(b){if(null!=b){var c;if(c="function"==typeof b.node?b:d3.select(b),!c.node()||"svg"!==c.node().nodeName)throw new Error("Plottable requires a valid SVG to renderTo");this._anchor(c)}if(null==this._element)throw new Error("If a component has never been rendered before, then renderTo must be given a node to render to, or a D3.Selection, or a selector string");return this._computeLayout(),this._render(),a.Core.RenderController.flush(),this},c.prototype.resize=function(a,b){if(!this.isTopLevelComponent)throw new Error("Cannot resize on non top-level component");return null!=a&&null!=b&&this._isAnchored&&this.rootSVG.attr({width:a,height:b}),this._invalidateLayout(),this},c.prototype.autoResize=function(b){return b?a.Core.ResizeBroadcaster.register(this):a.Core.ResizeBroadcaster.deregister(this),this._autoResize=b,this},c.prototype.xAlign=function(a){if(a=a.toLowerCase(),"left"===a)this._xAlignProportion=0;else if("center"===a)this._xAlignProportion=.5;else{if("right"!==a)throw new Error("Unsupported alignment");this._xAlignProportion=1}return this._invalidateLayout(),this},c.prototype.yAlign=function(a){if(a=a.toLowerCase(),"top"===a)this._yAlignProportion=0;else if("center"===a)this._yAlignProportion=.5;else{if("bottom"!==a)throw new Error("Unsupported alignment");this._yAlignProportion=1}return this._invalidateLayout(),this},c.prototype.xOffset=function(a){return this._xOffset=a,this._invalidateLayout(),this},c.prototype.yOffset=function(a){return this._yOffset=a,this._invalidateLayout(),this},c.prototype.addBox=function(a,b){if(null==this._element)throw new Error("Adding boxes before anchoring is currently disallowed");var b=null==b?this.boxContainer:b,c=b.append("rect");return null!=a&&c.classed(a,!0),this.boxes.push(c),null!=this.width()&&null!=this.height()&&c.attr("width",this.width()).attr("height",this.height()),c},c.prototype.generateClipPath=function(){var a=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;a=a.split("#")[0],this._element.attr("clip-path",'url("'+a+"#clipPath"+this._plottableID+'")');var b=this.boxContainer.append("clipPath").attr("id","clipPath"+this._plottableID);this.addBox("clip-rect",b)},c.prototype.registerInteraction=function(a){return this._element?(this.hitBox||(this.hitBox=this.addBox("hit-box"),this.hitBox.style("fill","#ffffff").style("opacity",0)),a._anchor(this,this.hitBox)):this.interactionsToRegister.push(a),this},c.prototype.classed=function(a,b){if(null==b)return null==a?!1:null==this._element?-1!==this.cssClasses.indexOf(a):this._element.classed(a);if(null==a)return this;if(null==this._element){var c=this.cssClasses.indexOf(a);b&&-1===c?this.cssClasses.push(a):b||-1===c||this.cssClasses.splice(c,1)}else this._element.classed(a,b);return this},c.prototype._isFixedWidth=function(){return this._fixedWidthFlag},c.prototype._isFixedHeight=function(){return this._fixedHeightFlag},c.prototype.merge=function(b){var c;if(this._isSetup||this._isAnchored)throw new Error("Can't presently merge a component that's already been anchored");return a.Component.Group.prototype.isPrototypeOf(b)?(c=b,c._addComponent(this,!0),c):c=new a.Component.Group([this,b])},c.prototype.detach=function(){return this._isAnchored&&this._element.remove(),null!=this._parent&&this._parent._removeComponent(this),this._isAnchored=!1,this._parent=null,this},c.prototype.remove=function(){this.removed=!0,this.detach(),a.Core.ResizeBroadcaster.deregister(this)},c.prototype.width=function(){return this._width},c.prototype.height=function(){return this._height},c.AUTORESIZE_BY_DEFAULT=!0,c}(a.Core.PlottableObject);b.AbstractComponent=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this._components=[]}return __extends(b,a),b.prototype._anchor=function(b){var c=this;a.prototype._anchor.call(this,b),this._components.forEach(function(a){return a._anchor(c._content)})},b.prototype._render=function(){this._components.forEach(function(a){return a._render()})},b.prototype._removeComponent=function(a){var b=this._components.indexOf(a);b>=0&&(this._components.splice(b,1),this._invalidateLayout())},b.prototype._addComponent=function(a,b){return void 0===b&&(b=!1),!a||this._components.indexOf(a)>=0?!1:(b?this._components.unshift(a):this._components.push(a),a._parent=this,this._isAnchored&&a._anchor(this._content),this._invalidateLayout(),!0)},b.prototype.components=function(){return this._components.slice()},b.prototype.empty=function(){return 0===this._components.length},b.prototype.detachAll=function(){return this._components.slice().forEach(function(a){return a.detach()}),this},b.prototype.remove=function(){a.prototype.remove.call(this),this._components.slice().forEach(function(a){return a.remove()})},b}(a.AbstractComponent);a.AbstractComponentContainer=b}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.classed("component-group",!0),a.forEach(function(a){return c._addComponent(a)})}return __extends(c,b),c.prototype._requestedSpace=function(b,c){var d=this._components.map(function(a){return a._requestedSpace(b,c)});return{width:a._Util.Methods.max(d,function(a){return a.width},0),height:a._Util.Methods.max(d,function(a){return a.height},0),wantsWidth:d.map(function(a){return a.wantsWidth}).some(function(a){return a}),wantsHeight:d.map(function(a){return a.wantsHeight}).some(function(a){return a})}},c.prototype.merge=function(a){return this._addComponent(a),this},c.prototype._computeLayout=function(a,c,d,e){var f=this;return b.prototype._computeLayout.call(this,a,c,d,e),this._components.forEach(function(a){a._computeLayout(0,0,f.width(),f.height())}),this},c.prototype._isFixedWidth=function(){return this._components.every(function(a){return a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return this._components.every(function(a){return a._isFixedHeight()})},c}(b.AbstractComponentContainer);b.Group=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){var f=this;if(void 0===e&&(e=a.Formatters.identity()),b.call(this),this._endTickLength=5,this._tickLength=5,this._tickLabelPadding=10,this._gutter=15,this._showEndTickLabels=!1,null==c||null==d)throw new Error("Axis requires a scale and orientation");this._scale=c,this.orient(d),this._setDefaultAlignment(),this.classed("axis",!0),this._isHorizontal()?this.classed("x-axis",!0):this.classed("y-axis",!0),this.formatter(e),this._scale.broadcaster.registerListener(this,function(){return f._rescale()})}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this._scale.broadcaster.deregisterListener(this)},c.prototype._isHorizontal=function(){return"top"===this._orientation||"bottom"===this._orientation},c.prototype._computeWidth=function(){return this._computedWidth=this._maxLabelTickLength(),this._computedWidth},c.prototype._computeHeight=function(){return this._computedHeight=this._maxLabelTickLength(),this._computedHeight},c.prototype._requestedSpace=function(a,b){var c=0,d=0;return this._isHorizontal()?(null==this._computedHeight&&this._computeHeight(),d=this._computedHeight+this._gutter):(null==this._computedWidth&&this._computeWidth(),c=this._computedWidth+this._gutter),{width:c,height:d,wantsWidth:!this._isHorizontal()&&c>a,wantsHeight:this._isHorizontal()&&d>b}},c.prototype._isFixedHeight=function(){return this._isHorizontal()},c.prototype._isFixedWidth=function(){return!this._isHorizontal()},c.prototype._rescale=function(){this._render()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._scale.range(this._isHorizontal()?[0,this.width()]:[this.height(),0])},c.prototype._setup=function(){b.prototype._setup.call(this),this._tickMarkContainer=this._content.append("g").classed(c.TICK_MARK_CLASS+"-container",!0),this._tickLabelContainer=this._content.append("g").classed(c.TICK_LABEL_CLASS+"-container",!0),this._baseline=this._content.append("line").classed("baseline",!0)},c.prototype._getTickValues=function(){return[]},c.prototype._doRender=function(){var a=this._getTickValues(),b=this._tickMarkContainer.selectAll("."+c.TICK_MARK_CLASS).data(a);b.enter().append("line").classed(c.TICK_MARK_CLASS,!0),b.attr(this._generateTickMarkAttrHash()),d3.select(b[0][0]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),d3.select(b[0][a.length-1]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),b.exit().remove(),this._baseline.attr(this._generateBaselineAttrHash())},c.prototype._generateBaselineAttrHash=function(){var a={x1:0,y1:0,x2:0,y2:0};switch(this._orientation){case"bottom":a.x2=this.width();break;case"top":a.x2=this.width(),a.y1=this.height(),a.y2=this.height();break;case"left":a.x1=this.width(),a.x2=this.width(),a.y2=this.height();break;case"right":a.y2=this.height()}return a},c.prototype._generateTickMarkAttrHash=function(a){var b=this;void 0===a&&(a=!1);var c={x1:0,y1:0,x2:0,y2:0},d=function(a){return b._scale.scale(a)};this._isHorizontal()?(c.x1=d,c.x2=d):(c.y1=d,c.y2=d);var e=a?this._endTickLength:this._tickLength;switch(this._orientation){case"bottom":c.y2=e;break;case"top":c.y1=this.height(),c.y2=this.height()-e;break;case"left":c.x1=this.width(),c.x2=this.width()-e;break;case"right":c.x2=e}return c},c.prototype._invalidateLayout=function(){this._computedWidth=null,this._computedHeight=null,b.prototype._invalidateLayout.call(this)},c.prototype._setDefaultAlignment=function(){switch(this._orientation){case"bottom":this.yAlign("top");break;case"top":this.yAlign("bottom");break;case"left":this.xAlign("right");break;case"right":this.xAlign("left")}},c.prototype.formatter=function(a){return void 0===a?this._formatter:(this._formatter=a,this._invalidateLayout(),this)},c.prototype.tickLength=function(a){if(null==a)return this._tickLength;if(0>a)throw new Error("tick length must be positive");return this._tickLength=a,this._invalidateLayout(),this},c.prototype.endTickLength=function(a){if(null==a)return this._endTickLength;if(0>a)throw new Error("end tick length must be positive");return this._endTickLength=a,this._invalidateLayout(),this},c.prototype._maxLabelTickLength=function(){return this.showEndTickLabels()?Math.max(this.tickLength(),this.endTickLength()):this.tickLength()},c.prototype.tickLabelPadding=function(a){if(null==a)return this._tickLabelPadding;if(0>a)throw new Error("tick label padding must be positive");return this._tickLabelPadding=a,this._invalidateLayout(),this},c.prototype.gutter=function(a){if(null==a)return this._gutter;if(0>a)throw new Error("gutter size must be positive");return this._gutter=a,this._invalidateLayout(),this},c.prototype.orient=function(a){if(null==a)return this._orientation;var b=a.toLowerCase();if("top"!==b&&"bottom"!==b&&"left"!==b&&"right"!==b)throw new Error("unsupported orientation");return this._orientation=b,this._invalidateLayout(),this},c.prototype.showEndTickLabels=function(a){return null==a?this._showEndTickLabels:(this._showEndTickLabels=a,this._render(),this)},c.prototype._hideEndTickLabels=function(){var a=this,b=this._element.select(".bounding-box")[0][0].getBoundingClientRect(),d=function(c){return Math.floor(b.left)<=Math.ceil(c.left)&&Math.floor(b.top)<=Math.ceil(c.top)&&Math.floor(c.right)<=Math.ceil(b.left+a.width())&&Math.floor(c.bottom)<=Math.ceil(b.top+a.height())},e=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS);if(0!==e[0].length){var f=e[0][0];d(f.getBoundingClientRect())||d3.select(f).style("visibility","hidden");var g=e[0][e[0].length-1];d(g.getBoundingClientRect())||d3.select(g).style("visibility","hidden")}},c.prototype._hideOverlappingTickLabels=function(){var b,d=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS).filter(function(){return"visible"===d3.select(this).style("visibility")});d.each(function(){var c=this.getBoundingClientRect(),d=d3.select(this);null!=b&&a._Util.DOM.boxesOverlap(c,b)?d.style("visibility","hidden"):(b=c,d.style("visibility","visible"))})},c.END_TICK_MARK_CLASS="end-tick-mark",c.TICK_MARK_CLASS="tick-mark",c.TICK_LABEL_CLASS="tick-label",c}(a.Component.AbstractComponent);b.AbstractAxis=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(a,b){c.call(this,a,b),this.classed("time-axis",!0),this.tickLabelPadding(5)}return __extends(d,c),d.prototype.orient=function(a){if(a&&("right"===a.toLowerCase()||"left"===a.toLowerCase()))throw new Error(a+" is not a supported orientation for TimeAxis - only horizontal orientations are supported");return c.prototype.orient.call(this,a)},d.prototype._computeHeight=function(){if(null!==this._computedHeight)return this._computedHeight;var a=this._measureTextHeight(this._majorTickLabels)+this._measureTextHeight(this._minorTickLabels);return this.tickLength(a),this.endTickLength(a),this._computedHeight=this._maxLabelTickLength()+2*this.tickLabelPadding(),this._computedHeight},d.prototype.calculateWorstWidth=function(a,b){var c=new Date(9999,8,29,12,59,9999);return this.measurer(d3.time.format(b)(c)).width},d.prototype.getIntervalLength=function(a){var b=this._scale.domain()[0],c=a.timeUnit.offset(b,a.step);if(c>this._scale.domain()[1])return this.width();var d=Math.abs(this._scale.scale(c)-this._scale.scale(b));return d},d.prototype.isEnoughSpace=function(a,b){var c=this.calculateWorstWidth(a,b.formatString)+2*this.tickLabelPadding(),d=Math.min(this.getIntervalLength(b),this.width());return d>c},d.prototype._setup=function(){c.prototype._setup.call(this),this._majorTickLabels=this._content.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),this._minorTickLabels=this._content.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),this.measurer=a._Util.Text.getTextMeasurer(this._majorTickLabels.append("text"))},d.prototype.getTickLevel=function(){for(var b=0;b=d._minorIntervals.length&&(a._Util.Methods.warn("zoomed out too far: could not find suitable interval to display labels"),b=d._minorIntervals.length-1),b -},d.prototype._getTickIntervalValues=function(a){return this._scale._tickInterval(a.timeUnit,a.step)},d.prototype._getTickValues=function(){var a=this.getTickLevel(),b=this._getTickIntervalValues(d._minorIntervals[a]),c=this._getTickIntervalValues(d._majorIntervals[a]);return b.concat(c)},d.prototype._measureTextHeight=function(c){var d=c.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),e=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return d.remove(),e},d.prototype.renderTickLabels=function(c,d,e){var f=this;c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).remove();var g=this._scale._tickInterval(d.timeUnit,d.step);g.splice(0,0,this._scale.domain()[0]),g.push(this._scale.domain()[1]);var h=1===d.step,i=[];h?g.map(function(a,b){b+1>=g.length||i.push(new Date((g[b+1].valueOf()-g[b].valueOf())/2+g[b].valueOf()))}):i=g,i=i.filter(function(a){return f.canFitLabelFilter(c,a,d3.time.format(d.formatString)(a),h)});var j=c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).data(i,function(a){return a.valueOf()}),k=j.enter().append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0);k.append("text");var l=h?0:this.tickLabelPadding(),m="bottom"===this._orientation?this._maxLabelTickLength()/2*e:this.height()-this._maxLabelTickLength()/2*e+2*this.tickLabelPadding(),n=j.selectAll("text");n.size()>0&&a._Util.DOM.translate(n,l,m),j.exit().remove(),j.attr("transform",function(a){return"translate("+f._scale.scale(a)+",0)"});var o=h?"middle":"start";j.selectAll("text").text(function(a){return d3.time.format(d.formatString)(a)}).style("text-anchor",o)},d.prototype.canFitLabelFilter=function(a,b,c,d){var e,f,g=this.measurer(c).width+this.tickLabelPadding();return d?(e=this._scale.scale(b)+g/2,f=this._scale.scale(b)-g/2):(e=this._scale.scale(b)+g,f=this._scale.scale(b)),e0},d.prototype.adjustTickLength=function(a,c){var d=this._getTickIntervalValues(c),e=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).filter(function(a){return d.map(function(a){return a.valueOf()}).indexOf(a.valueOf())>=0});"top"===this._orientation&&(a=this.height()-a),e.attr("y2",a)},d.prototype.generateLabellessTicks=function(a){if(!(0>a)){var c=this._getTickIntervalValues(d._minorIntervals[a]),e=this._getTickValues().concat(c),f=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).data(e);f.enter().append("line").classed(b.AbstractAxis.TICK_MARK_CLASS,!0),f.attr(this._generateTickMarkAttrHash()),f.exit().remove(),this.adjustTickLength(this.tickLabelPadding(),d._minorIntervals[a])}},d.prototype._doRender=function(){c.prototype._doRender.call(this);var a=this.getTickLevel();this.renderTickLabels(this._minorTickLabels,d._minorIntervals[a],1),this.renderTickLabels(this._majorTickLabels,d._majorIntervals[a],2);var b=this._scale.domain(),e=this._scale.scale(b[1])-this._scale.scale(b[0]);return 1.5*this.getIntervalLength(d._minorIntervals[a])>=e&&this.generateLabellessTicks(a-1),this.adjustTickLength(this._maxLabelTickLength()/2,d._minorIntervals[a]),this.adjustTickLength(this._maxLabelTickLength(),d._majorIntervals[a]),this},d._minorIntervals=[{timeUnit:d3.time.second,step:1,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:5,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:10,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:15,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:30,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.minute,step:1,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:5,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:10,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:15,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:30,formatString:"%I:%M %p"},{timeUnit:d3.time.hour,step:1,formatString:"%I %p"},{timeUnit:d3.time.hour,step:3,formatString:"%I %p"},{timeUnit:d3.time.hour,step:6,formatString:"%I %p"},{timeUnit:d3.time.hour,step:12,formatString:"%I %p"},{timeUnit:d3.time.day,step:1,formatString:"%a %e"},{timeUnit:d3.time.day,step:1,formatString:"%e"},{timeUnit:d3.time.month,step:1,formatString:"%B"},{timeUnit:d3.time.month,step:1,formatString:"%b"},{timeUnit:d3.time.month,step:3,formatString:"%B"},{timeUnit:d3.time.month,step:6,formatString:"%B"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%y"},{timeUnit:d3.time.year,step:5,formatString:"%Y"},{timeUnit:d3.time.year,step:25,formatString:"%Y"},{timeUnit:d3.time.year,step:50,formatString:"%Y"},{timeUnit:d3.time.year,step:100,formatString:"%Y"},{timeUnit:d3.time.year,step:200,formatString:"%Y"},{timeUnit:d3.time.year,step:500,formatString:"%Y"},{timeUnit:d3.time.year,step:1e3,formatString:"%Y"}],d._majorIntervals=[{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.month,step:1,formatString:"%B %Y"},{timeUnit:d3.time.month,step:1,formatString:"%B %Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""}],d}(b.AbstractAxis);b.Time=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=a.Formatters.general()),c.call(this,b,d,e),this.tickLabelPositioning="center",this.showFirstTickLabel=!1,this.showLastTickLabel=!1}return __extends(d,c),d.prototype._setup=function(){c.prototype._setup.call(this),this.measurer=a._Util.Text.getTextMeasurer(this._tickLabelContainer.append("text").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0))},d.prototype._computeWidth=function(){var b=this,c=this._getTickValues(),d=c.map(function(a){var c=b._formatter(a);return b.measurer(c).width}),e=a._Util.Methods.max(d,0);return this._computedWidth="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+e:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+e),this._computedWidth},d.prototype._computeHeight=function(){var b=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return this._computedHeight="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+b:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+b),this._computedHeight},d.prototype._getTickValues=function(){return this._scale.ticks()},d.prototype._rescale=function(){if(this._isSetup){if(!this._isHorizontal()){var a=this._computeWidth();if(a>this.width()||aa,wantsHeight:e>b}},c.prototype._setup=function(){b.prototype._setup.call(this),this.textContainer=this._content.append("g"),this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),this.text(this._text)},c.prototype.text=function(a){return void 0===a?this._text:(this._text=a,this._invalidateLayout(),this)},c.prototype.orient=function(a){if(null==a)return this.orientation;if(a=a.toLowerCase(),"horizontal"!==a&&"left"!==a&&"right"!==a)throw new Error(a+" is not a valid orientation for LabelComponent");return this.orientation=a,this._invalidateLayout(),this},c.prototype.padding=function(a){if(null==a)return this._padding;if(a=+a,0>a)throw new Error(a+" is not a valid padding value. Cannot be less than 0.");return this._padding=a,this._invalidateLayout(),this},c.prototype._doRender=function(){b.prototype._doRender.call(this);var c=this.measurer(this._text),d=Math.max(Math.min((this.height()-c.height)/2,this.padding()),0),e=Math.max(Math.min((this.width()-c.width)/2,this.padding()),0);this.textContainer.attr("transform","translate("+e+","+d+")"),this.textContainer.text("");var f="horizontal"===this.orientation?this.width():this.height(),g=a._Util.Text.getTruncatedText(this._text,f,this.measurer),h=this.width()-2*e,i=this.height()-2*d;"horizontal"===this.orientation?a._Util.Text.writeLineHorizontally(g,this.textContainer,h,i,this.xAlignment,this.yAlignment):a._Util.Text.writeLineVertically(g,this.textContainer,h,i,this.xAlignment,this.yAlignment,this.orientation)},c.prototype._computeLayout=function(c,d,e,f){return this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),b.prototype._computeLayout.call(this,c,d,e,f),this},c}(b.AbstractComponent);b.Label=c;var d=function(a){function b(b,c){a.call(this,b,c),this.classed("title-label",!0)}return __extends(b,a),b}(c);b.TitleLabel=d;var e=function(a){function b(b,c){a.call(this,b,c),this.classed("axis-label",!0)}return __extends(b,a),b}(c);b.AxisLabel=e}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this),this.classed("legend",!0),this.scale(a),this.xAlign("RIGHT").yAlign("TOP"),this.xOffset(5).yOffset(5),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this)},c.prototype.toggleCallback=function(a){return void 0!==a?(this._toggleCallback=a,this.isOff=d3.set(),this.updateListeners(),this.updateClasses(),this):this._toggleCallback},c.prototype.hoverCallback=function(a){return void 0!==a?(this._hoverCallback=a,this.datumCurrentlyFocusedOn=void 0,this.updateListeners(),this.updateClasses(),this):this._hoverCallback},c.prototype.scale=function(a){var b=this;return null!=a?(null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this),this.colorScale=a,this.colorScale.broadcaster.registerListener(this,function(){return b.updateDomain()}),this.updateDomain(),this):this.colorScale},c.prototype.updateDomain=function(){null!=this._toggleCallback&&(this.isOff=a._Util.Methods.intersection(this.isOff,d3.set(this.scale().domain()))),null!=this._hoverCallback&&(this.datumCurrentlyFocusedOn=this.scale().domain().indexOf(this.datumCurrentlyFocusedOn)>=0?this.datumCurrentlyFocusedOn:void 0),this._invalidateLayout()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e);var f=this.measureTextHeight(),g=this.colorScale.domain().length;this.nRowsDrawn=Math.min(g,Math.floor(this.height()/f))},c.prototype._requestedSpace=function(b,d){var e=this.measureTextHeight(),f=this.colorScale.domain().length,g=Math.min(f,Math.floor((d-2*c.MARGIN)/e)),h=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),i=a._Util.Text.getTextMeasurer(h.append("text")),j=a._Util.Methods.max(this.colorScale.domain(),function(a){return i(a).width},0);h.remove(),j=void 0===j?0:j;var k=0===g?0:j+e+2*c.MARGIN,l=0===g?0:f*e+2*c.MARGIN;return{width:k,height:l,wantsWidth:k>b,wantsHeight:l>d}},c.prototype.measureTextHeight=function(){var b=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),d=a._Util.Text.getTextMeasurer(b.append("text"))(a._Util.Text.HEIGHT_TEXT).height;return 0===d&&(d=1),b.remove(),d},c.prototype._doRender=function(){b.prototype._doRender.call(this);var d=this.colorScale.domain().slice(0,this.nRowsDrawn),e=this.measureTextHeight(),f=this.width()-e-c.MARGIN,g=.3*e,h=this._content.selectAll("."+c.SUBELEMENT_CLASS).data(d,function(a){return a}),i=h.enter().append("g").classed(c.SUBELEMENT_CLASS,!0);i.each(function(a){d3.select(this).classed(a.replace(" ","-"),!0)}),i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove(),h.selectAll("circle").attr("cx",e/2).attr("cy",e/2).attr("r",g).attr("fill",this.colorScale._d3Scale),h.selectAll("g.text-container").text("").attr("transform","translate("+e+", 0)").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),e=a._Util.Text.getTruncatedText(b,f,d),g=d(e);a._Util.Text.writeLineHorizontally(e,c,g.width,g.height)}),h.attr("transform",function(a){return"translate("+c.MARGIN+","+(d.indexOf(a)*e+c.MARGIN)+")"}),this.updateClasses(),this.updateListeners()},c.prototype.updateListeners=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);if(null!=this._hoverCallback){var d=function(b){return function(c){a.datumCurrentlyFocusedOn=b?c:void 0,a._hoverCallback(a.datumCurrentlyFocusedOn),a.updateClasses()}};b.on("mouseover",d(!0)),b.on("mouseout",d(!1))}else b.on("mouseover",null),b.on("mouseout",null);null!=this._toggleCallback?b.on("click",function(b){var c=a.isOff.has(b);c?a.isOff.remove(b):a.isOff.add(b),a._toggleCallback(b,c),a.updateClasses()}):b.on("click",null)}},c.prototype.updateClasses=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);null!=this._hoverCallback?(b.classed("focus",function(b){return a.datumCurrentlyFocusedOn===b}),b.classed("hover",void 0!==this.datumCurrentlyFocusedOn)):(b.classed("hover",!1),b.classed("focus",!1)),null!=this._toggleCallback?(b.classed("toggled-on",function(b){return!a.isOff.has(b)}),b.classed("toggled-off",function(b){return a.isOff.has(b)})):(b.classed("toggled-on",!1),b.classed("toggled-off",!1))}},c.SUBELEMENT_CLASS="legend-row",c.MARGIN=5,c}(b.AbstractComponent);b.Legend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;b.call(this),this.padding=5,this.classed("legend",!0),this.scale=a,this.scale.broadcaster.registerListener(this,function(){return c._invalidateLayout()}),this.xAlign("left").yAlign("center"),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this.scale.broadcaster.deregisterListener(this)},c.prototype.calculateLayoutInfo=function(b,d){var e=this,f=this._content.append("g").classed(c.LEGEND_ROW_CLASS,!0),g=(f.append("g").classed(c.LEGEND_ENTRY_CLASS,!0),a._Util.Text.getTextMeasurer(f.append("text"))),h=g(a._Util.Text.HEIGHT_TEXT).height,i=Math.max(0,b-this.padding),j=function(a){var b=h+g(a).width+e.padding;return Math.min(b,i)},k=this.scale.domain(),l=a._Util.Methods.populateMap(k,j);f.remove();var m=this.packRows(i,k,l),n=Math.floor((d-2*this.padding)/h);return n!==n&&(n=0),{textHeight:h,entryLengths:l,rows:m,numRowsToDraw:Math.max(Math.min(n,m.length),0)}},c.prototype._requestedSpace=function(b,c){var d=this.calculateLayoutInfo(b,c),e=d.rows.map(function(a){return d3.sum(a,function(a){return d.entryLengths.get(a)})}),f=a._Util.Methods.max(e,0);f=void 0===f?0:f;var g=this.padding+f,h=d.numRowsToDraw*d.textHeight+2*this.padding,i=d.rows.length*d.textHeight+2*this.padding;return{width:g,height:h,wantsWidth:g>b,wantsHeight:i>c}},c.prototype.packRows=function(a,b,c){var d=[[]],e=d[0],f=a;return b.forEach(function(b){var g=c.get(b);g>f&&(e=[],d.push(e),f=a),e.push(b),f-=g}),d},c.prototype._doRender=function(){var d=this;b.prototype._doRender.call(this);var e=this.calculateLayoutInfo(this.width(),this.height()),f=e.rows.slice(0,e.numRowsToDraw),g=this._content.selectAll("g."+c.LEGEND_ROW_CLASS).data(f);g.enter().append("g").classed(c.LEGEND_ROW_CLASS,!0),g.exit().remove(),g.attr("transform",function(a,b){return"translate(0, "+(b*e.textHeight+d.padding)+")"});var h=g.selectAll("g."+c.LEGEND_ENTRY_CLASS).data(function(a){return a}),i=h.enter().append("g").classed(c.LEGEND_ENTRY_CLASS,!0);h.each(function(a){d3.select(this).classed(a.replace(" ","-"),!0)}),i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove();var j=this.padding;g.each(function(){var a=j,b=d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS);b.attr("transform",function(b){var c="translate("+a+", 0)";return a+=e.entryLengths.get(b),c})}),h.select("circle").attr("cx",e.textHeight/2).attr("cy",e.textHeight/2).attr("r",.3*e.textHeight).attr("fill",function(a){return d.scale.scale(a)});var k=this.padding,l=h.select("g.text-container");l.text(""),l.append("title").text(function(a){return a}),l.attr("transform","translate("+e.textHeight+", "+.1*e.textHeight+")").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),f=e.entryLengths.get(b)-e.textHeight-k,g=a._Util.Text.getTruncatedText(b,f,d),h=d(g);a._Util.Text.writeLineHorizontally(g,c,h.width,h.height)})},c.LEGEND_ROW_CLASS="legend-row",c.LEGEND_ENTRY_CLASS="legend-entry",c}(b.AbstractComponent);b.HorizontalLegend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;if(null!=c&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(c))throw new Error("xScale needs to inherit from Scale.AbstractQuantitative");if(null!=d&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(d))throw new Error("yScale needs to inherit from Scale.AbstractQuantitative");b.call(this),this.classed("gridlines",!0),this.xScale=c,this.yScale=d,this.xScale&&this.xScale.broadcaster.registerListener(this,function(){return e._render()}),this.yScale&&this.yScale.broadcaster.registerListener(this,function(){return e._render()})}return __extends(c,b),c.prototype.remove=function(){return b.prototype.remove.call(this),this.xScale&&this.xScale.broadcaster.deregisterListener(this),this.yScale&&this.yScale.broadcaster.deregisterListener(this),this},c.prototype._setup=function(){b.prototype._setup.call(this),this.xLinesContainer=this._content.append("g").classed("x-gridlines",!0),this.yLinesContainer=this._content.append("g").classed("y-gridlines",!0)},c.prototype._doRender=function(){b.prototype._doRender.call(this),this.redrawXLines(),this.redrawYLines()},c.prototype.redrawXLines=function(){var a=this;if(this.xScale){var b=this.xScale.ticks(),c=function(b){return a.xScale.scale(b)},d=this.xLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",c).attr("y1",0).attr("x2",c).attr("y2",this.height()).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c.prototype.redrawYLines=function(){var a=this;if(this.yScale){var b=this.yScale.ticks(),c=function(b){return a.yScale.scale(b)},d=this.yLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",0).attr("y1",c).attr("x2",this.width()).attr("y2",c).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c}(b.AbstractComponent);b.Gridlines=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.rowPadding=0,this.colPadding=0,this.rows=[],this.rowWeights=[],this.colWeights=[],this.nRows=0,this.nCols=0,this.classed("table",!0),a.forEach(function(a,b){a.forEach(function(a,d){c.addComponent(b,d,a)})})}return __extends(c,b),c.prototype.addComponent=function(a,b,c){if(this._addComponent(c)){this.nRows=Math.max(a+1,this.nRows),this.nCols=Math.max(b+1,this.nCols),this.padTableToSize(this.nRows,this.nCols);var d=this.rows[a][b];if(d)throw new Error("Table.addComponent cannot be called on a cell where a component already exists (for the moment)");this.rows[a][b]=c}return this},c.prototype._removeComponent=function(a){b.prototype._removeComponent.call(this,a);var c,d;a:for(var e=0;e0&&v&&e!==x,C=f>0&&w&&f!==y;if(!B&&!C)break;if(r>5)break}return e=h-d3.sum(u.guaranteedWidths),f=i-d3.sum(u.guaranteedHeights),n=c.calcProportionalSpace(k,e),o=c.calcProportionalSpace(j,f),{colProportionalSpace:n,rowProportionalSpace:o,guaranteedWidths:u.guaranteedWidths,guaranteedHeights:u.guaranteedHeights,wantsWidth:v,wantsHeight:w}},c.prototype.determineGuarantees=function(b,c){var d=a._Util.Methods.createFilledArray(0,this.nCols),e=a._Util.Methods.createFilledArray(0,this.nRows),f=a._Util.Methods.createFilledArray(!1,this.nCols),g=a._Util.Methods.createFilledArray(!1,this.nRows);return this.rows.forEach(function(a,h){a.forEach(function(a,i){var j;j=null!=a?a._requestedSpace(b[i],c[h]):{width:0,height:0,wantsWidth:!1,wantsHeight:!1};var k=Math.min(j.width,b[i]),l=Math.min(j.height,c[h]);d[i]=Math.max(d[i],k),e[h]=Math.max(e[h],l),f[i]=f[i]||j.wantsWidth,g[h]=g[h]||j.wantsHeight})}),{guaranteedWidths:d,guaranteedHeights:e,wantsWidthArr:f,wantsHeightArr:g}},c.prototype._requestedSpace=function(a,b){var c=this.iterateLayout(a,b);return{width:d3.sum(c.guaranteedWidths),height:d3.sum(c.guaranteedHeights),wantsWidth:c.wantsWidth,wantsHeight:c.wantsHeight}},c.prototype._computeLayout=function(c,d,e,f){var g=this;b.prototype._computeLayout.call(this,c,d,e,f);var h=this.iterateLayout(this.width(),this.height()),i=a._Util.Methods.addArrays(h.rowProportionalSpace,h.guaranteedHeights),j=a._Util.Methods.addArrays(h.colProportionalSpace,h.guaranteedWidths),k=0;this.rows.forEach(function(a,b){var c=0;a.forEach(function(a,d){null!=a&&a._computeLayout(c,k,j[d],i[b]),c+=j[d]+g.colPadding}),k+=i[b]+g.rowPadding})},c.prototype.padding=function(a,b){return this.rowPadding=a,this.colPadding=b,this._invalidateLayout(),this},c.prototype.rowWeight=function(a,b){return this.rowWeights[a]=b,this._invalidateLayout(),this},c.prototype.colWeight=function(a,b){return this.colWeights[a]=b,this._invalidateLayout(),this},c.prototype._isFixedWidth=function(){var a=d3.transpose(this.rows);return c.fixedSpace(a,function(a){return null==a||a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return c.fixedSpace(this.rows,function(a){return null==a||a._isFixedHeight()})},c.prototype.padTableToSize=function(a,b){for(var c=0;a>c;c++){void 0===this.rows[c]&&(this.rows[c]=[],this.rowWeights[c]=null);for(var d=0;b>d;d++)void 0===this.rows[c][d]&&(this.rows[c][d]=null)}for(d=0;b>d;d++)void 0===this.colWeights[d]&&(this.colWeights[d]=null)},c.calcComponentWeights=function(a,b,c){return a.map(function(a,d){if(null!=a)return a;var e=b[d].map(c),f=e.reduce(function(a,b){return a&&b},!0);return f?0:1})},c.calcProportionalSpace=function(b,c){var d=d3.sum(b);return 0===d?a._Util.Methods.createFilledArray(0,b.length):b.map(function(a){return c*a/d -})},c.fixedSpace=function(a,b){var c=function(a){return a.reduce(function(a,b){return a&&b},!0)},d=function(a){return c(a.map(b))};return c(a.map(d))},c}(b.AbstractComponentContainer);b.Table=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this._dataChanged=!1,this._projectors={},this._animate=!1,this._animators={},this._ANIMATION_DURATION=250,this._animateOnNextRender=!0,this.clipPathEnabled=!0,this.classed("plot",!0),this._key2DatasetDrawerKey=d3.map(),this._datasetKeysInOrder=[],this.nextSeriesIndex=0}return __extends(c,b),c.prototype._anchor=function(a){b.prototype._anchor.call(this,a),this._animateOnNextRender=!0,this._dataChanged=!0,this._updateScaleExtents()},c.prototype._setup=function(){var a=this;b.prototype._setup.call(this),this._renderArea=this._content.append("g").classed("render-area",!0),this._getDrawersInOrder().forEach(function(b){return b.setup(a._renderArea.append("g"))})},c.prototype.remove=function(){var a=this;b.prototype.remove.call(this),this._datasetKeysInOrder.forEach(function(b){return a.removeDataset(b)});var c=Object.keys(this._projectors);c.forEach(function(b){var c=a._projectors[b];c.scale&&c.scale.broadcaster.deregisterListener(a)})},c.prototype.addDataset=function(b,c){if("string"!=typeof b&&void 0!==c)throw new Error("invalid input to addDataset");"string"==typeof b&&"_"===b[0]&&a._Util.Methods.warn("Warning: Using _named series keys may produce collisions with unlabeled data sources");var d="string"==typeof b?b:"_"+this.nextSeriesIndex++,e="string"!=typeof b?b:c,c=e instanceof a.Dataset?e:new a.Dataset(e);return this._addDataset(d,c),this},c.prototype._addDataset=function(a,b){var c=this;this._key2DatasetDrawerKey.has(a)&&this.removeDataset(a);var d=this._getDrawer(a),e={drawer:d,dataset:b,key:a};this._datasetKeysInOrder.push(a),this._key2DatasetDrawerKey.set(a,e),this._isSetup&&d.setup(this._renderArea.append("g")),b.broadcaster.registerListener(this,function(){return c._onDatasetUpdate()}),this._onDatasetUpdate()},c.prototype._getDrawer=function(b){return new a._Drawer.AbstractDrawer(b)},c.prototype._getAnimator=function(b){return this._animate&&this._animateOnNextRender?this._animators[b]||new a.Animator.Null:new a.Animator.Null},c.prototype._onDatasetUpdate=function(){this._updateScaleExtents(),this._animateOnNextRender=!0,this._dataChanged=!0,this._render()},c.prototype.attr=function(a,b,c){return this.project(a,b,c)},c.prototype.project=function(b,c,d){var e=this;b=b.toLowerCase();var f=this._projectors[b],g=f&&f.scale;g&&this._datasetKeysInOrder.forEach(function(a){g._removeExtent(e._plottableID.toString()+"_"+a,b),g.broadcaster.deregisterListener(e)}),d&&d.broadcaster.registerListener(this,function(){return e._render()});var h=a._Util.Methods._applyAccessor(c,this);return this._projectors[b]={accessor:h,scale:d,attribute:b},this._updateScaleExtent(b),this._render(),this},c.prototype._generateAttrToProjector=function(){var a=this,b={};return d3.keys(this._projectors).forEach(function(c){var d=a._projectors[c],e=d.accessor,f=d.scale,g=f?function(a,b){return f.scale(e(a,b))}:e;b[c]=g}),b},c.prototype._doRender=function(){this._isAnchored&&(this.paint(),this._dataChanged=!1,this._animateOnNextRender=!1)},c.prototype.animate=function(a){return this._animate=a,this},c.prototype.detach=function(){return b.prototype.detach.call(this),this._updateScaleExtents(),this},c.prototype._updateScaleExtents=function(){var a=this;d3.keys(this._projectors).forEach(function(b){return a._updateScaleExtent(b)})},c.prototype._updateScaleExtent=function(a){var b=this,c=this._projectors[a];c.scale&&this._key2DatasetDrawerKey.forEach(function(d,e){var f=e.dataset._getExtent(c.accessor,c.scale._typeCoercer),g=b._plottableID.toString()+"_"+d;0!==f.length&&b._isAnchored?c.scale._updateExtent(g,a,f):c.scale._removeExtent(g,a)})},c.prototype.animator=function(a,b){return void 0===b?this._animators[a]:(this._animators[a]=b,this)},c.prototype.datasetOrder=function(b){function c(b,c){var d=a._Util.Methods.intersection(d3.set(b),d3.set(c)),e=d.size();return e===b.length&&e===c.length}return void 0===b?this._datasetKeysInOrder:(c(b,this._datasetKeysInOrder)?(this._datasetKeysInOrder=b,this._onDatasetUpdate()):a._Util.Methods.warn("Attempted to change datasetOrder, but new order is not permutation of old. Ignoring."),this)},c.prototype.removeDataset=function(b){var c;if("string"==typeof b)c=b;else if(b instanceof a.Dataset||b instanceof Array){var d=b instanceof a.Dataset?this.datasets():this.datasets().map(function(a){return a.data()}),e=d.indexOf(b);-1!==e&&(c=this._datasetKeysInOrder[e])}return this._removeDataset(c)},c.prototype._removeDataset=function(a){if(null!=a&&this._key2DatasetDrawerKey.has(a)){var b=this._key2DatasetDrawerKey.get(a);b.drawer.remove();var c=d3.values(this._projectors),d=this._plottableID.toString()+"_"+a;c.forEach(function(a){null!=a.scale&&a.scale._removeExtent(d,a.attribute)}),b.dataset.broadcaster.deregisterListener(this),this._datasetKeysInOrder.splice(this._datasetKeysInOrder.indexOf(a),1),this._key2DatasetDrawerKey.remove(a),this._onDatasetUpdate()}return this},c.prototype.datasets=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2DatasetDrawerKey.get(b).dataset})},c.prototype._getDrawersInOrder=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2DatasetDrawerKey.get(b).drawer})},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animator.Null}]},c.prototype._additionalPaint=function(){},c.prototype._getDataToDraw=function(){var a=this,b=d3.map();return this._datasetKeysInOrder.forEach(function(c){b.set(c,a._key2DatasetDrawerKey.get(c).dataset.data())}),b},c.prototype.paint=function(){var b=this._generateDrawSteps(),c=this._getDataToDraw(),d=this._getDrawersInOrder(),e=this._datasetKeysInOrder.map(function(a,e){return d[e].draw(c.get(a),b)}),f=a._Util.Methods.max(e,0);this._additionalPaint(f)},c}(a.Component.AbstractComponent);b.AbstractPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.colorScale=new a.Scale.Color,this.classed("pie-plot",!0)}return __extends(c,b),c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")")},c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Pie plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this);c["inner-radius"]=c["inner-radius"]||d3.functor(0),c["outer-radius"]=c["outer-radius"]||d3.functor(Math.min(this.width(),this.height())/2),null==c.fill&&(c.fill=function(b,c){return a.colorScale.scale(String(c))});var d=function(a){return a.value},e=this._projectors.value;return c.value=e?e.accessor:d,c},c.prototype._getDrawer=function(b){return new a._Drawer.Arc(b).setClass("arc")},c}(b.AbstractPlot);b.Pie=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,c){if(b.call(this),this._autoAdjustXScaleDomain=!1,this._autoAdjustYScaleDomain=!1,null==a||null==c)throw new Error("XYPlots require an xScale and yScale");this.classed("xy-plot",!0),this.project("x","x",a),this.project("y","y",c)}return __extends(c,b),c.prototype.project=function(a,c,d){var e=this;return"x"===a&&d&&(this._xScale&&this._xScale.broadcaster.deregisterListener("yDomainAdjustment"+this._plottableID),this._xScale=d,this._updateXDomainer(),d.broadcaster.registerListener("yDomainAdjustment"+this._plottableID,function(){return e.adjustYDomainOnChangeFromX()})),"y"===a&&d&&(this._yScale&&this._yScale.broadcaster.deregisterListener("xDomainAdjustment"+this._plottableID),this._yScale=d,this._updateYDomainer(),d.broadcaster.registerListener("xDomainAdjustment"+this._plottableID,function(){return e.adjustXDomainOnChangeFromY()})),b.prototype.project.call(this,a,c,d),this},c.prototype.remove=function(){return b.prototype.remove.call(this),this._xScale&&this._xScale.broadcaster.deregisterListener("yDomainAdjustment"+this._plottableID),this._yScale&&this._yScale.broadcaster.deregisterListener("xDomainAdjustment"+this._plottableID),this},c.prototype.automaticallyAdjustYScaleOverVisiblePoints=function(a){return this._autoAdjustYScaleDomain=a,this.adjustYDomainOnChangeFromX(),this},c.prototype.automaticallyAdjustXScaleOverVisiblePoints=function(a){return this._autoAdjustXScaleDomain=a,this.adjustXDomainOnChangeFromY(),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=a.x,d=a.y;return a.defined=function(a,b){var e=c(a,b),f=d(a,b);return null!=e&&e===e&&null!=f&&f===f},a},c.prototype._computeLayout=function(c,d,e,f){b.prototype._computeLayout.call(this,c,d,e,f),this._xScale.range([0,this.width()]),this._yScale.range(this._yScale instanceof a.Scale.Ordinal?[0,this.height()]:[this.height(),0])},c.prototype._updateXDomainer=function(){if(this._xScale instanceof a.Scale.AbstractQuantitative){var b=this._xScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype._updateYDomainer=function(){if(this._yScale instanceof a.Scale.AbstractQuantitative){var b=this._yScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype.showAllData=function(){this._xScale.autoDomain(),this._autoAdjustYScaleDomain||this._yScale.autoDomain()},c.prototype.adjustYDomainOnChangeFromX=function(){this._autoAdjustYScaleDomain&&this.adjustDomainToVisiblePoints(this._xScale,this._yScale,!0)},c.prototype.adjustXDomainOnChangeFromY=function(){this._autoAdjustXScaleDomain&&this.adjustDomainToVisiblePoints(this._yScale,this._xScale,!1)},c.prototype.adjustDomainToVisiblePoints=function(b,c,d){if(c instanceof a.Scale.AbstractQuantitative){var e=c,f=this.normalizeDatasets(d),g=this.adjustDomainOverVisiblePoints(f,b.domain());if(0===g.length)return;g=e.domainer().computeDomain([g],e),e.domain(g)}},c.prototype.normalizeDatasets=function(b){var c=a._Util.Methods.flatten(this.datasets().map(function(a){return a.data()})),d=this._projectors[b?"x":"y"].accessor,e=this._projectors[b?"y":"x"].accessor;return c.map(function(a,b){return{a:d(a,b),b:e(a,b)}})},c.prototype.adjustDomainOverVisiblePoints=function(b,c){var d=b.filter(function(a){return c[0]<=a.a&&a.a<=c[1]}).map(function(a){return a.b}),e=[];return 0!==d.length&&(e=[a._Util.Methods.min(d,null),a._Util.Methods.max(d,null)]),e},c}(b.AbstractPlot);b.AbstractXYPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.closeDetectionRadius=5,this.classed("scatter-plot",!0),this.project("r",3),this.project("opacity",.6);var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this._animators["circles-reset"]=new a.Animator.Null,this._animators.circles=(new a.Animator.Base).duration(250).delay(5)}return __extends(c,b),c.prototype.project=function(a,c,d){return a="cx"===a?"x":a,a="cy"===a?"y":a,b.prototype.project.call(this,a,c,d),this},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("circle")},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this);return a.cx=a.x,delete a.x,a.cy=a.y,delete a.y,a},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.r=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("circles-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("circles")}),a},c.prototype._getClosestStruckPoint=function(a,b){var c,d,e=this._getDrawersInOrder(),f=this._generateAttrToProjector(),g=function(b,c){var d=f.cx(b,c)-a.x,e=f.cy(b,c)-a.y;return d*d+e*e},h=!1,i=b*b;if(e.forEach(function(a){a._getDrawSelection().each(function(a,b){var e=g(a,b),j=f.r(a,b);j*j>e?((!h||i>e)&&(c=this,d=b,i=e),h=!0):!h&&i>e&&(c=this,d=b,i=e)})}),!c)return{selection:null,pixelPositions:null,data:null};var j=d3.select(c),k=j.data(),l={x:f.cx(k[0],d),y:f.cy(k[0],d)};return{selection:j,pixelPositions:[l],data:k}},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){},c.prototype._doHover=function(a){return this._getClosestStruckPoint(a,this.closeDetectionRadius)},c}(b.AbstractXYPlot);b.Scatter=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){b.call(this,c,d),this._animators={cells:new a.Animator.Null},this.classed("grid-plot",!0),this._xScale.rangeType("bands",0,0),this._yScale.rangeType("bands",0,0),this._colorScale=e,this.project("fill","value",e),this._animators.cells=new a.Animator.Null}return __extends(c,b),c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Grid plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("rect")},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"fill"===a&&(this._colorScale=this._projectors.fill.scale),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=this._xScale.rangeBand(),d=this._yScale.rangeBand();return a.width=function(){return c},a.height=function(){return d},a},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("cells")}]},c}(b.AbstractXYPlot);b.Grid=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this._barAlignmentFactor=.5,this._barLabelFormatter=a.Formatters.identity(),this._barLabelsEnabled=!1,this._hoverMode="point",this.hideBarsIfAnyAreTooWide=!0,this.classed("bar-plot",!0);var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this._animators["bars-reset"]=new a.Animator.Null,this._animators.bars=new a.Animator.Base,this._animators.baseline=new a.Animator.Null,this.baseline(0)}return __extends(c,b),c.prototype._getDrawer=function(b){return new a._Drawer.Rect(b,this._isVertical)},c.prototype._setup=function(){b.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},c.prototype.baseline=function(a){return null==a?this._baselineValue:(this._baselineValue=a,this._updateXDomainer(),this._updateYDomainer(),this._render(),this)},c.prototype.barAlignment=function(a){var b=a.toLowerCase(),c=this.constructor._BarAlignmentToFactor;if(void 0===c[b])throw new Error("unsupported bar alignment");return this._barAlignmentFactor=c[b],this._render(),this},c.prototype.parseExtent=function(a){if("number"==typeof a)return{min:a,max:a};if(a instanceof Object&&"min"in a&&"max"in a)return a;throw new Error("input '"+a+"' can't be parsed as an Extent")},c.prototype.barLabelsEnabled=function(a){return void 0===a?this._barLabelsEnabled:(this._barLabelsEnabled=a,this._render(),this)},c.prototype.barLabelFormatter=function(a){return null==a?this._barLabelFormatter:(this._barLabelFormatter=a,this._render(),this)},c.prototype.selectBar=function(a,b,c){if(void 0===c&&(c=!0),!this._isSetup)return null;var d=[],e=this.parseExtent(a),f=this.parseExtent(b),g=.5;if(this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").each(function(){var a=this.getBBox();a.x+a.width>=e.min-g&&a.x<=e.max+g&&a.y+a.height>=f.min-g&&a.y<=f.max+g&&d.push(this)})}),d.length>0){var h=d3.selectAll(d);return h.classed("selected",c),h}return null},c.prototype.deselectAll=function(){return this._isSetup&&this._getDrawersInOrder().forEach(function(a){return a._renderArea.selectAll("rect").classed("selected",!1)}),this},c.prototype._updateDomainer=function(b){if(b instanceof a.Scale.AbstractQuantitative){var c=b;c._userSetDomainer||(null!=this._baselineValue?c.domainer().addPaddingException(this._baselineValue,"BAR_PLOT+"+this._plottableID).addIncludedValue(this._baselineValue,"BAR_PLOT+"+this._plottableID):c.domainer().removePaddingException("BAR_PLOT+"+this._plottableID).removeIncludedValue("BAR_PLOT+"+this._plottableID),c.domainer().pad()),c._autoDomainIfAutomaticMode()}},c.prototype._updateYDomainer=function(){this._isVertical?this._updateDomainer(this._yScale):b.prototype._updateYDomainer.call(this)},c.prototype._updateXDomainer=function(){this._isVertical?b.prototype._updateXDomainer.call(this):this._updateDomainer(this._xScale)},c.prototype._additionalPaint=function(b){var c=this,d=this._isVertical?this._yScale:this._xScale,e=d.scale(this._baselineValue),f={x1:this._isVertical?0:e,y1:this._isVertical?e:0,x2:this._isVertical?this.width():e,y2:this._isVertical?e:this.height()};this._getAnimator("baseline").animate(this._baseline,f);var g=this._getDrawersInOrder();g.forEach(function(a){return a.removeLabels()}),this._barLabelsEnabled&&a._Util.Methods.setTimeout(function(){return c._drawLabels()},b)},c.prototype._drawLabels=function(){var a=this._getDrawersInOrder(),b=this._generateAttrToProjector(),c=this._getDataToDraw();this._datasetKeysInOrder.forEach(function(d,e){return a[e].drawText(c.get(d),b)}),this.hideBarsIfAnyAreTooWide&&a.some(function(a){return a._someLabelsTooWide})&&a.forEach(function(a){return a.removeLabels()})},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged&&this._animate){var b=this._generateAttrToProjector(),c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue),e=this._isVertical?"y":"x",f=this._isVertical?"height":"width";b[e]=function(){return d},b[f]=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("bars-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("bars")}),a},c.prototype._generateAttrToProjector=function(){var c=this,d=b.prototype._generateAttrToProjector.call(this),e=this._isVertical?this._yScale:this._xScale,f=this._isVertical?this._xScale:this._yScale,g=this._isVertical?"y":"x",h=this._isVertical?"x":"y",i=e.scale(this._baselineValue);d.width||(d.width=function(){return c._getBarPixelWidth()});var j=d[h],k=d.width,l=f instanceof a.Scale.Ordinal&&"bands"===f.rangeType();if(l){var m=f.rangeBand();d[h]=function(a,b){return j(a,b)-k(a,b)/2+m/2}}else d[h]=function(a,b){return j(a,b)-k(a,b)*c._barAlignmentFactor};var n=d[g];d[g]=function(a,b){var c=n(a,b);return c>i?i:c},d.height=function(a,b){return Math.abs(i-n(a,b))};var o=this._projectors[g].accessor;return this.barLabelsEnabled&&this.barLabelFormatter&&(d.label=function(a,b){return c._barLabelFormatter(o(a,b))},d.positive=function(a,b){return n(a,b)<=i}),d},c.prototype._getBarPixelWidth=function(){var b,c=this._isVertical?this._xScale:this._yScale;if(c instanceof a.Scale.Ordinal){var d=c;if("bands"===d.rangeType())b=d.rangeBand();else{var e=2*d._outerPadding,f=this._isVertical?this.width():this.height(),g=f/(e+d.domain().length-1);b=g*e*.5}}else{var h=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,i=d3.set(a._Util.Methods.flatten(this.datasets().map(function(a){return a.data().map(function(a,b){return h(a,b)})}))).values();if(i.some(function(a){return"undefined"===a}))return-1;var j=d3.set(a._Util.Methods.flatten(this.datasets().map(function(a){return a.data().map(function(a,b){return h(a,b).valueOf()})}))).values().map(function(a){return+a});j.sort(function(a,b){return a-b});var k=d3.pairs(j),l=this._isVertical?this.width():this.height();b=.95*a._Util.Methods.min(k,function(a){return Math.abs(c.scale(a[1])-c.scale(a[0]))},.4*l)}return b},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode");return this._hoverMode=b,this},c.prototype.clearHoverSelection=function(){this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed("not-hovered hovered",!1)})},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){this.clearHoverSelection()},c.prototype._doHover=function(a){var b=this,c=a.x,d=a.y;if("line"===this._hoverMode){var e={min:-1/0,max:1/0};this._isVertical?d=e:c=e}var f=this.selectBar(c,d,!1);if(!f)return this.clearHoverSelection(),{data:null,pixelPositions:null,selection:null};this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed({hovered:!1,"not-hovered":!0})}),f.classed({hovered:!0,"not-hovered":!1});var g=[],h=this._generateAttrToProjector();return f.each(function(a,c){g.push(b._isVertical?{x:h.x(a,c)+h.width(a,c)/2,y:h.y(a,c)+(h.positive(a,c)?0:h.height(a,c))}:{x:h.x(a,c)+(h.positive(a,c)?0:h.width(a,c)),y:h.y(a,c)+h.height(a,c)/2})}),{data:f.data(),pixelPositions:g,selection:f}},c._BarAlignmentToFactor={},c._DEFAULT_WIDTH=10,c}(b.AbstractXYPlot);b.AbstractBarPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){this._isVertical=!0,a.call(this,b,c)}return __extends(b,a),b.prototype._updateYDomainer=function(){this._updateDomainer(this._yScale)},b._BarAlignmentToFactor={left:0,center:.5,right:1},b}(a.AbstractBarPlot);a.VerticalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){a.call(this,b,c)}return __extends(b,a),b.prototype._updateXDomainer=function(){this._updateDomainer(this._xScale)},b.prototype._generateAttrToProjector=function(){var b=a.prototype._generateAttrToProjector.call(this),c=b.width;return b.width=b.height,b.height=c,b},b._BarAlignmentToFactor={top:0,center:.5,bottom:1},b}(a.AbstractBarPlot);a.HorizontalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.hoverDetectionRadius=15,this.classed("line-plot",!0);var e=(new a.Scale.Color).range()[0];this.project("stroke",function(){return e}),this.project("stroke-width",function(){return"2px"}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this.hoverTarget=this._foregroundContainer.append("circle").classed("hover-target",!0).style("visibility","hidden")},c.prototype._rejectNullsAndNaNs=function(a,b,c){var d=c(a,b);return null!=d&&d===d},c.prototype._getDrawer=function(b){return new a._Drawer.Line(b)},c.prototype._getResetYFunction=function(){var a=this._yScale.domain(),b=Math.max(a[0],a[1]),c=Math.min(a[0],a[1]),d=0>b&&b||c>0&&c||0,e=this._yScale.scale(d);return function(){return e}},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.y=this._getResetYFunction(),a.push({attrToProjector:b,animator:this._getAnimator("reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("main")}),a},c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this),d=this._wholeDatumAttributes(),e=function(a){return-1===d.indexOf(a)},f=d3.keys(c).filter(e);f.forEach(function(a){var b=c[a];c[a]=function(a,c){return a.length>0?b(a[0],c):null}});var g=c.x,h=c.y;return c.defined=function(b,c){return a._rejectNullsAndNaNs(b,c,g)&&a._rejectNullsAndNaNs(b,c,h)},c},c.prototype._wholeDatumAttributes=function(){return["x","y"]},c.prototype._getClosestWithinRange=function(a,b){var c,d,e=this._generateAttrToProjector(),f=e.x,g=e.y,h=function(b,c){var d=+f(b,c)-a.x,e=+g(b,c)-a.y;return d*d+e*e},i=b*b;return this.datasets().forEach(function(a){a.data().forEach(function(a,b){var e=h(a,b);i>e&&(c=a,d={x:f(a,b),y:g(a,b)},i=e)})}),{closestValue:c,closestPoint:d}},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){},c.prototype._doHover=function(a){var b=this._getClosestWithinRange(a,this.hoverDetectionRadius),c=b.closestValue;if(void 0===c)return{data:null,pixelPositions:null,selection:null};var d=b.closestPoint;return this.hoverTarget.attr({cx:b.closestPoint.x,cy:b.closestPoint.y}),{data:[c],pixelPositions:[d],selection:this.hoverTarget}},c}(b.AbstractXYPlot);b.Line=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.classed("area-plot",!0),this.project("y0",0,d),this.project("fill-opacity",function(){return.25});var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this.project("stroke",function(){return e}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),null!=this._yScale&&this._updateYDomainer()},c.prototype._getDrawer=function(b){return new a._Drawer.Area(b)},c.prototype._updateYDomainer=function(){var c=this;b.prototype._updateYDomainer.call(this);var d,e=this._projectors.y0,f=e&&e.accessor;if(null!=f){var g=this.datasets().map(function(a){return a._getExtent(f,c._yScale._typeCoercer)}),h=a._Util.Methods.flatten(g),i=a._Util.Methods.uniq(h);1===i.length&&(d=i[0])}this._yScale._userSetDomainer||(null!=d?this._yScale.domainer().addPaddingException(d,"AREA_PLOT+"+this._plottableID):this._yScale.domainer().removePaddingException("AREA_PLOT+"+this._plottableID),this._yScale._autoDomainIfAutomaticMode())},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"y0"===a&&this._updateYDomainer(),this},c.prototype._getResetYFunction=function(){return this._generateAttrToProjector().y0},c.prototype._wholeDatumAttributes=function(){var a=b.prototype._wholeDatumAttributes.call(this);return a.push("y0"),a},c}(b.Line);b.Area=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(a,b,d){void 0===d&&(d=!0),this._isVertical=d,c.call(this,a,b)}return __extends(d,c),d.prototype._generateAttrToProjector=function(){var a=c.prototype._generateAttrToProjector.call(this),b=this.makeInnerScale(),d=function(){return b.rangeBand()},e=a.height;a.width=this._isVertical?d:e,a.height=this._isVertical?e:d;var f=function(a){return a._PLOTTABLE_PROTECTED_FIELD_POSITION};return a.x=this._isVertical?f:a.x,a.y=this._isVertical?a.y:f,a},d.prototype._getDataToDraw=function(){var b=this,c=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,d=this.makeInnerScale(),e=d3.map();return this._datasetKeysInOrder.forEach(function(f){var g=b._key2DatasetDrawerKey.get(f).dataset.data();e.set(f,g.map(function(e,g){var h=c(e,g),i=b._isVertical?b._xScale:b._yScale,j=a._Util.Methods.copyMap(e);return j._PLOTTABLE_PROTECTED_FIELD_POSITION=i.scale(h)+d.scale(f),j}))}),e},d.prototype.makeInnerScale=function(){var c=new a.Scale.Ordinal;if(c.domain(this._datasetKeysInOrder),this._projectors.width){var d=this._projectors.width,e=d.accessor,f=d.scale,g=f?function(a,b){return f.scale(e(a,b))}:e;c.range([0,g(null,0)])}else{var h=this._isVertical?this._xScale:this._yScale,i=h instanceof a.Scale.Ordinal&&"bands"===h.rangeType(),j=i?h.rangeBand():b.AbstractBarPlot._DEFAULT_WIDTH;c.range([0,j])}return c},d}(b.AbstractBarPlot);b.ClusteredBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.stackedExtent=[0,0]}return __extends(c,b),c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),this._projectors.x&&this._projectors.y&&("x"===a||"y"===a)&&this._updateStackOffsets(),this},c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),this._datasetKeysInOrder&&this._projectors.x&&this._projectors.y&&this._updateStackOffsets()},c.prototype._updateStackOffsets=function(){var b=this._generateDefaultMapArray(),c=this._getDomainKeys(),d=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.max(0,b.get(a).value)}})}),e=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.min(b.get(a).value,0)}})});this._setDatasetStackOffsets(this._stack(d),this._stack(e)),this._updateStackExtents()},c.prototype._updateStackExtents=function(){var b=this.datasets(),c=this._valueAccessor(),d=a._Util.Methods.max(b,function(b){return a._Util.Methods.max(b.data(),function(a){return+c(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0),e=a._Util.Methods.min(b,function(b){return a._Util.Methods.min(b.data(),function(a){return+c(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0);this.stackedExtent=[Math.min(e,0),Math.max(0,d)]},c.prototype._stack=function(a){var b=this,c=function(a,b){a.offset=b};return d3.layout.stack().x(function(a){return a.key}).y(function(a){return+a.value}).values(function(a){return b._getDomainKeys().map(function(b){return a.get(b)})}).out(c)(a),a},c.prototype._setDatasetStackOffsets=function(a,b){var c=this._keyAccessor(),d=this._valueAccessor();this.datasets().forEach(function(e,f){var g=a[f],h=b[f],i=e.data().every(function(a){return d(a)<=0});e.data().forEach(function(a){var b=g.get(c(a)).offset,e=h.get(c(a)).offset,f=d(a);a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET=0===f?i?e:b:f>0?b:e})})},c.prototype._getDomainKeys=function(){var a=this._keyAccessor(),b=d3.set(),c=this.datasets();return c.forEach(function(c){c.data().forEach(function(c){b.add(a(c))})}),b.values()},c.prototype._generateDefaultMapArray=function(){var b=this._keyAccessor(),c=this._valueAccessor(),d=this.datasets(),e=this._getDomainKeys(),f=d.map(function(){return a._Util.Methods.populateMap(e,function(a){return{key:a,value:0} -})});return d.forEach(function(a,d){a.data().forEach(function(a){var e=b(a),g=c(a);f[d].set(e,{key:e,value:g})})}),f},c.prototype._updateScaleExtents=function(){b.prototype._updateScaleExtents.call(this);var a=this._isVertical?this._yScale:this._xScale;a&&(this._isAnchored&&this.stackedExtent.length>0?a._updateExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT",this.stackedExtent):a._removeExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT"))},c.prototype._keyAccessor=function(){return this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor},c.prototype._valueAccessor=function(){return this._isVertical?this._projectors.y.accessor:this._projectors.x.accessor},c}(b.AbstractXYPlot);b.AbstractStacked=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d){c.call(this,b,d),this._baselineValue=0,this.classed("area-plot",!0);var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this._isVertical=!0}return __extends(d,c),d.prototype._getDrawer=function(b){return new a._Drawer.Area(b).drawLine(!1)},d.prototype._setup=function(){c.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},d.prototype._updateStackOffsets=function(){var b=this._getDomainKeys(),d=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,e=this.datasets().map(function(a){return d3.set(a.data().map(function(a,b){return d(a,b).toString()})).values()});e.some(function(a){return a.length!==b.length})&&a._Util.Methods.warn("the domains across the datasets are not the same. Plot may produce unintended behavior."),c.prototype._updateStackOffsets.call(this)},d.prototype._additionalPaint=function(){var a=this._yScale.scale(this._baselineValue),b={x1:0,y1:a,x2:this.width(),y2:a};this._getAnimator("baseline").animate(this._baseline,b)},d.prototype._updateYDomainer=function(){c.prototype._updateYDomainer.call(this);var a=this._yScale;a._userSetDomainer||(a.domainer().addPaddingException(0,"STACKED_AREA_PLOT+"+this._plottableID),a._autoDomainIfAutomaticMode())},d.prototype._onDatasetUpdate=function(){c.prototype._onDatasetUpdate.call(this),b.Area.prototype._onDatasetUpdate.apply(this)},d.prototype._generateAttrToProjector=function(){var a=this,b=c.prototype._generateAttrToProjector.call(this),d=this._wholeDatumAttributes(),e=function(a){return-1===d.indexOf(a)},f=d3.keys(b).filter(e);f.forEach(function(a){var c=b[a];b[a]=function(a,b){return a.length>0?c(a[0],b):null}});var g=this._projectors.y.accessor;return b.y=function(b){return a._yScale.scale(+g(b)+b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},b.y0=function(b){return a._yScale.scale(b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},b},d.prototype._wholeDatumAttributes=function(){return["x","y","defined"]},d}(b.AbstractStacked);b.StackedArea=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=!0),this._isVertical=e,this._baselineValue=0,c.call(this,b,d),this.classed("bar-plot",!0);var f=(new a.Scale.Color).range()[0];this.project("fill",function(){return f}),this.baseline(this._baselineValue),this._isVertical=e}return __extends(d,c),d.prototype._getAnimator=function(b){if(this._animate&&this._animateOnNextRender){if(this._animators[b])return this._animators[b];if("stacked-bar"===b){var c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue);return new a.Animator.MovingRect(d,this._isVertical)}}return new a.Animator.Null},d.prototype._generateAttrToProjector=function(){var a=this,c=b.AbstractBarPlot.prototype._generateAttrToProjector.apply(this),d=this._isVertical?"y":"x",e=this._isVertical?this._yScale:this._xScale,f=this._projectors[d].accessor,g=function(a){return e.scale(a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},h=function(a){return e.scale(+f(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},i=function(a){return Math.abs(h(a)-g(a))},j=c.width;c.height=this._isVertical?i:j,c.width=this._isVertical?j:i;var k=function(a){return+f(a)<0?g(a):h(a)};return c[d]=function(b){return a._isVertical?k(b):k(b)-i(b)},c},d.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("stacked-bar")}]},d.prototype.project=function(a,d,e){return c.prototype.project.call(this,a,d,e),b.AbstractStacked.prototype.project.apply(this,[a,d,e]),this},d.prototype._onDatasetUpdate=function(){return c.prototype._onDatasetUpdate.call(this),b.AbstractStacked.prototype._onDatasetUpdate.apply(this),this},d.prototype._updateStackOffsets=function(){b.AbstractStacked.prototype._updateStackOffsets.call(this)},d.prototype._updateStackExtents=function(){b.AbstractStacked.prototype._updateStackExtents.call(this)},d.prototype._stack=function(a){return b.AbstractStacked.prototype._stack.call(this,a)},d.prototype._setDatasetStackOffsets=function(a,c){b.AbstractStacked.prototype._setDatasetStackOffsets.call(this,a,c)},d.prototype._getDomainKeys=function(){return b.AbstractStacked.prototype._getDomainKeys.call(this)},d.prototype._generateDefaultMapArray=function(){return b.AbstractStacked.prototype._generateDefaultMapArray.call(this)},d.prototype._updateScaleExtents=function(){b.AbstractStacked.prototype._updateScaleExtents.call(this)},d.prototype._keyAccessor=function(){return b.AbstractStacked.prototype._keyAccessor.call(this)},d.prototype._valueAccessor=function(){return b.AbstractStacked.prototype._valueAccessor.call(this)},d.prototype._getBarPixelWidth=function(){return b.AbstractBarPlot.prototype._getBarPixelWidth.apply(this)},d}(b.AbstractBarPlot);b.StackedBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.prototype.getTiming=function(){return 0},a.prototype.animate=function(a,b){return a.attr(b)},a}();a.Null=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._duration=a.DEFAULT_DURATION_MILLISECONDS,this._delay=a.DEFAULT_DELAY_MILLISECONDS,this._easing=a.DEFAULT_EASING,this._maxIterativeDelay=a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS,this._maxTotalDuration=a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS}return a.prototype.getTiming=function(a){var b=Math.max(this.maxTotalDuration()-this.duration(),0),c=Math.min(this.maxIterativeDelay(),b/Math.max(a-1,1)),d=c*a+this.delay()+this.duration();return d},a.prototype.animate=function(a,b){var c=this,d=a[0].length,e=Math.max(this.maxTotalDuration()-this.duration(),0),f=Math.min(this.maxIterativeDelay(),e/Math.max(d-1,1));return a.transition().ease(this.easing()).duration(this.duration()).delay(function(a,b){return c.delay()+f*b}).attr(b)},a.prototype.duration=function(a){return null==a?this._duration:(this._duration=a,this)},a.prototype.delay=function(a){return null==a?this._delay:(this._delay=a,this)},a.prototype.easing=function(a){return null==a?this._easing:(this._easing=a,this)},a.prototype.maxIterativeDelay=function(a){return null==a?this._maxIterativeDelay:(this._maxIterativeDelay=a,this)},a.prototype.maxTotalDuration=function(a){return null==a?this._maxTotalDuration:(this._maxTotalDuration=a,this)},a.DEFAULT_DURATION_MILLISECONDS=300,a.DEFAULT_DELAY_MILLISECONDS=0,a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS=15,a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS=600,a.DEFAULT_EASING="exp-out",a}();a.Base=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===b&&(b=!0),void 0===c&&(c=!1),a.call(this),this.isVertical=b,this.isReverse=c}return __extends(b,a),b.prototype.animate=function(c,d){var e={};return b.ANIMATED_ATTRIBUTES.forEach(function(a){return e[a]=d[a]}),e[this.getMovingAttr()]=this._startMovingProjector(d),e[this.getGrowingAttr()]=function(){return 0},c.attr(e),a.prototype.animate.call(this,c,d)},b.prototype._startMovingProjector=function(a){if(this.isVertical===this.isReverse)return a[this.getMovingAttr()];var b=a[this.getMovingAttr()],c=a[this.getGrowingAttr()];return function(a,d){return b(a,d)+c(a,d)}},b.prototype.getGrowingAttr=function(){return this.isVertical?"height":"width"},b.prototype.getMovingAttr=function(){return this.isVertical?"y":"x"},b.ANIMATED_ATTRIBUTES=["height","width","x","y","fill"],b}(a.Base);a.Rect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===c&&(c=!0),a.call(this,c),this.startPixelValue=b}return __extends(b,a),b.prototype._startMovingProjector=function(){return d3.functor(this.startPixelValue)},b}(a.Rect);a.MovingRect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(b){a.call(this),this._event2Callback={},this.connected=!1,this._target=b}return __extends(b,a),b.prototype.target=function(a){if(null==a)return this._target;var b=this.connected;return this.disconnect(),this._target=a,b&&this.connect(),this},b.prototype._getEventString=function(a){return a+".dispatcher"+this._plottableID},b.prototype.connect=function(){var a=this;if(this.connected)throw new Error("Can't connect dispatcher twice!");return this._target&&(this.connected=!0,Object.keys(this._event2Callback).forEach(function(b){var c=a._event2Callback[b];a._target.on(a._getEventString(b),c)})),this},b.prototype.disconnect=function(){var a=this;return this.connected=!1,this._target&&Object.keys(this._event2Callback).forEach(function(b){a._target.on(a._getEventString(b),null)}),this},b}(a.Core.PlottableObject);b.AbstractDispatcher=c}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this._event2Callback.mouseover=function(){null!=c._mouseover&&c._mouseover(c.getMousePosition())},this._event2Callback.mousemove=function(){null!=c._mousemove&&c._mousemove(c.getMousePosition())},this._event2Callback.mouseout=function(){null!=c._mouseout&&c._mouseout(c.getMousePosition())}}return __extends(b,a),b.prototype.getMousePosition=function(){var a=d3.mouse(this._target.node());return{x:a[0],y:a[1]}},b.prototype.mouseover=function(a){return void 0===a?this._mouseover:(this._mouseover=a,this)},b.prototype.mousemove=function(a){return void 0===a?this._mousemove:(this._mousemove=a,this)},b.prototype.mouseout=function(a){return void 0===a?this._mouseout:(this._mouseout=a,this)},b}(a.AbstractDispatcher);a.Mouse=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this.mousedOverTarget=!1,this.keydownListenerTarget=d3.select(document),this._event2Callback.mouseover=function(){c.mousedOverTarget=!0},this._event2Callback.mouseout=function(){c.mousedOverTarget=!1}}return __extends(b,a),b.prototype.connect=function(){var b=this;return a.prototype.connect.call(this),this.keydownListenerTarget.on(this._getEventString("keydown"),function(){b.mousedOverTarget&&b._onKeyDown&&b._onKeyDown(d3.event)}),this},b.prototype.disconnect=function(){return a.prototype.disconnect.call(this),this.keydownListenerTarget.on(this._getEventString("keydown"),null),this},b.prototype.onKeyDown=function(a){return void 0===a?this._onKeyDown:(this._onKeyDown=a,this)},b}(a.AbstractDispatcher);a.Keypress=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(a,b){this._componentToListenTo=a,this._hitBox=b},b}(a.Core.PlottableObject);b.AbstractInteraction=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(b,c){var d=this;a.prototype._anchor.call(this,b,c),c.on(this._listenTo(),function(){var a=d3.mouse(c.node()),b=a[0],e=a[1];d._callback({x:b,y:e})})},b.prototype._listenTo=function(){return"click"},b.prototype.callback=function(a){return this._callback=a,this},b}(a.AbstractInteraction);a.Click=b;var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._listenTo=function(){return"dblclick"},b}(b);a.DoubleClick=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.activated=!1,this.keyCode2Callback={},this.dispatcher=new a.Dispatcher.Keypress}return __extends(c,b),c.prototype._anchor=function(a,c){var d=this;b.prototype._anchor.call(this,a,c),this.dispatcher.target(this._hitBox),this.dispatcher.onKeyDown(function(a){d.keyCode2Callback[a.keyCode]&&d.keyCode2Callback[a.keyCode]()}),this.dispatcher.connect()},c.prototype.on=function(a,b){return this.keyCode2Callback[a]=b,this},c}(b.AbstractInteraction);b.Key=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;b.call(this),null==c&&(c=new a.Scale.Linear),null==d&&(d=new a.Scale.Linear),this._xScale=c,this._yScale=d,this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return e.rerenderZoomed()})}return __extends(c,b),c.prototype.resetZoom=function(){var a=this;this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return a.rerenderZoomed()}),this.zoom(this._hitBox)},c.prototype._anchor=function(a,c){b.prototype._anchor.call(this,a,c),this.zoom(c)},c.prototype.rerenderZoomed=function(){var a=this._xScale._d3Scale.domain(),b=this._yScale._d3Scale.domain();this._xScale.domain(a),this._yScale.domain(b)},c}(b.AbstractInteraction);b.PanZoom=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentBar=null,this._hoverMode="point"}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),a._Util.Methods.warn("Interaction.BarHover is deprecated; please use Interaction.Hover instead"),this.plotIsVertical=this._componentToListenTo._isVertical,this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mousemove(function(a){var b=e.getHoveredBar(a);if(null==b)e._hoverOut();else{if(null!=e.currentBar){if(e.currentBar.node()===b.node())return;e._hoverOut()}e.getBars().classed("not-hovered",!0).classed("hovered",!1),b.classed("not-hovered",!1).classed("hovered",!0),null!=e.hoverCallback&&e.hoverCallback(b.data()[0],b)}e.currentBar=b}),this.dispatcher.mouseout(function(){return e._hoverOut()}),this.dispatcher.connect()},c.prototype.getBars=function(){return this._componentToListenTo._renderArea.selectAll("rect")},c.prototype._hoverOut=function(){this.getBars().classed("not-hovered hovered",!1),null!=this.unhoverCallback&&null!=this.currentBar&&this.unhoverCallback(this.currentBar.data()[0],this.currentBar),this.currentBar=null},c.prototype.getHoveredBar=function(a){if("point"===this._hoverMode)return this._componentToListenTo.selectBar(a.x,a.y,!1);var b={min:-1/0,max:1/0};return this.plotIsVertical?this._componentToListenTo.selectBar(a.x,b,!1):this._componentToListenTo.selectBar(b,a.y,!1)},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode for Interaction.BarHover");return this._hoverMode=b,this},c.prototype.onHover=function(a){return this.hoverCallback=a,this},c.prototype.onUnhover=function(a){return this.unhoverCallback=a,this},c}(b.AbstractInteraction);b.BarHover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){var b=this;a.call(this),this.dragInitialized=!1,this._origin=[0,0],this._location=[0,0],this.dragBehavior=d3.behavior.drag(),this.dragBehavior.on("dragstart",function(){return b._dragstart()}),this.dragBehavior.on("drag",function(){return b._drag()}),this.dragBehavior.on("dragend",function(){return b._dragend()})}return __extends(b,a),b.prototype.dragstart=function(a){return void 0===a?this.ondragstart:(this.ondragstart=a,this)},b.prototype.drag=function(a){return void 0===a?this.ondrag:(this.ondrag=a,this)},b.prototype.dragend=function(a){return void 0===a?this.ondragend:(this.ondragend=a,this)},b.prototype._dragstart=function(){var a=this._componentToListenTo.width(),b=this._componentToListenTo.height(),c=function(a,b){return function(c){return Math.min(Math.max(c,a),b)}};this.constrainX=c(0,a),this.constrainY=c(0,b)},b.prototype._doDragstart=function(){null!=this.ondragstart&&this.ondragstart({x:this._origin[0],y:this._origin[1]})},b.prototype._drag=function(){this.dragInitialized||(this._origin=[d3.event.x,d3.event.y],this.dragInitialized=!0,this._doDragstart()),this._location=[this.constrainX(d3.event.x),this.constrainY(d3.event.y)],this._doDrag()},b.prototype._doDrag=function(){if(null!=this.ondrag){var a={x:this._origin[0],y:this._origin[1]},b={x:this._location[0],y:this._location[1]};this.ondrag(a,b)}},b.prototype._dragend=function(){this.dragInitialized&&(this.dragInitialized=!1,this._doDragend())},b.prototype._doDragend=function(){if(null!=this.ondragend){var a={x:this._origin[0],y:this._origin[1]},b={x:this._location[0],y:this._location[1]};this.ondragend(a,b)}},b.prototype._anchor=function(b,c){return a.prototype._anchor.call(this,b,c),c.call(this.dragBehavior),this},b.prototype.setupZoomCallback=function(a,b){function c(c,g){return null==c||null==g?(f&&(null!=a&&a.domain(d),null!=b&&b.domain(e)),void(f=!f)):(f=!1,null!=a&&a.domain([a.invert(c.x),a.invert(g.x)]),null!=b&&b.domain([b.invert(g.y),b.invert(c.y)]),void this.clearBox())}var d=null!=a?a.domain():null,e=null!=b?b.domain():null,f=!1;return this.drag(c),this.dragend(c),this},b}(a.AbstractInteraction);a.Drag=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.boxIsDrawn=!1}return __extends(b,a),b.prototype._dragstart=function(){a.prototype._dragstart.call(this),this.clearBox()},b.prototype.clearBox=function(){return null!=this.dragBox?(this.dragBox.attr("height",0).attr("width",0),this.boxIsDrawn=!1,this):void 0},b.prototype.setBox=function(a,b,c,d){if(null!=this.dragBox){var e=Math.abs(a-b),f=Math.abs(c-d),g=Math.min(a,b),h=Math.min(c,d);return this.dragBox.attr({x:g,y:h,width:e,height:f}),this.boxIsDrawn=e>0&&f>0,this}},b.prototype._anchor=function(c,d){a.prototype._anchor.call(this,c,d);var e=b.CLASS_DRAG_BOX,f=this._componentToListenTo._backgroundContainer;return this.dragBox=f.append("rect").classed(e,!0).attr("x",0).attr("y",0),this},b.CLASS_DRAG_BOX="drag-box",b}(a.Drag);a.DragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[0],this._location[0])},b.prototype.setBox=function(b,c){return a.prototype.setBox.call(this,b,c,0,this._componentToListenTo.height()),this},b}(a.DragBox);a.XDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[0],this._location[0],this._origin[1],this._location[1])},b}(a.DragBox);a.XYDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[1],this._location[1])},b.prototype.setBox=function(b,c){return a.prototype.setBox.call(this,0,this._componentToListenTo.width(),b,c),this},b}(a.DragBox);a.YDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentHoverData={data:null,pixelPositions:null,selection:null}}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mouseover(function(a){e._componentToListenTo._hoverOverComponent(a),e.handleHoverOver(a)}),this.dispatcher.mouseout(function(a){e._componentToListenTo._hoverOutComponent(a),e.safeHoverOut(e.currentHoverData),e.currentHoverData={data:null,pixelPositions:null,selection:null}}),this.dispatcher.mousemove(function(a){return e.handleHoverOver(a)}),this.dispatcher.connect()},c.diffHoverData=function(a,b){if(null==a.data||null==b.data)return a;var c=[],d=[],e=[];return a.data.forEach(function(f,g){-1===b.data.indexOf(f)&&(c.push(f),d.push(a.pixelPositions[g]),e.push(a.selection[0][g]))}),0===c.length?{data:null,pixelPositions:null,selection:null}:{data:c,pixelPositions:d,selection:d3.selectAll(e)}},c.prototype.handleHoverOver=function(a){var b=this.currentHoverData,d=this._componentToListenTo._doHover(a);this.currentHoverData=d;var e=c.diffHoverData(b,d);this.safeHoverOut(e);var f=c.diffHoverData(d,b);this.safeHoverOver(f)},c.prototype.safeHoverOut=function(a){this.hoverOutCallback&&a.data&&this.hoverOutCallback(a)},c.prototype.safeHoverOver=function(a){this.hoverOverCallback&&a.data&&this.hoverOverCallback(a)},c.prototype.onHoverOver=function(a){return this.hoverOverCallback=a,this},c.prototype.onHoverOut=function(a){return this.hoverOutCallback=a,this},c.prototype.getCurrentHoverData=function(){return this.currentHoverData},c}(b.AbstractInteraction);b.Hover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={})); \ No newline at end of file +var Plottable;!function(a){!function(b){!function(b){function c(a,b,c){return Math.min(b,c)<=a&&a<=Math.max(b,c)}function d(b){a.Config.SHOW_WARNINGS&&null!=window.console&&(null!=window.console.warn?console.warn(b):null!=window.console.log&&console.log(b))}function e(a,b){if(a.length!==b.length)throw new Error("attempted to add arrays of unequal length");return a.map(function(c,d){return a[d]+b[d]})}function f(a,b){var c=d3.set();return a.forEach(function(a){b.has(a)&&c.add(a)}),c}function g(a){return"function"==typeof a?a:"string"==typeof a&&"#"!==a[0]?function(b){return b[a]}:function(){return a}}function h(a,b){var c=d3.set();return a.forEach(function(a){return c.add(a)}),b.forEach(function(a){return c.add(a)}),c}function i(a,b){var c=d3.map();return a.forEach(function(a,d){c.set(a,b(a,d))}),c}function j(a){var b=d3.set(),c=[];return a.forEach(function(a){b.has(a)||(b.add(a),c.push(a))}),c}function k(a,b){for(var c=[],d=0;b>d;d++)c[d]="function"==typeof a?a(d):a;return c}function l(a){return Array.prototype.concat.apply([],a)}function m(a,b){if(null==a||null==b)return a===b;if(a.length!==b.length)return!1;for(var c=0;cf;++f)e[f]=a+c*f;return e}function s(a,b){for(var c=[],d=2;db?"0"+c:c});if(4===d.length&&"00"===d[3])return null;var e="#"+d.join("");return a.classed(b,!1),e}b.inRange=c,b.warn=d,b.addArrays=e,b.intersection=f,b.accessorize=g,b.union=h,b.populateMap=i,b.uniq=j,b.createFilledArray=k,b.flatten=l,b.arrayEq=m,b.objEq=n,b.max=o,b.min=p,b.copyMap=q,b.range=r,b.setTimeout=s,b.colorTest=t}(b.Methods||(b.Methods={}));b.Methods}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a,b,c){for(var d=0,e=b.length;e>d;){var f=d+e>>>1,g=null==c?b[f]:c(b[f]);a>g?d=f+1:e=f}return d}a.sortedIndex=b}(a.OpenSource||(a.OpenSource={}));a.OpenSource}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.counter={}}return a.prototype.setDefault=function(a){null==this.counter[a]&&(this.counter[a]=0)},a.prototype.increment=function(a){return this.setDefault(a),++this.counter[a]},a.prototype.decrement=function(a){return this.setDefault(a),--this.counter[a]},a.prototype.get=function(a){return this.setDefault(a),this.counter[a]},a}();a.IDCounter=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.keyValuePairs=[]}return a.prototype.set=function(a,b){if(a!==a)throw new Error("NaN may not be used as a key to the StrictEqualityAssociativeArray");for(var c=0;cb){var h=e("."),i=Math.floor(b/h);return"...".substr(0,i)}for(;f+g>b;)d=d.substr(0,d.length-1).trim(),f=e(d);if(e(d+"...")>b)throw new Error("addEllipsesToLine failed :(");return d+"..."}function i(b,c,d,e,f,g){void 0===f&&(f="left"),void 0===g&&(g="top");var h={left:0,center:.5,right:1},i={top:0,center:.5,bottom:1};if(void 0===h[f]||void 0===i[g])throw new Error("unrecognized alignment x:"+f+", y:"+g);var j=c.append("g"),k=j.append("text");k.text(b);var l=a.DOM.getBBox(k),m=l.height,n=l.width;if(n>d||m>e)return a.Methods.warn("Insufficient space to fit text: "+b),k.text(""),{width:0,height:0};var o={left:"start",center:"middle",right:"end"},p=o[f],q=d*h[f],r=e*i[g],s=.85-i[g];return k.attr("text-anchor",p).attr("y",s+"em"),a.DOM.translate(j,q,r),{width:n,height:m}}function j(a,b,c,d,e,f,g){if(void 0===e&&(e="left"),void 0===f&&(f="top"),void 0===g&&(g="right"),"right"!==g&&"left"!==g)throw new Error("unrecognized rotation: "+g);var h="right"===g,j={left:"bottom",right:"top",center:"center",top:"left",bottom:"right"},k={left:"top",right:"bottom",center:"center",top:"right",bottom:"left"},l=h?j:k,m=b.append("g"),n=i(a,m,d,c,l[f],l[e]),o=d3.transform("");return o.rotate="right"===g?90:-90,o.translate=[h?c:0,h?0:d],m.attr("transform",o.toString()),m.classed("rotated-"+g,!0),{width:n.height,height:n.width}}function k(d,e,f,g,h,j){void 0===h&&(h="left"),void 0===j&&(j="top");var k=c(e.append("text"))(b.HEIGHT_TEXT).height,l=0,m=e.append("g");d.forEach(function(b,c){var d=m.append("g");a.DOM.translate(d,0,c*k);var e=i(b,d,f,k,h,j);e.width>l&&(l=e.width)});var n=k*d.length,o=g-n,p={center:.5,top:0,bottom:1};return a.DOM.translate(m,0,o*p[j]),{width:l,height:n}}function l(d,e,f,g,h,i,k){void 0===h&&(h="left"),void 0===i&&(i="top"),void 0===k&&(k="left");var l=c(e.append("text"))(b.HEIGHT_TEXT).height,m=0,n=e.append("g");d.forEach(function(b,c){var d=n.append("g");a.DOM.translate(d,c*l,0);var e=j(b,d,l,g,h,i,k);e.height>m&&(m=e.height)});var o=l*d.length,p=f-o,q={center:.5,left:0,right:1};return a.DOM.translate(n,p*q[h],0),{width:o,height:m}}function m(b,c,d,e,f,g){if(void 0===f&&(f="horizontal"),-1===["left","right","horizontal"].indexOf(f))throw new Error("Unrecognized orientation to writeText: "+f);var h="horizontal"===f,i=h?c:d,j=h?d:c,m=a.WordWrap.breakTextToFitRect(b,i,j,e);if(0===m.lines.length)return{textFits:m.textFits,usedWidth:0,usedHeight:0};var n,o;if(null==g){var p=h?a.Methods.max:d3.sum,q=h?d3.sum:a.Methods.max,r=function(a){return h?e(a).height:e(a).width},s=function(a){return h?e(a).width:e(a).height};n=p(m.lines,s,0),o=q(m.lines,r,0)}else{var t=g.g.append("g").classed("writeText-inner-g",!0),u=h?k:l,v=u.call(this,m.lines,t,c,d,g.xAlign,g.yAlign,f);n=v.width,o=v.height}return{textFits:m.textFits,usedWidth:n,usedHeight:o}}b.HEIGHT_TEXT="bqpdl",b.getTextMeasurer=c;var n="a",o=function(){function b(b){var g=this;this.cache=new a.Cache(c(b),n,a.Methods.objEq),this.measure=d(e(f(function(a){return g.cache.get(a)})))}return b.prototype.clear=function(){return this.cache.clear(),this},b}();b.CachingCharacterMeasurer=o,b.getTruncatedText=g,b.addEllipsesToLine=h,b.writeLineHorizontally=i,b.writeLineVertically=j,b.writeText=m}(a.Text||(a.Text={}));a.Text}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(b){function c(b,c,e,f){var g=function(a){return f(a).width},h=d(b,c,g),i=f("hello world").height,j=Math.floor(e/i),k=j>=h.length;return k||(h=h.splice(0,j),j>0&&(h[j-1]=a.Text.addEllipsesToLine(h[j-1],c,f))),{originalText:b,lines:h,textFits:k}}function d(a,b,c){for(var d=[],e=a.split("\n"),g=0,h=e.length;h>g;g++){var i=e[g];null!==i?d=d.concat(f(i,b,c)):d.push("")}return d}function e(b,c,d){var e=h(b),f=e.map(d),g=a.Methods.max(f,0);return c>=g}function f(a,b,c){for(var d,e=[],f=h(a),i="",j=0;d||je;e++){var g=a[e];""===c||j(c[0],g,d)?c+=g:(b.push(c),c=g),d=g}return c&&b.push(c),b}function i(a){return null==a?!0:""===a.trim()}function j(a,b,c){return m.test(a)&&m.test(b)?!0:m.test(a)||m.test(b)?!1:l.test(c)||k.test(b)?!1:!0}var k=/[{\[]/,l=/[!"%),-.:;?\]}]/,m=/^\s+$/;b.breakTextToFitRect=c,b.canWrapWithoutBreakingWords=e}(a.WordWrap||(a.WordWrap={}));a.WordWrap}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b;try{b=a.node().getBBox()}catch(c){b={x:0,y:0,width:0,height:0}}return b}function c(b){null!=window.requestAnimationFrame?window.requestAnimationFrame(b):setTimeout(b,a.POLYFILL_TIMEOUT_MSEC)}function d(a,b){var c=a.getPropertyValue(b),d=parseFloat(c);return d!==d?0:d}function e(a){for(var b=a.node();null!==b&&"svg"!==b.nodeName;)b=b.parentNode;return null==b}function f(a){var b=window.getComputedStyle(a);return d(b,"width")+d(b,"padding-left")+d(b,"padding-right")+d(b,"border-left-width")+d(b,"border-right-width")}function g(a){var b=window.getComputedStyle(a);return d(b,"height")+d(b,"padding-top")+d(b,"padding-bottom")+d(b,"border-top-width")+d(b,"border-bottom-width")}function h(a){var b=a.node().clientWidth;if(0===b){var c=a.attr("width");if(-1!==c.indexOf("%")){for(var d=a.node().parentNode;null!=d&&0===d.clientWidth;)d=d.parentNode;if(null==d)throw new Error("Could not compute width of element");b=d.clientWidth*parseFloat(c)/100}else b=parseFloat(c)}return b}function i(a,b,c){var d=d3.transform(a.attr("transform"));return null==b?d.translate:(c=null==c?0:c,d.translate[0]=b,d.translate[1]=c,a.attr("transform",d.toString()),a)}function j(a,b){return a.rightb.right?!1:a.bottomb.bottom?!1:!0}a.getBBox=b,a.POLYFILL_TIMEOUT_MSEC=1e3/60,a.requestAnimationFramePolyfill=c,a.isSelectionRemovedFromSVG=e,a.getElementWidth=f,a.getElementHeight=g,a.getSVGPixelWidth=h,a.translate=i,a.boxesOverlap=j}(a.DOM||(a.DOM={}));a.DOM}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b=d3.rgb(a),c=function(a){return a/=255,.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4)},d=c(b.r),e=c(b.g),f=c(b.b);return.2126*d+.7152*e+.0722*f}function c(a,c){var d=b(a)+.05,e=b(c)+.05;return d>e?d/e:e/d}a.contrast=c}(a.Color||(a.Color={}));a.Color}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){a.MILLISECONDS_IN_ONE_DAY=864e5,function(b){function c(a,c,d){void 0===a&&(a=2),void 0===c&&(c="$"),void 0===d&&(d=!0);var e=b.fixed(a);return function(a){var b=e(Math.abs(a));return""!==b&&(d?b=c+b:b+=c,0>a&&(b="-"+b)),b}}function d(a){return void 0===a&&(a=3),l(a),function(b){return b.toFixed(a)}}function e(a){return void 0===a&&(a=3),l(a),function(b){if("number"==typeof b){var c=Math.pow(10,a);return String(Math.round(b*c)/c)}return String(b)}}function f(){return function(a){return String(a)}}function g(a){void 0===a&&(a=0);var c=b.fixed(a);return function(a){var b=100*a,d=a.toString(),e=Math.pow(10,d.length-(d.indexOf(".")+1));return b=parseInt((b*e).toString(),10)/e,c(b)+"%"}}function h(a){return void 0===a&&(a=3),l(a),function(b){return d3.format("."+a+"s")(b)}}function i(){var a=8,b={};return b[0]={format:".%L",filter:function(a){return 0!==a.getMilliseconds()}},b[1]={format:":%S",filter:function(a){return 0!==a.getSeconds()}},b[2]={format:"%I:%M",filter:function(a){return 0!==a.getMinutes()}},b[3]={format:"%I %p",filter:function(a){return 0!==a.getHours()}},b[4]={format:"%a %d",filter:function(a){return 0!==a.getDay()&&1!==a.getDate()}},b[5]={format:"%b %d",filter:function(a){return 1!==a.getDate()}},b[6]={format:"%b",filter:function(a){return 0!==a.getMonth()}},b[7]={format:"%Y",filter:function(){return!0}},function(c){for(var d=0;a>d;d++)if(b[d].filter(c))return d3.time.format(b[d].format)(c)}}function j(a){return d3.time.format(a)}function k(b,c,d){return void 0===b&&(b=0),void 0===c&&(c=a.MILLISECONDS_IN_ONE_DAY),void 0===d&&(d=""),function(a){var e=Math.round((a.valueOf()-b)/c);return e.toString()+d}}function l(a){if(0>a||a>20)throw new RangeError("Formatter precision must be between 0 and 20")}b.currency=c,b.fixed=d,b.general=e,b.identity=f,b.percentage=g,b.siSuffix=h,b.multiTime=i,b.time=j,b.relativeDate=k}(a.Formatters||(a.Formatters={}));a.Formatters}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){a.SHOW_WARNINGS=!0}(a.Config||(a.Config={}));a.Config}(Plottable||(Plottable={}));var Plottable;!function(a){a.version="0.37.0"}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.CORAL_RED="#fd373e",a.INDIGO="#5279c7",a.ROBINS_EGG_BLUE="#06cccc",a.FERN="#63c261",a.BURNING_ORANGE="#ff7939",a.ROYAL_HEATH="#962565",a.CONIFER="#99ce50",a.CERISE_RED="#db2e65",a.BRIGHT_SUN="#fad419",a.JACARTA="#2c2b6f",a.PLOTTABLE_COLORS=[a.INDIGO,a.CORAL_RED,a.FERN,a.BRIGHT_SUN,a.JACARTA,a.BURNING_ORANGE,a.CERISE_RED,a.CONIFER,a.ROYAL_HEATH,a.ROBINS_EGG_BLUE],a}();a.Colors=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._plottableID=a.nextID++}return a.nextID=0,a}();a.PlottableObject=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this.key2callback=new a._Util.StrictEqualityAssociativeArray,this.listenable=c}return __extends(c,b),c.prototype.registerListener=function(a,b){return this.key2callback.set(a,b),this},c.prototype.broadcast=function(){for(var a=this,b=[],c=0;c0){var f=d.valueOf();return d instanceof Date?[f-b.ONE_DAY,f+b.ONE_DAY]:[f-b.PADDING_FOR_IDENTICAL_DOMAIN,f+b.PADDING_FOR_IDENTICAL_DOMAIN]}if(a.domain()[0]===a.domain()[1])return c;var g=this.padProportion/2,h=a.invert(a.scale(d)-(a.scale(e)-a.scale(d))*g),i=a.invert(a.scale(e)+(a.scale(e)-a.scale(d))*g),j=this.paddingExceptions.values().concat(this.unregisteredPaddingExceptions.values()),k=d3.set(j);return k.has(d)&&(h=d),k.has(e)&&(i=e),[h,i]},b.prototype.niceDomain=function(a,b){return this.doNice?a._niceDomain(b,this.niceCount):b},b.prototype.includeDomain=function(a){var b=this.includedValues.values().concat(this.unregisteredIncludedValues.values());return b.reduce(function(a,b){return[Math.min(a[0],b),Math.max(a[1],b)]},a)},b.PADDING_FOR_IDENTICAL_DOMAIN=1,b.ONE_DAY=864e5,b}();a.Domainer=b}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this._autoDomainAutomatically=!0,this.broadcaster=new a.Core.Broadcaster(this),this._rendererAttrID2Extent={},this._typeCoercer=function(a){return a},this._domainModificationInProgress=!1,this._d3Scale=c}return __extends(c,b),c.prototype._getAllExtents=function(){return d3.values(this._rendererAttrID2Extent)},c.prototype._getExtent=function(){return[]},c.prototype.autoDomain=function(){return this._autoDomainAutomatically=!0,this._setDomain(this._getExtent()),this},c.prototype._autoDomainIfAutomaticMode=function(){this._autoDomainAutomatically&&this.autoDomain()},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype.domain=function(a){return null==a?this._getDomain():(this._autoDomainAutomatically=!1,this._setDomain(a),this)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setDomain=function(a){this._domainModificationInProgress||(this._domainModificationInProgress=!0,this._d3Scale.domain(a),this.broadcaster.broadcast(),this._domainModificationInProgress=!1)},c.prototype.range=function(a){return null==a?this._d3Scale.range():(this._d3Scale.range(a),this)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._updateExtent=function(a,b,c){return this._rendererAttrID2Extent[a+b]=c,this._autoDomainIfAutomaticMode(),this},c.prototype._removeExtent=function(a,b){return delete this._rendererAttrID2Extent[a+b],this._autoDomainIfAutomaticMode(),this},c}(a.Core.PlottableObject);b.AbstractScale=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this,c),this._numTicks=10,this._PADDING_FOR_IDENTICAL_DOMAIN=1,this._userSetDomainer=!1,this._domainer=new a.Domainer,this._typeCoercer=function(a){return+a},this._tickGenerator=function(a){return a.getDefaultTicks()}}return __extends(c,b),c.prototype._getExtent=function(){return this._domainer.computeDomain(this._getAllExtents(),this)},c.prototype.invert=function(a){return this._d3Scale.invert(a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(c){var d=function(a){return a!==a||1/0===a||a===-1/0};return d(c[0])||d(c[1])?void a._Util.Methods.warn("Warning: QuantitativeScales cannot take NaN or Infinity as a domain value. Ignoring."):void b.prototype._setDomain.call(this,c)},c.prototype.interpolate=function(a){return null==a?this._d3Scale.interpolate():(this._d3Scale.interpolate(a),this)},c.prototype.rangeRound=function(a){return this._d3Scale.rangeRound(a),this},c.prototype.getDefaultTicks=function(){return this._d3Scale.ticks(this.numTicks())},c.prototype.clamp=function(a){return null==a?this._d3Scale.clamp():(this._d3Scale.clamp(a),this)},c.prototype.ticks=function(){return this._tickGenerator(this)},c.prototype.numTicks=function(a){return null==a?this._numTicks:(this._numTicks=a,this)},c.prototype._niceDomain=function(a,b){return this._d3Scale.copy().domain(a).nice(b).domain()},c.prototype.domainer=function(a){return null==a?this._domainer:(this._domainer=a,this._userSetDomainer=!0,this._autoDomainIfAutomaticMode(),this)},c.prototype._defaultExtent=function(){return[0,1]},c.prototype.tickGenerator=function(a){return null==a?this._tickGenerator:(this._tickGenerator=a,this)},c}(b.AbstractScale);b.AbstractQuantitative=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){a.call(this,null==b?d3.scale.linear():b)}return __extends(b,a),b.prototype.copy=function(){return new b(this._d3Scale.copy())},b}(a.AbstractQuantitative);a.Linear=b}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(d){b.call(this,null==d?d3.scale.log():d),c.warned||(c.warned=!0,a._Util.Methods.warn("Plottable.Scale.Log is deprecated. If possible, use Plottable.Scale.ModifiedLog instead."))}return __extends(c,b),c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){return[1,10]},c.warned=!1,c}(b.AbstractQuantitative);b.Log=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(void 0===a&&(a=10),b.call(this,d3.scale.linear()),this._showIntermediateTicks=!1,this.base=a,this.pivot=this.base,this.untransformedDomain=this._defaultExtent(),this._numTicks=10,1>=a)throw new Error("ModifiedLogScale: The base must be > 1")}return __extends(c,b),c.prototype.adjustedLog=function(a){var b=0>a?-1:1;return a*=b,aa?-1:1;return a*=b,a=Math.pow(this.base,a),a=d&&e>=a}),m=j.concat(l).concat(k);return m.length<=1&&(m=d3.scale.linear().domain([d,e]).ticks(b)),m},c.prototype.logTicks=function(b,c){var d=this,e=this.howManyTicks(b,c);if(0===e)return[];var f=Math.floor(Math.log(b)/Math.log(this.base)),g=Math.ceil(Math.log(c)/Math.log(this.base)),h=d3.range(g,f,-Math.ceil((g-f)/e)),i=this._showIntermediateTicks?Math.floor(e/h.length):1,j=d3.range(this.base,1,-(this.base-1)/i).map(Math.floor),k=a._Util.Methods.uniq(j),l=h.map(function(a){return k.map(function(b){return Math.pow(d.base,a-1)*b})}),m=a._Util.Methods.flatten(l),n=m.filter(function(a){return a>=b&&c>=a}),o=n.sort(function(a,b){return a-b});return o},c.prototype.howManyTicks=function(b,c){var d=this.adjustedLog(a._Util.Methods.min(this.untransformedDomain,0)),e=this.adjustedLog(a._Util.Methods.max(this.untransformedDomain,0)),f=this.adjustedLog(b),g=this.adjustedLog(c),h=(g-f)/(e-d),i=Math.ceil(h*this._numTicks);return i},c.prototype.copy=function(){return new c(this.base)},c.prototype._niceDomain=function(a){return a},c.prototype.showIntermediateTicks=function(a){return null==a?this._showIntermediateTicks:void(this._showIntermediateTicks=a)},c}(b.AbstractQuantitative);b.ModifiedLog=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(b.call(this,null==a?d3.scale.ordinal():a),this._range=[0,1],this._rangeType="bands",this._innerPadding=.3,this._outerPadding=.5,this._typeCoercer=function(a){return null!=a&&a.toString?a.toString():a},this._innerPadding>this._outerPadding)throw new Error("outerPadding must be >= innerPadding so cat axis bands work out reasonably")}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents();return a._Util.Methods.uniq(a._Util.Methods.flatten(b))},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(a){b.prototype._setDomain.call(this,a),this.range(this.range())},c.prototype.range=function(a){return null==a?this._range:(this._range=a,"points"===this._rangeType?this._d3Scale.rangePoints(a,2*this._outerPadding):"bands"===this._rangeType&&this._d3Scale.rangeBands(a,this._innerPadding,this._outerPadding),this)},c.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},c.prototype.innerPadding=function(){var a=this.domain(); +if(a.length<2)return 0;var b=Math.abs(this.scale(a[1])-this.scale(a[0]));return b-this.rangeBand()},c.prototype.fullBandStartAndWidth=function(a){var b=this.scale(a)-this.innerPadding()/2,c=this.rangeBand()+this.innerPadding();return[b,c]},c.prototype.rangeType=function(a,b,c){if(null==a)return this._rangeType;if("points"!==a&&"bands"!==a)throw new Error("Unsupported range type: "+a);return this._rangeType=a,null!=b&&(this._outerPadding=b),null!=c&&(this._innerPadding=c),this.range(this.range()),this.broadcaster.broadcast(),this},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c}(b.AbstractScale);b.Ordinal=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var d;switch(a){case null:case void 0:d=d3.scale.ordinal().range(c.getPlottableColors());break;case"Category10":case"category10":case"10":d=d3.scale.category10();break;case"Category20":case"category20":case"20":d=d3.scale.category20();break;case"Category20b":case"category20b":case"20b":d=d3.scale.category20b();break;case"Category20c":case"category20c":case"20c":d=d3.scale.category20c();break;default:throw new Error("Unsupported ColorScale type")}b.call(this,d)}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents(),c=[];return b.forEach(function(a){c=c.concat(a)}),a._Util.Methods.uniq(c)},c.getPlottableColors=function(){for(var b,c=[],d=d3.select("body").append("div"),e=0;null!==(b=a._Util.Methods.colorTest(d,"plottable-colors-"+e));)c.push(b),e++;return d.remove(),c},c}(b.AbstractScale);b.Color=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,null==a?d3.time.scale():a),this._typeCoercer=function(a){return a&&a._isAMomentObject||a instanceof Date?a:new Date(a)}}return __extends(c,b),c.prototype._tickInterval=function(a,b){var c=d3.time.scale();return c.domain(this.domain()),c.range(this.range()),c.ticks(a.range,b)},c.prototype._setDomain=function(a){return a=a.map(this._typeCoercer),b.prototype._setDomain.call(this,a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){var b=(new Date).valueOf(),c=b-a.MILLISECONDS_IN_ONE_DAY;return[c,b]},c}(b.AbstractQuantitative);b.Time=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,d){void 0===a&&(a="reds"),void 0===d&&(d="linear"),this._colorRange=this._resolveColorValues(a),this._scaleType=d,b.call(this,c.getD3InterpolatedScale(this._colorRange,this._scaleType))}return __extends(c,b),c.getD3InterpolatedScale=function(a,b){var d;switch(b){case"linear":d=d3.scale.linear();break;case"log":d=d3.scale.log();break;case"sqrt":d=d3.scale.sqrt();break;case"pow":d=d3.scale.pow()}if(null==d)throw new Error("unknown Quantitative scale type "+b);return d.range([0,1]).interpolate(c.interpolateColors(a))},c.interpolateColors=function(a){if(a.length<2)throw new Error("Color scale arrays must have at least two elements.");return function(){return function(b){b=Math.max(0,Math.min(1,b));var c=b*(a.length-1),d=Math.floor(c),e=Math.ceil(c),f=c-d;return d3.interpolateLab(a[d],a[e])(f)}}},c.prototype.colorRange=function(a){return null==a?this._colorRange:(this._colorRange=this._resolveColorValues(a),this._resetScale(),this)},c.prototype.scaleType=function(a){return null==a?this._scaleType:(this._scaleType=a,this._resetScale(),this)},c.prototype._resetScale=function(){this._d3Scale=c.getD3InterpolatedScale(this._colorRange,this._scaleType),this._autoDomainIfAutomaticMode(),this.broadcaster.broadcast()},c.prototype._resolveColorValues=function(a){return a instanceof Array?a:null!=c.COLOR_SCALES[a]?c.COLOR_SCALES[a]:c.COLOR_SCALES.reds},c.prototype.autoDomain=function(){var b=this._getAllExtents();return b.length>0&&this._setDomain([a._Util.Methods.min(b,function(a){return a[0]},0),a._Util.Methods.max(b,function(a){return a[1]},0)]),this},c.COLOR_SCALES={reds:["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],blues:["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],posneg:["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"]},c}(b.AbstractScale);b.InterpolatedColor=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(a){var b=this;if(this.rescaleInProgress=!1,null==a)throw new Error("ScaleDomainCoordinator requires scales to coordinate");this.scales=a,this.scales.forEach(function(a){return a.broadcaster.registerListener(b,function(a){return b.rescale(a)})})}return a.prototype.rescale=function(a){if(!this.rescaleInProgress){this.rescaleInProgress=!0;var b=a.domain();this.scales.forEach(function(a){return a.domain(b)}),this.rescaleInProgress=!1}},a}();a.ScaleDomainCoordinator=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){!function(b){function c(b){if(0>=b)throw new Error("interval must be positive number");return function(c){var d=c.domain(),e=Math.min(d[0],d[1]),f=Math.max(d[0],d[1]),g=Math.ceil(e/b)*b,h=Math.floor((f-g)/b)+1,i=e%b===0?[]:[e],j=a._Util.Methods.range(0,h).map(function(a){return g+a*b}),k=f%b===0?[]:[f];return i.concat(j).concat(k)}}function d(){return function(a){var b=a.getDefaultTicks();return b.filter(function(a,c){return a%1===0||0===c||c===b.length-1})}}b.intervalTickGenerator=c,b.integerTickGenerator=d}(b.TickGenerators||(b.TickGenerators={}));b.TickGenerators}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){var c=function(){function b(a){this.key=a}return b.prototype.setClass=function(a){return this._className=a,this},b.prototype.setup=function(a){this._renderArea=a},b.prototype.remove=function(){null!=this._renderArea&&this._renderArea.remove()},b.prototype._enterData=function(){},b.prototype._drawStep=function(){},b.prototype._numberOfAnimationIterations=function(a){return a.length},b.prototype.applyMetadata=function(a,b,c){var d={};return d3.keys(a).forEach(function(e){d[e]=function(d,f){return a[e](d,f,b,c)}}),d},b.prototype._prepareDrawSteps=function(){},b.prototype._prepareData=function(a){return a},b.prototype.draw=function(b,c,d,e){var f=this,g=c.map(function(a){return{attrToProjector:f.applyMetadata(a.attrToProjector,d,e),animator:a.animator}}),h=this._prepareData(b,g);this._prepareDrawSteps(g),this._enterData(h);var i=this._numberOfAnimationIterations(h),j=0;return g.forEach(function(b){a._Util.Methods.setTimeout(function(){return f._drawStep(b)},j),j+=b.animator.getTiming(i)}),j},b}();b.AbstractDrawer=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments)}return __extends(c,b),c.prototype._enterData=function(a){b.prototype._enterData.call(this,a),this.pathSelection.datum(a)},c.prototype.setup=function(a){this.pathSelection=a.append("path").classed("line",!0).style({fill:"none","vector-effect":"non-scaling-stroke"}),b.prototype.setup.call(this,a)},c.prototype.createLine=function(a,b,c){return c||(c=function(){return!0}),d3.svg.line().x(a).y(b).defined(c)},c.prototype._numberOfAnimationIterations=function(){return 1},c.prototype._drawStep=function(c){var d=(b.prototype._drawStep.call(this,c),a._Util.Methods.copyMap(c.attrToProjector)),e=d.x,f=d.y,g=d.defined;delete d.x,delete d.y,d.defined&&delete d.defined,d.d=this.createLine(e,f,g),d.fill&&this.pathSelection.attr("fill",d.fill),c.animator.animate(this.pathSelection,d)},c}(b.AbstractDrawer);b.Line=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(){c.apply(this,arguments),this._drawLine=!0}return __extends(d,c),d.prototype._enterData=function(a){this._drawLine?c.prototype._enterData.call(this,a):b.AbstractDrawer.prototype._enterData.call(this,a),this.areaSelection.datum(a)},d.prototype.drawLine=function(a){return this._drawLine=a,this},d.prototype.setup=function(a){this.areaSelection=a.append("path").classed("area",!0).style({stroke:"none"}),this._drawLine?c.prototype.setup.call(this,a):b.AbstractDrawer.prototype.setup.call(this,a)},d.prototype.createArea=function(a,b,c,d){return d||(d=function(){return!0}),d3.svg.area().x(a).y0(b).y1(c).defined(d)},d.prototype._drawStep=function(d){this._drawLine?c.prototype._drawStep.call(this,d):b.AbstractDrawer.prototype._drawStep.call(this,d);var e=a._Util.Methods.copyMap(d.attrToProjector),f=e.x,g=e.y0,h=e.y,i=e.defined;delete e.x,delete e.y0,delete e.y,e.defined&&delete e.defined,e.d=this.createArea(f,g,h,i),e.fill&&this.areaSelection.attr("fill",e.fill),d.animator.animate(this.areaSelection,e)},d}(b.Line);b.Area=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype.svgElement=function(a){return this._svgElement=a,this},b.prototype._getDrawSelection=function(){return this._renderArea.selectAll(this._svgElement)},b.prototype._drawStep=function(b){a.prototype._drawStep.call(this,b);var c=this._getDrawSelection();b.attrToProjector.fill&&c.attr("fill",b.attrToProjector.fill),b.animator.animate(c,b.attrToProjector)},b.prototype._enterData=function(b){a.prototype._enterData.call(this,b);var c=this._getDrawSelection().data(b);c.enter().append(this._svgElement),null!=this._className&&c.classed(this._className,!0),c.exit().remove()},b.prototype.filterDefinedData=function(a,b){return b?a.filter(b):a},b.prototype._prepareDrawSteps=function(b){a.prototype._prepareDrawSteps.call(this,b),b.forEach(function(a){a.attrToProjector.defined&&delete a.attrToProjector.defined})},b.prototype._prepareData=function(b,c){var d=this;return c.reduce(function(a,b){return d.filterDefinedData(a,b.attrToProjector.defined)},a.prototype._prepareData.call(this,b,c))},b}(a.AbstractDrawer);a.Element=b}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=5,d=5,e=function(b){function e(a,c){b.call(this,a),this._someLabelsTooWide=!1,this.svgElement("rect"),this._isVertical=c}return __extends(e,b),e.prototype.setup=function(c){b.prototype.setup.call(this,c.append("g").classed("bar-area",!0)),this.textArea=c.append("g").classed("bar-label-text-area",!0),this.measurer=new a._Util.Text.CachingCharacterMeasurer(this.textArea.append("text")).measure},e.prototype.removeLabels=function(){this.textArea.selectAll("g").remove()},e.prototype.drawText=function(b,e,f,g){var h=this,i=b.map(function(b,i){var j=e.label(b,i,f,g).toString(),k=e.width(b,i,f,g),l=e.height(b,i,f,g),m=e.x(b,i,f,g),n=e.y(b,i,f,g),o=e.positive(b,i,f,g),p=h.measurer(j),q=e.fill(b,i,f,g),r=1.6*a._Util.Color.contrast("white",q)v;if(p.height<=l&&p.width<=k){var x=Math.min((s-t)/2,c);o||(x=-1*x),h._isVertical?n+=x:m+=x;var y=h.textArea.append("g").attr("transform","translate("+m+","+n+")"),z=r?"dark-label":"light-label";y.classed(z,!0);var A,B;h._isVertical?(A="center",B=o?"top":"bottom"):(A=o?"left":"right",B="center"),a._Util.Text.writeLineHorizontally(j,y,k,l,A,B)}return w});this._someLabelsTooWide=i.some(function(a){return a})},e}(b.Element);b.Rect=e}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,a),this._svgElement="path"}return __extends(c,b),c.prototype.createArc=function(a,b){return d3.svg.arc().innerRadius(a).outerRadius(b)},c.prototype.retargetProjectors=function(a){var b={};return d3.entries(a).forEach(function(a){b[a.key]=function(b,c){return a.value(b.data,c)}}),b},c.prototype._drawStep=function(c){var d=a._Util.Methods.copyMap(c.attrToProjector);d=this.retargetProjectors(d);var e=d["inner-radius"],f=d["outer-radius"];return delete d["inner-radius"],delete d["outer-radius"],d.d=this.createArc(e,f),b.prototype._drawStep.call(this,{attrToProjector:d,animator:c.animator})},c.prototype.draw=function(a,c,d,e){var f=function(a,b){return c[0].attrToProjector.value(a,b,d,e)},g=d3.layout.pie().sort(null).value(f)(a);return c.forEach(function(a){return delete a.attrToProjector.value}),b.prototype.draw.call(this,g,c,d,e)},c}(b.Element);b.Arc=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.clipPathEnabled=!1,this._xAlignProportion=0,this._yAlignProportion=0,this._fixedHeightFlag=!1,this._fixedWidthFlag=!1,this._isSetup=!1,this._isAnchored=!1,this.interactionsToRegister=[],this.boxes=[],this.isTopLevelComponent=!1,this._width=0,this._height=0,this._xOffset=0,this._yOffset=0,this.cssClasses=["component"],this.removed=!1,this._autoResize=c.AUTORESIZE_BY_DEFAULT}return __extends(c,b),c.prototype._anchor=function(a){if(this.removed)throw new Error("Can't reuse remove()-ed components!");"svg"===a.node().nodeName&&(this.rootSVG=a,this.rootSVG.classed("plottable",!0),this.rootSVG.style("overflow","visible"),this.isTopLevelComponent=!0),null!=this._element?a.node().appendChild(this._element.node()):(this._element=a.append("g"),this._setup()),this._isAnchored=!0},c.prototype._setup=function(){var a=this;this._isSetup||(this.cssClasses.forEach(function(b){a._element.classed(b,!0)}),this.cssClasses=null,this._backgroundContainer=this._element.append("g").classed("background-container",!0),this._content=this._element.append("g").classed("content",!0),this._foregroundContainer=this._element.append("g").classed("foreground-container",!0),this.boxContainer=this._element.append("g").classed("box-container",!0),this.clipPathEnabled&&this.generateClipPath(),this.addBox("bounding-box"),this.interactionsToRegister.forEach(function(b){return a.registerInteraction(b)}),this.interactionsToRegister=null,this.isTopLevelComponent&&this.autoResize(this._autoResize),this._isSetup=!0)},c.prototype._requestedSpace=function(){return{width:0,height:0,wantsWidth:!1,wantsHeight:!1}},c.prototype._computeLayout=function(b,c,d,e){var f=this;if(null==b||null==c||null==d||null==e){if(null==this._element)throw new Error("anchor must be called before computeLayout");if(!this.isTopLevelComponent)throw new Error("null arguments cannot be passed to _computeLayout() on a non-root node");b=0,c=0,null==this.rootSVG.attr("width")&&this.rootSVG.attr("width","100%"),null==this.rootSVG.attr("height")&&this.rootSVG.attr("height","100%");var g=this.rootSVG.node();d=a._Util.DOM.getElementWidth(g),e=a._Util.DOM.getElementHeight(g)}this.xOrigin=b,this.yOrigin=c;var h=this._requestedSpace(d,e);this._width=this._isFixedWidth()?Math.min(d,h.width):d,this._height=this._isFixedHeight()?Math.min(e,h.height):e;var i=this.xOrigin+this._xOffset,j=this.yOrigin+this._yOffset;i+=(d-this.width())*this._xAlignProportion,j+=(e-h.height)*this._yAlignProportion,this._element.attr("transform","translate("+i+","+j+")"),this.boxes.forEach(function(a){return a.attr("width",f.width()).attr("height",f.height())})},c.prototype._render=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToRender(this)},c.prototype._scheduleComputeLayout=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToComputeLayout(this)},c.prototype._doRender=function(){},c.prototype._invalidateLayout=function(){this._isAnchored&&this._isSetup&&(this.isTopLevelComponent?this._scheduleComputeLayout():this._parent._invalidateLayout())},c.prototype.renderTo=function(b){if(null!=b){var c;if(c="function"==typeof b.node?b:d3.select(b),!c.node()||"svg"!==c.node().nodeName)throw new Error("Plottable requires a valid SVG to renderTo");this._anchor(c)}if(null==this._element)throw new Error("If a component has never been rendered before, then renderTo must be given a node to render to, or a D3.Selection, or a selector string");return this._computeLayout(),this._render(),a.Core.RenderController.flush(),this},c.prototype.resize=function(a,b){if(!this.isTopLevelComponent)throw new Error("Cannot resize on non top-level component");return null!=a&&null!=b&&this._isAnchored&&this.rootSVG.attr({width:a,height:b}),this._invalidateLayout(),this},c.prototype.autoResize=function(b){return b?a.Core.ResizeBroadcaster.register(this):a.Core.ResizeBroadcaster.deregister(this),this._autoResize=b,this},c.prototype.xAlign=function(a){if(a=a.toLowerCase(),"left"===a)this._xAlignProportion=0;else if("center"===a)this._xAlignProportion=.5;else{if("right"!==a)throw new Error("Unsupported alignment");this._xAlignProportion=1}return this._invalidateLayout(),this},c.prototype.yAlign=function(a){if(a=a.toLowerCase(),"top"===a)this._yAlignProportion=0;else if("center"===a)this._yAlignProportion=.5;else{if("bottom"!==a)throw new Error("Unsupported alignment");this._yAlignProportion=1}return this._invalidateLayout(),this},c.prototype.xOffset=function(a){return this._xOffset=a,this._invalidateLayout(),this},c.prototype.yOffset=function(a){return this._yOffset=a,this._invalidateLayout(),this},c.prototype.addBox=function(a,b){if(null==this._element)throw new Error("Adding boxes before anchoring is currently disallowed");var b=null==b?this.boxContainer:b,c=b.append("rect");return null!=a&&c.classed(a,!0),this.boxes.push(c),null!=this.width()&&null!=this.height()&&c.attr("width",this.width()).attr("height",this.height()),c},c.prototype.generateClipPath=function(){var a=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;a=a.split("#")[0],this._element.attr("clip-path",'url("'+a+"#clipPath"+this._plottableID+'")');var b=this.boxContainer.append("clipPath").attr("id","clipPath"+this._plottableID);this.addBox("clip-rect",b)},c.prototype.registerInteraction=function(a){return this._element?(this.hitBox||(this.hitBox=this.addBox("hit-box"),this.hitBox.style("fill","#ffffff").style("opacity",0)),a._anchor(this,this.hitBox)):this.interactionsToRegister.push(a),this},c.prototype.classed=function(a,b){if(null==b)return null==a?!1:null==this._element?-1!==this.cssClasses.indexOf(a):this._element.classed(a);if(null==a)return this;if(null==this._element){var c=this.cssClasses.indexOf(a);b&&-1===c?this.cssClasses.push(a):b||-1===c||this.cssClasses.splice(c,1)}else this._element.classed(a,b);return this},c.prototype._isFixedWidth=function(){return this._fixedWidthFlag},c.prototype._isFixedHeight=function(){return this._fixedHeightFlag},c.prototype.merge=function(b){var c;if(this._isSetup||this._isAnchored)throw new Error("Can't presently merge a component that's already been anchored");return a.Component.Group.prototype.isPrototypeOf(b)?(c=b,c._addComponent(this,!0),c):c=new a.Component.Group([this,b])},c.prototype.detach=function(){return this._isAnchored&&this._element.remove(),null!=this._parent&&this._parent._removeComponent(this),this._isAnchored=!1,this._parent=null,this},c.prototype.remove=function(){this.removed=!0,this.detach(),a.Core.ResizeBroadcaster.deregister(this)},c.prototype.width=function(){return this._width},c.prototype.height=function(){return this._height},c.AUTORESIZE_BY_DEFAULT=!0,c}(a.Core.PlottableObject);b.AbstractComponent=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this._components=[]}return __extends(b,a),b.prototype._anchor=function(b){var c=this;a.prototype._anchor.call(this,b),this._components.forEach(function(a){return a._anchor(c._content)})},b.prototype._render=function(){this._components.forEach(function(a){return a._render()})},b.prototype._removeComponent=function(a){var b=this._components.indexOf(a);b>=0&&(this._components.splice(b,1),this._invalidateLayout())},b.prototype._addComponent=function(a,b){return void 0===b&&(b=!1),!a||this._components.indexOf(a)>=0?!1:(b?this._components.unshift(a):this._components.push(a),a._parent=this,this._isAnchored&&a._anchor(this._content),this._invalidateLayout(),!0)},b.prototype.components=function(){return this._components.slice()},b.prototype.empty=function(){return 0===this._components.length},b.prototype.detachAll=function(){return this._components.slice().forEach(function(a){return a.detach()}),this},b.prototype.remove=function(){a.prototype.remove.call(this),this._components.slice().forEach(function(a){return a.remove()})},b}(a.AbstractComponent);a.AbstractComponentContainer=b}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.classed("component-group",!0),a.forEach(function(a){return c._addComponent(a)})}return __extends(c,b),c.prototype._requestedSpace=function(b,c){var d=this._components.map(function(a){return a._requestedSpace(b,c)});return{width:a._Util.Methods.max(d,function(a){return a.width},0),height:a._Util.Methods.max(d,function(a){return a.height},0),wantsWidth:d.map(function(a){return a.wantsWidth}).some(function(a){return a}),wantsHeight:d.map(function(a){return a.wantsHeight}).some(function(a){return a})}},c.prototype.merge=function(a){return this._addComponent(a),this},c.prototype._computeLayout=function(a,c,d,e){var f=this;return b.prototype._computeLayout.call(this,a,c,d,e),this._components.forEach(function(a){a._computeLayout(0,0,f.width(),f.height())}),this},c.prototype._isFixedWidth=function(){return this._components.every(function(a){return a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return this._components.every(function(a){return a._isFixedHeight()})},c}(b.AbstractComponentContainer);b.Group=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){var f=this;if(void 0===e&&(e=a.Formatters.identity()),b.call(this),this._endTickLength=5,this._tickLength=5,this._tickLabelPadding=10,this._gutter=15,this._showEndTickLabels=!1,null==c||null==d)throw new Error("Axis requires a scale and orientation");this._scale=c,this.orient(d),this._setDefaultAlignment(),this.classed("axis",!0),this._isHorizontal()?this.classed("x-axis",!0):this.classed("y-axis",!0),this.formatter(e),this._scale.broadcaster.registerListener(this,function(){return f._rescale()})}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this._scale.broadcaster.deregisterListener(this)},c.prototype._isHorizontal=function(){return"top"===this._orientation||"bottom"===this._orientation},c.prototype._computeWidth=function(){return this._computedWidth=this._maxLabelTickLength(),this._computedWidth},c.prototype._computeHeight=function(){return this._computedHeight=this._maxLabelTickLength(),this._computedHeight},c.prototype._requestedSpace=function(a,b){var c=0,d=0;return this._isHorizontal()?(null==this._computedHeight&&this._computeHeight(),d=this._computedHeight+this._gutter):(null==this._computedWidth&&this._computeWidth(),c=this._computedWidth+this._gutter),{width:c,height:d,wantsWidth:!this._isHorizontal()&&c>a,wantsHeight:this._isHorizontal()&&d>b}},c.prototype._isFixedHeight=function(){return this._isHorizontal()},c.prototype._isFixedWidth=function(){return!this._isHorizontal()},c.prototype._rescale=function(){this._render()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._scale.range(this._isHorizontal()?[0,this.width()]:[this.height(),0])},c.prototype._setup=function(){b.prototype._setup.call(this),this._tickMarkContainer=this._content.append("g").classed(c.TICK_MARK_CLASS+"-container",!0),this._tickLabelContainer=this._content.append("g").classed(c.TICK_LABEL_CLASS+"-container",!0),this._baseline=this._content.append("line").classed("baseline",!0)},c.prototype._getTickValues=function(){return[]},c.prototype._doRender=function(){var a=this._getTickValues(),b=this._tickMarkContainer.selectAll("."+c.TICK_MARK_CLASS).data(a);b.enter().append("line").classed(c.TICK_MARK_CLASS,!0),b.attr(this._generateTickMarkAttrHash()),d3.select(b[0][0]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),d3.select(b[0][a.length-1]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),b.exit().remove(),this._baseline.attr(this._generateBaselineAttrHash())},c.prototype._generateBaselineAttrHash=function(){var a={x1:0,y1:0,x2:0,y2:0};switch(this._orientation){case"bottom":a.x2=this.width();break;case"top":a.x2=this.width(),a.y1=this.height(),a.y2=this.height();break;case"left":a.x1=this.width(),a.x2=this.width(),a.y2=this.height();break;case"right":a.y2=this.height()}return a},c.prototype._generateTickMarkAttrHash=function(a){var b=this;void 0===a&&(a=!1);var c={x1:0,y1:0,x2:0,y2:0},d=function(a){return b._scale.scale(a)};this._isHorizontal()?(c.x1=d,c.x2=d):(c.y1=d,c.y2=d);var e=a?this._endTickLength:this._tickLength;switch(this._orientation){case"bottom":c.y2=e;break;case"top":c.y1=this.height(),c.y2=this.height()-e;break;case"left":c.x1=this.width(),c.x2=this.width()-e;break;case"right":c.x2=e}return c},c.prototype._invalidateLayout=function(){this._computedWidth=null,this._computedHeight=null,b.prototype._invalidateLayout.call(this)},c.prototype._setDefaultAlignment=function(){switch(this._orientation){case"bottom":this.yAlign("top");break;case"top":this.yAlign("bottom");break;case"left":this.xAlign("right");break;case"right":this.xAlign("left")}},c.prototype.formatter=function(a){return void 0===a?this._formatter:(this._formatter=a,this._invalidateLayout(),this)},c.prototype.tickLength=function(a){if(null==a)return this._tickLength;if(0>a)throw new Error("tick length must be positive");return this._tickLength=a,this._invalidateLayout(),this},c.prototype.endTickLength=function(a){if(null==a)return this._endTickLength;if(0>a)throw new Error("end tick length must be positive");return this._endTickLength=a,this._invalidateLayout(),this},c.prototype._maxLabelTickLength=function(){return this.showEndTickLabels()?Math.max(this.tickLength(),this.endTickLength()):this.tickLength()},c.prototype.tickLabelPadding=function(a){if(null==a)return this._tickLabelPadding;if(0>a)throw new Error("tick label padding must be positive");return this._tickLabelPadding=a,this._invalidateLayout(),this},c.prototype.gutter=function(a){if(null==a)return this._gutter;if(0>a)throw new Error("gutter size must be positive");return this._gutter=a,this._invalidateLayout(),this},c.prototype.orient=function(a){if(null==a)return this._orientation;var b=a.toLowerCase();if("top"!==b&&"bottom"!==b&&"left"!==b&&"right"!==b)throw new Error("unsupported orientation");return this._orientation=b,this._invalidateLayout(),this},c.prototype.showEndTickLabels=function(a){return null==a?this._showEndTickLabels:(this._showEndTickLabels=a,this._render(),this)},c.prototype._hideEndTickLabels=function(){var a=this,b=this._element.select(".bounding-box")[0][0].getBoundingClientRect(),d=function(c){return Math.floor(b.left)<=Math.ceil(c.left)&&Math.floor(b.top)<=Math.ceil(c.top)&&Math.floor(c.right)<=Math.ceil(b.left+a.width())&&Math.floor(c.bottom)<=Math.ceil(b.top+a.height())},e=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS);if(0!==e[0].length){var f=e[0][0];d(f.getBoundingClientRect())||d3.select(f).style("visibility","hidden");var g=e[0][e[0].length-1];d(g.getBoundingClientRect())||d3.select(g).style("visibility","hidden")}},c.prototype._hideOverlappingTickLabels=function(){var b,d=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS).filter(function(){return"visible"===d3.select(this).style("visibility")});d.each(function(){var c=this.getBoundingClientRect(),d=d3.select(this);null!=b&&a._Util.DOM.boxesOverlap(c,b)?d.style("visibility","hidden"):(b=c,d.style("visibility","visible"))})},c.END_TICK_MARK_CLASS="end-tick-mark",c.TICK_MARK_CLASS="tick-mark",c.TICK_LABEL_CLASS="tick-label",c}(a.Component.AbstractComponent);b.AbstractAxis=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d){c.call(this,b,d),this.possibleTimeAxisConfigurations=[{tierConfigurations:[{interval:d3.time.second,step:1,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.second,step:5,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.second,step:10,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.second,step:15,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.second,step:30,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.minute,step:1,formatter:a.Formatters.time("%I:%M %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.minute,step:5,formatter:a.Formatters.time("%I:%M %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.minute,step:10,formatter:a.Formatters.time("%I:%M %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.minute,step:15,formatter:a.Formatters.time("%I:%M %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.minute,step:30,formatter:a.Formatters.time("%I:%M %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.hour,step:1,formatter:a.Formatters.time("%I %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.hour,step:3,formatter:a.Formatters.time("%I %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.hour,step:6,formatter:a.Formatters.time("%I %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.hour,step:12,formatter:a.Formatters.time("%I %p")},{interval:d3.time.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}]},{tierConfigurations:[{interval:d3.time.day,step:1,formatter:a.Formatters.time("%a %e")},{interval:d3.time.month,step:1,formatter:a.Formatters.time("%B %Y")}]},{tierConfigurations:[{interval:d3.time.day,step:1,formatter:a.Formatters.time("%e")},{interval:d3.time.month,step:1,formatter:a.Formatters.time("%B %Y")}]},{tierConfigurations:[{interval:d3.time.month,step:1,formatter:a.Formatters.time("%B")},{interval:d3.time.year,step:1,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.month,step:1,formatter:a.Formatters.time("%b")},{interval:d3.time.year,step:1,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.month,step:3,formatter:a.Formatters.time("%b")},{interval:d3.time.year,step:1,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.month,step:6,formatter:a.Formatters.time("%b")},{interval:d3.time.year,step:1,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:1,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:1,formatter:a.Formatters.time("%y")}]},{tierConfigurations:[{interval:d3.time.year,step:5,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:25,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:50,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:100,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:200,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:500,formatter:a.Formatters.time("%Y")}]},{tierConfigurations:[{interval:d3.time.year,step:1e3,formatter:a.Formatters.time("%Y")}]}],this.classed("time-axis",!0),this.tickLabelPadding(5) +}return __extends(d,c),d.prototype.axisConfigurations=function(a){return null==a?this.possibleTimeAxisConfigurations:(this.possibleTimeAxisConfigurations=a,this._invalidateLayout(),this)},d.prototype.getMostPreciseConfigurationIndex=function(){var b=this,c=this.possibleTimeAxisConfigurations.length;return this.possibleTimeAxisConfigurations.forEach(function(a,d){c>d&&a.tierConfigurations.every(function(a){return b.checkTimeAxisTierConfigurationWidth(a)})&&(c=d)}),c===this.possibleTimeAxisConfigurations.length&&(a._Util.Methods.warn("zoomed out too far: could not find suitable interval to display labels"),--c),c},d.prototype.orient=function(a){if(a&&("right"===a.toLowerCase()||"left"===a.toLowerCase()))throw new Error(a+" is not a supported orientation for TimeAxis - only horizontal orientations are supported");return c.prototype.orient.call(this,a)},d.prototype._computeHeight=function(){if(null!==this._computedHeight)return this._computedHeight;var a=2*this._measureTextHeight();return this.tickLength(a),this.endTickLength(a),this._computedHeight=this._maxLabelTickLength()+2*this.tickLabelPadding(),this._computedHeight},d.prototype.getIntervalLength=function(a){var b=this._scale.domain()[0],c=a.interval.offset(b,a.step);if(c>this._scale.domain()[1])return this.width();var d=Math.abs(this._scale.scale(c)-this._scale.scale(b));return d},d.prototype.maxWidthForInterval=function(a){return this.measurer(a.formatter(d.LONG_DATE)).width},d.prototype.checkTimeAxisTierConfigurationWidth=function(a){var b=this.maxWidthForInterval(a)+2*this.tickLabelPadding();return Math.min(this.getIntervalLength(a),this.width())>=b},d.prototype._setup=function(){c.prototype._setup.call(this),this.tierLabelContainers=[];for(var e=0;e=g.length||i.push(new Date((g[b+1].valueOf()-g[b].valueOf())/2+g[b].valueOf()))}):i=g;var j=[];i=i.filter(function(a,b){var e=f.canFitLabelFilter(c,a,g.slice(b,b+2),d.formatter(a),h);return e&&j.push(g[b]),e});var k=c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).data(i,function(a){return a.valueOf()}),l=k.enter().append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0);l.append("text");var m=h?0:this.tickLabelPadding(),n="bottom"===this._orientation?this._maxLabelTickLength()/2*e:this.height()-this._maxLabelTickLength()/2*e+2*this.tickLabelPadding(),o=k.selectAll("text");o.size()>0&&a._Util.DOM.translate(o,m,n),k.exit().remove(),k.attr("transform",function(a){return"translate("+f._scale.scale(a)+",0)"});var p=h?"middle":"start";return k.selectAll("text").text(d.formatter).style("text-anchor",p),j},d.prototype.canFitLabelFilter=function(a,b,c,d,e){var f,g,h=this.measurer(d).width+this.tickLabelPadding(),i=this._scale.scale(c[0]),j=this._scale.scale(c[1]);return e?(f=this._scale.scale(b)+h/2,g=this._scale.scale(b)-h/2):(f=this._scale.scale(b)+h,g=this._scale.scale(b)),j>=f&&g>=i},d.prototype.adjustTickLength=function(a,c){var d=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).filter(function(b){return a.map(function(a){return a.valueOf()}).indexOf(b.valueOf())>=0});"top"===this._orientation&&(c=this.height()-c),d.attr("y2",c)},d.prototype.generateLabellessTicks=function(){return this.mostPreciseConfigIndex<1?[]:this.getTickIntervalValues(this.possibleTimeAxisConfigurations[this.mostPreciseConfigIndex-1].tierConfigurations[0])},d.prototype.createTickMarks=function(a){var c=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).data(a);c.enter().append("line").classed(b.AbstractAxis.TICK_MARK_CLASS,!0),c.attr(this._generateTickMarkAttrHash()),c.exit().remove()},d.prototype._doRender=function(){var b=this;this.mostPreciseConfigIndex=this.getMostPreciseConfigurationIndex(),c.prototype._doRender.call(this);var e=this.possibleTimeAxisConfigurations[this.mostPreciseConfigIndex].tierConfigurations;this.tierLabelContainers.forEach(this.cleanContainer);var f=e.map(function(a,c){return b.renderTierLabels(b.tierLabelContainers[c],a,c+1)}),g=f.slice(),h=[],i=this._scale.domain(),j=this._scale.scale(i[1])-this._scale.scale(i[0]);return 1.5*this.getIntervalLength(e[0])>=j&&(h=this.generateLabellessTicks()),g.push(h),this.createTickMarks(a._Util.Methods.flatten(g)),this.adjustTickLength(h,this.tickLabelPadding()),e.forEach(function(a,c){return b.adjustTickLength(f[c],b._maxLabelTickLength()*(c+1)/d.NUM_TIERS)}),this},d.LONG_DATE=new Date(9999,8,29,12,59,9999),d.NUM_TIERS=2,d}(b.AbstractAxis);b.Time=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=a.Formatters.general()),c.call(this,b,d,e),this.tickLabelPositioning="center",this.showFirstTickLabel=!1,this.showLastTickLabel=!1}return __extends(d,c),d.prototype._setup=function(){c.prototype._setup.call(this),this.measurer=a._Util.Text.getTextMeasurer(this._tickLabelContainer.append("text").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0))},d.prototype._computeWidth=function(){var b=this,c=this._getTickValues(),d=c.map(function(a){var c=b._formatter(a);return b.measurer(c).width}),e=a._Util.Methods.max(d,0);return this._computedWidth="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+e:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+e),this._computedWidth},d.prototype._computeHeight=function(){var b=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return this._computedHeight="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+b:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+b),this._computedHeight},d.prototype._getTickValues=function(){return this._scale.ticks()},d.prototype._rescale=function(){if(this._isSetup){if(!this._isHorizontal()){var a=this._computeWidth();if(a>this.width()||aa,wantsHeight:e>b}},c.prototype._setup=function(){b.prototype._setup.call(this),this.textContainer=this._content.append("g"),this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),this.text(this._text)},c.prototype.text=function(a){return void 0===a?this._text:(this._text=a,this._invalidateLayout(),this)},c.prototype.orient=function(a){if(null==a)return this.orientation;if(a=a.toLowerCase(),"horizontal"!==a&&"left"!==a&&"right"!==a)throw new Error(a+" is not a valid orientation for LabelComponent");return this.orientation=a,this._invalidateLayout(),this},c.prototype.padding=function(a){if(null==a)return this._padding;if(a=+a,0>a)throw new Error(a+" is not a valid padding value. Cannot be less than 0.");return this._padding=a,this._invalidateLayout(),this},c.prototype._doRender=function(){b.prototype._doRender.call(this);var c=this.measurer(this._text),d=Math.max(Math.min((this.height()-c.height)/2,this.padding()),0),e=Math.max(Math.min((this.width()-c.width)/2,this.padding()),0);this.textContainer.attr("transform","translate("+e+","+d+")"),this.textContainer.text("");var f="horizontal"===this.orientation?this.width():this.height(),g=a._Util.Text.getTruncatedText(this._text,f,this.measurer),h=this.width()-2*e,i=this.height()-2*d;"horizontal"===this.orientation?a._Util.Text.writeLineHorizontally(g,this.textContainer,h,i,this.xAlignment,this.yAlignment):a._Util.Text.writeLineVertically(g,this.textContainer,h,i,this.xAlignment,this.yAlignment,this.orientation)},c.prototype._computeLayout=function(c,d,e,f){return this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),b.prototype._computeLayout.call(this,c,d,e,f),this},c}(b.AbstractComponent);b.Label=c;var d=function(a){function b(b,c){a.call(this,b,c),this.classed("title-label",!0)}return __extends(b,a),b}(c);b.TitleLabel=d;var e=function(a){function b(b,c){a.call(this,b,c),this.classed("axis-label",!0)}return __extends(b,a),b}(c);b.AxisLabel=e}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this),this.classed("legend",!0),this.scale(a),this.xAlign("RIGHT").yAlign("TOP"),this.xOffset(5).yOffset(5),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this)},c.prototype.toggleCallback=function(a){return void 0!==a?(this._toggleCallback=a,this.isOff=d3.set(),this.updateListeners(),this.updateClasses(),this):this._toggleCallback},c.prototype.hoverCallback=function(a){return void 0!==a?(this._hoverCallback=a,this.datumCurrentlyFocusedOn=void 0,this.updateListeners(),this.updateClasses(),this):this._hoverCallback},c.prototype.scale=function(a){var b=this;return null!=a?(null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this),this.colorScale=a,this.colorScale.broadcaster.registerListener(this,function(){return b.updateDomain()}),this.updateDomain(),this):this.colorScale},c.prototype.updateDomain=function(){null!=this._toggleCallback&&(this.isOff=a._Util.Methods.intersection(this.isOff,d3.set(this.scale().domain()))),null!=this._hoverCallback&&(this.datumCurrentlyFocusedOn=this.scale().domain().indexOf(this.datumCurrentlyFocusedOn)>=0?this.datumCurrentlyFocusedOn:void 0),this._invalidateLayout()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e);var f=this.measureTextHeight(),g=this.colorScale.domain().length;this.nRowsDrawn=Math.min(g,Math.floor(this.height()/f))},c.prototype._requestedSpace=function(b,d){var e=this.measureTextHeight(),f=this.colorScale.domain().length,g=Math.min(f,Math.floor((d-2*c.MARGIN)/e)),h=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),i=a._Util.Text.getTextMeasurer(h.append("text")),j=a._Util.Methods.max(this.colorScale.domain(),function(a){return i(a).width},0);h.remove(),j=void 0===j?0:j;var k=0===g?0:j+e+2*c.MARGIN,l=0===g?0:f*e+2*c.MARGIN;return{width:k,height:l,wantsWidth:k>b,wantsHeight:l>d}},c.prototype.measureTextHeight=function(){var b=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),d=a._Util.Text.getTextMeasurer(b.append("text"))(a._Util.Text.HEIGHT_TEXT).height;return 0===d&&(d=1),b.remove(),d},c.prototype._doRender=function(){b.prototype._doRender.call(this);var d=this.colorScale.domain().slice(0,this.nRowsDrawn),e=this.measureTextHeight(),f=this.width()-e-c.MARGIN,g=.3*e,h=this._content.selectAll("."+c.SUBELEMENT_CLASS).data(d,function(a){return a}),i=h.enter().append("g").classed(c.SUBELEMENT_CLASS,!0);i.each(function(a){d3.select(this).classed(a.replace(" ","-"),!0)}),i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove(),h.selectAll("circle").attr("cx",e/2).attr("cy",e/2).attr("r",g).attr("fill",this.colorScale._d3Scale),h.selectAll("g.text-container").text("").attr("transform","translate("+e+", 0)").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),e=a._Util.Text.getTruncatedText(b,f,d),g=d(e);a._Util.Text.writeLineHorizontally(e,c,g.width,g.height)}),h.attr("transform",function(a){return"translate("+c.MARGIN+","+(d.indexOf(a)*e+c.MARGIN)+")"}),this.updateClasses(),this.updateListeners()},c.prototype.updateListeners=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);if(null!=this._hoverCallback){var d=function(b){return function(c){a.datumCurrentlyFocusedOn=b?c:void 0,a._hoverCallback(a.datumCurrentlyFocusedOn),a.updateClasses()}};b.on("mouseover",d(!0)),b.on("mouseout",d(!1))}else b.on("mouseover",null),b.on("mouseout",null);null!=this._toggleCallback?b.on("click",function(b){var c=a.isOff.has(b);c?a.isOff.remove(b):a.isOff.add(b),a._toggleCallback(b,c),a.updateClasses()}):b.on("click",null)}},c.prototype.updateClasses=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);null!=this._hoverCallback?(b.classed("focus",function(b){return a.datumCurrentlyFocusedOn===b}),b.classed("hover",void 0!==this.datumCurrentlyFocusedOn)):(b.classed("hover",!1),b.classed("focus",!1)),null!=this._toggleCallback?(b.classed("toggled-on",function(b){return!a.isOff.has(b)}),b.classed("toggled-off",function(b){return a.isOff.has(b)})):(b.classed("toggled-on",!1),b.classed("toggled-off",!1))}},c.SUBELEMENT_CLASS="legend-row",c.MARGIN=5,c}(b.AbstractComponent);b.Legend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;b.call(this),this.padding=5,this.classed("legend",!0),this.scale=a,this.scale.broadcaster.registerListener(this,function(){return c._invalidateLayout()}),this.xAlign("left").yAlign("center"),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this.scale.broadcaster.deregisterListener(this)},c.prototype.calculateLayoutInfo=function(b,d){var e=this,f=this._content.append("g").classed(c.LEGEND_ROW_CLASS,!0),g=(f.append("g").classed(c.LEGEND_ENTRY_CLASS,!0),a._Util.Text.getTextMeasurer(f.append("text"))),h=g(a._Util.Text.HEIGHT_TEXT).height,i=Math.max(0,b-this.padding),j=function(a){var b=h+g(a).width+e.padding;return Math.min(b,i)},k=this.scale.domain(),l=a._Util.Methods.populateMap(k,j);f.remove();var m=this.packRows(i,k,l),n=Math.floor((d-2*this.padding)/h);return n!==n&&(n=0),{textHeight:h,entryLengths:l,rows:m,numRowsToDraw:Math.max(Math.min(n,m.length),0)}},c.prototype._requestedSpace=function(b,c){var d=this.calculateLayoutInfo(b,c),e=d.rows.map(function(a){return d3.sum(a,function(a){return d.entryLengths.get(a)})}),f=a._Util.Methods.max(e,0);f=void 0===f?0:f;var g=this.padding+f,h=d.numRowsToDraw*d.textHeight+2*this.padding,i=d.rows.length*d.textHeight+2*this.padding;return{width:g,height:h,wantsWidth:g>b,wantsHeight:i>c}},c.prototype.packRows=function(a,b,c){var d=[[]],e=d[0],f=a;return b.forEach(function(b){var g=c.get(b);g>f&&(e=[],d.push(e),f=a),e.push(b),f-=g}),d},c.prototype._doRender=function(){var d=this;b.prototype._doRender.call(this);var e=this.calculateLayoutInfo(this.width(),this.height()),f=e.rows.slice(0,e.numRowsToDraw),g=this._content.selectAll("g."+c.LEGEND_ROW_CLASS).data(f);g.enter().append("g").classed(c.LEGEND_ROW_CLASS,!0),g.exit().remove(),g.attr("transform",function(a,b){return"translate(0, "+(b*e.textHeight+d.padding)+")"});var h=g.selectAll("g."+c.LEGEND_ENTRY_CLASS).data(function(a){return a}),i=h.enter().append("g").classed(c.LEGEND_ENTRY_CLASS,!0);h.each(function(a){d3.select(this).classed(a.replace(" ","-"),!0)}),i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove();var j=this.padding;g.each(function(){var a=j,b=d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS);b.attr("transform",function(b){var c="translate("+a+", 0)";return a+=e.entryLengths.get(b),c})}),h.select("circle").attr("cx",e.textHeight/2).attr("cy",e.textHeight/2).attr("r",.3*e.textHeight).attr("fill",function(a){return d.scale.scale(a)});var k=this.padding,l=h.select("g.text-container");l.text(""),l.append("title").text(function(a){return a}),l.attr("transform","translate("+e.textHeight+", "+.1*e.textHeight+")").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),f=e.entryLengths.get(b)-e.textHeight-k,g=a._Util.Text.getTruncatedText(b,f,d),h=d(g);a._Util.Text.writeLineHorizontally(g,c,h.width,h.height)})},c.LEGEND_ROW_CLASS="legend-row",c.LEGEND_ENTRY_CLASS="legend-entry",c}(b.AbstractComponent);b.HorizontalLegend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;if(null!=c&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(c))throw new Error("xScale needs to inherit from Scale.AbstractQuantitative");if(null!=d&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(d))throw new Error("yScale needs to inherit from Scale.AbstractQuantitative");b.call(this),this.classed("gridlines",!0),this.xScale=c,this.yScale=d,this.xScale&&this.xScale.broadcaster.registerListener(this,function(){return e._render()}),this.yScale&&this.yScale.broadcaster.registerListener(this,function(){return e._render()})}return __extends(c,b),c.prototype.remove=function(){return b.prototype.remove.call(this),this.xScale&&this.xScale.broadcaster.deregisterListener(this),this.yScale&&this.yScale.broadcaster.deregisterListener(this),this},c.prototype._setup=function(){b.prototype._setup.call(this),this.xLinesContainer=this._content.append("g").classed("x-gridlines",!0),this.yLinesContainer=this._content.append("g").classed("y-gridlines",!0)},c.prototype._doRender=function(){b.prototype._doRender.call(this),this.redrawXLines(),this.redrawYLines()},c.prototype.redrawXLines=function(){var a=this;if(this.xScale){var b=this.xScale.ticks(),c=function(b){return a.xScale.scale(b)},d=this.xLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",c).attr("y1",0).attr("x2",c).attr("y2",this.height()).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c.prototype.redrawYLines=function(){var a=this;if(this.yScale){var b=this.yScale.ticks(),c=function(b){return a.yScale.scale(b)},d=this.yLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",0).attr("y1",c).attr("x2",this.width()).attr("y2",c).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c}(b.AbstractComponent);b.Gridlines=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.rowPadding=0,this.colPadding=0,this.rows=[],this.rowWeights=[],this.colWeights=[],this.nRows=0,this.nCols=0,this.classed("table",!0),a.forEach(function(a,b){a.forEach(function(a,d){c.addComponent(b,d,a)})})}return __extends(c,b),c.prototype.addComponent=function(a,b,c){if(this._addComponent(c)){this.nRows=Math.max(a+1,this.nRows),this.nCols=Math.max(b+1,this.nCols),this.padTableToSize(this.nRows,this.nCols);var d=this.rows[a][b];if(d)throw new Error("Table.addComponent cannot be called on a cell where a component already exists (for the moment)");this.rows[a][b]=c}return this},c.prototype._removeComponent=function(a){b.prototype._removeComponent.call(this,a);var c,d;a:for(var e=0;e0&&v&&e!==x,C=f>0&&w&&f!==y;if(!B&&!C)break;if(r>5)break}return e=h-d3.sum(u.guaranteedWidths),f=i-d3.sum(u.guaranteedHeights),n=c.calcProportionalSpace(k,e),o=c.calcProportionalSpace(j,f),{colProportionalSpace:n,rowProportionalSpace:o,guaranteedWidths:u.guaranteedWidths,guaranteedHeights:u.guaranteedHeights,wantsWidth:v,wantsHeight:w}},c.prototype.determineGuarantees=function(b,c){var d=a._Util.Methods.createFilledArray(0,this.nCols),e=a._Util.Methods.createFilledArray(0,this.nRows),f=a._Util.Methods.createFilledArray(!1,this.nCols),g=a._Util.Methods.createFilledArray(!1,this.nRows);return this.rows.forEach(function(a,h){a.forEach(function(a,i){var j;j=null!=a?a._requestedSpace(b[i],c[h]):{width:0,height:0,wantsWidth:!1,wantsHeight:!1};var k=Math.min(j.width,b[i]),l=Math.min(j.height,c[h]);d[i]=Math.max(d[i],k),e[h]=Math.max(e[h],l),f[i]=f[i]||j.wantsWidth,g[h]=g[h]||j.wantsHeight})}),{guaranteedWidths:d,guaranteedHeights:e,wantsWidthArr:f,wantsHeightArr:g}},c.prototype._requestedSpace=function(a,b){var c=this.iterateLayout(a,b);return{width:d3.sum(c.guaranteedWidths),height:d3.sum(c.guaranteedHeights),wantsWidth:c.wantsWidth,wantsHeight:c.wantsHeight}},c.prototype._computeLayout=function(c,d,e,f){var g=this;b.prototype._computeLayout.call(this,c,d,e,f);var h=this.iterateLayout(this.width(),this.height()),i=a._Util.Methods.addArrays(h.rowProportionalSpace,h.guaranteedHeights),j=a._Util.Methods.addArrays(h.colProportionalSpace,h.guaranteedWidths),k=0;this.rows.forEach(function(a,b){var c=0;a.forEach(function(a,d){null!=a&&a._computeLayout(c,k,j[d],i[b]),c+=j[d]+g.colPadding}),k+=i[b]+g.rowPadding})},c.prototype.padding=function(a,b){return this.rowPadding=a,this.colPadding=b,this._invalidateLayout(),this},c.prototype.rowWeight=function(a,b){return this.rowWeights[a]=b,this._invalidateLayout(),this},c.prototype.colWeight=function(a,b){return this.colWeights[a]=b,this._invalidateLayout(),this},c.prototype._isFixedWidth=function(){var a=d3.transpose(this.rows);return c.fixedSpace(a,function(a){return null==a||a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return c.fixedSpace(this.rows,function(a){return null==a||a._isFixedHeight()})},c.prototype.padTableToSize=function(a,b){for(var c=0;a>c;c++){void 0===this.rows[c]&&(this.rows[c]=[],this.rowWeights[c]=null);for(var d=0;b>d;d++)void 0===this.rows[c][d]&&(this.rows[c][d]=null)}for(d=0;b>d;d++)void 0===this.colWeights[d]&&(this.colWeights[d]=null)},c.calcComponentWeights=function(a,b,c){return a.map(function(a,d){if(null!=a)return a;var e=b[d].map(c),f=e.reduce(function(a,b){return a&&b},!0);return f?0:1})},c.calcProportionalSpace=function(b,c){var d=d3.sum(b);return 0===d?a._Util.Methods.createFilledArray(0,b.length):b.map(function(a){return c*a/d})},c.fixedSpace=function(a,b){var c=function(a){return a.reduce(function(a,b){return a&&b},!0)},d=function(a){return c(a.map(b))};return c(a.map(d))},c}(b.AbstractComponentContainer);b.Table=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this._dataChanged=!1,this._projections={},this._animate=!1,this._animators={},this._ANIMATION_DURATION=250,this._animateOnNextRender=!0,this.clipPathEnabled=!0,this.classed("plot",!0),this._key2PlotDatasetKey=d3.map(),this._datasetKeysInOrder=[],this.nextSeriesIndex=0}return __extends(c,b),c.prototype._anchor=function(a){b.prototype._anchor.call(this,a),this._animateOnNextRender=!0,this._dataChanged=!0,this._updateScaleExtents() +},c.prototype._setup=function(){var a=this;b.prototype._setup.call(this),this._renderArea=this._content.append("g").classed("render-area",!0),this._getDrawersInOrder().forEach(function(b){return b.setup(a._renderArea.append("g"))})},c.prototype.remove=function(){var a=this;b.prototype.remove.call(this),this._datasetKeysInOrder.forEach(function(b){return a.removeDataset(b)});var c=Object.keys(this._projections);c.forEach(function(b){var c=a._projections[b];c.scale&&c.scale.broadcaster.deregisterListener(a)})},c.prototype.addDataset=function(b,c){if("string"!=typeof b&&void 0!==c)throw new Error("invalid input to addDataset");"string"==typeof b&&"_"===b[0]&&a._Util.Methods.warn("Warning: Using _named series keys may produce collisions with unlabeled data sources");var d="string"==typeof b?b:"_"+this.nextSeriesIndex++,e="string"!=typeof b?b:c,c=e instanceof a.Dataset?e:new a.Dataset(e);return this._addDataset(d,c),this},c.prototype._addDataset=function(a,b){var c=this;this._key2PlotDatasetKey.has(a)&&this.removeDataset(a);var d=this._getDrawer(a),e=this._getPlotMetadataForDataset(a),f={drawer:d,dataset:b,key:a,plotMetadata:e};this._datasetKeysInOrder.push(a),this._key2PlotDatasetKey.set(a,f),this._isSetup&&d.setup(this._renderArea.append("g")),b.broadcaster.registerListener(this,function(){return c._onDatasetUpdate()}),this._onDatasetUpdate()},c.prototype._getDrawer=function(b){return new a._Drawer.AbstractDrawer(b)},c.prototype._getAnimator=function(b){return this._animate&&this._animateOnNextRender?this._animators[b]||new a.Animator.Null:new a.Animator.Null},c.prototype._onDatasetUpdate=function(){this._updateScaleExtents(),this._animateOnNextRender=!0,this._dataChanged=!0,this._render()},c.prototype.attr=function(a,b,c){return this.project(a,b,c)},c.prototype.project=function(b,c,d){var e=this;b=b.toLowerCase();var f=this._projections[b],g=f&&f.scale;return g&&this._datasetKeysInOrder.forEach(function(a){g._removeExtent(e._plottableID.toString()+"_"+a,b),g.broadcaster.deregisterListener(e)}),d&&d.broadcaster.registerListener(this,function(){return e._render()}),c=a._Util.Methods.accessorize(c),this._projections[b]={accessor:c,scale:d,attribute:b},this._updateScaleExtent(b),this._render(),this},c.prototype._generateAttrToProjector=function(){var a=this,b={};return d3.keys(this._projections).forEach(function(c){var d=a._projections[c],e=d.accessor,f=d.scale,g=f?function(a,b,c,d){return f.scale(e(a,b,c,d))}:e;b[c]=g}),b},c.prototype._doRender=function(){this._isAnchored&&(this.paint(),this._dataChanged=!1,this._animateOnNextRender=!1)},c.prototype.animate=function(a){return this._animate=a,this},c.prototype.detach=function(){return b.prototype.detach.call(this),this._updateScaleExtents(),this},c.prototype._updateScaleExtents=function(){var a=this;d3.keys(this._projections).forEach(function(b){return a._updateScaleExtent(b)})},c.prototype._updateScaleExtent=function(a){var b=this,c=this._projections[a];c.scale&&this._key2PlotDatasetKey.forEach(function(d,e){var f=e.dataset._getExtent(c.accessor,c.scale._typeCoercer,e.plotMetadata),g=b._plottableID.toString()+"_"+d;0!==f.length&&b._isAnchored?c.scale._updateExtent(g,a,f):c.scale._removeExtent(g,a)})},c.prototype.animator=function(a,b){return void 0===b?this._animators[a]:(this._animators[a]=b,this)},c.prototype.datasetOrder=function(b){function c(b,c){var d=a._Util.Methods.intersection(d3.set(b),d3.set(c)),e=d.size();return e===b.length&&e===c.length}return void 0===b?this._datasetKeysInOrder:(c(b,this._datasetKeysInOrder)?(this._datasetKeysInOrder=b,this._onDatasetUpdate()):a._Util.Methods.warn("Attempted to change datasetOrder, but new order is not permutation of old. Ignoring."),this)},c.prototype.removeDataset=function(b){var c;if("string"==typeof b)c=b;else if(b instanceof a.Dataset||b instanceof Array){var d=b instanceof a.Dataset?this.datasets():this.datasets().map(function(a){return a.data()}),e=d.indexOf(b);-1!==e&&(c=this._datasetKeysInOrder[e])}return this._removeDataset(c)},c.prototype._removeDataset=function(a){if(null!=a&&this._key2PlotDatasetKey.has(a)){var b=this._key2PlotDatasetKey.get(a);b.drawer.remove();var c=d3.values(this._projections),d=this._plottableID.toString()+"_"+a;c.forEach(function(a){null!=a.scale&&a.scale._removeExtent(d,a.attribute)}),b.dataset.broadcaster.deregisterListener(this),this._datasetKeysInOrder.splice(this._datasetKeysInOrder.indexOf(a),1),this._key2PlotDatasetKey.remove(a),this._onDatasetUpdate()}return this},c.prototype.datasets=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2PlotDatasetKey.get(b).dataset})},c.prototype._getDrawersInOrder=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2PlotDatasetKey.get(b).drawer})},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animator.Null}]},c.prototype._additionalPaint=function(){},c.prototype._getDataToDraw=function(){var a=this,b=d3.map();return this._datasetKeysInOrder.forEach(function(c){b.set(c,a._key2PlotDatasetKey.get(c).dataset.data())}),b},c.prototype._getPlotMetadataForDataset=function(a){return{datasetKey:a}},c.prototype.paint=function(){var b=this,c=this._generateDrawSteps(),d=this._getDataToDraw(),e=this._getDrawersInOrder(),f=this._datasetKeysInOrder.map(function(a,f){return e[f].draw(d.get(a),c,b._key2PlotDatasetKey.get(a).dataset.metadata(),b._key2PlotDatasetKey.get(a).plotMetadata)}),g=a._Util.Methods.max(f,0);this._additionalPaint(g)},c}(a.Component.AbstractComponent);b.AbstractPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.colorScale=new a.Scale.Color,this.classed("pie-plot",!0)}return __extends(c,b),c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")")},c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Pie plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this);c["inner-radius"]=c["inner-radius"]||d3.functor(0),c["outer-radius"]=c["outer-radius"]||d3.functor(Math.min(this.width(),this.height())/2),null==c.fill&&(c.fill=function(b,c){return a.colorScale.scale(String(c))});var d=function(a){return a.value},e=this._projections.value;return c.value=e?e.accessor:d,c},c.prototype._getDrawer=function(b){return new a._Drawer.Arc(b).setClass("arc")},c}(b.AbstractPlot);b.Pie=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,c){if(b.call(this),this._autoAdjustXScaleDomain=!1,this._autoAdjustYScaleDomain=!1,null==a||null==c)throw new Error("XYPlots require an xScale and yScale");this.classed("xy-plot",!0),this.project("x","x",a),this.project("y","y",c)}return __extends(c,b),c.prototype.project=function(a,c,d){var e=this;return"x"===a&&d&&(this._xScale&&this._xScale.broadcaster.deregisterListener("yDomainAdjustment"+this._plottableID),this._xScale=d,this._updateXDomainer(),d.broadcaster.registerListener("yDomainAdjustment"+this._plottableID,function(){return e.adjustYDomainOnChangeFromX()})),"y"===a&&d&&(this._yScale&&this._yScale.broadcaster.deregisterListener("xDomainAdjustment"+this._plottableID),this._yScale=d,this._updateYDomainer(),d.broadcaster.registerListener("xDomainAdjustment"+this._plottableID,function(){return e.adjustXDomainOnChangeFromY()})),b.prototype.project.call(this,a,c,d),this},c.prototype.remove=function(){return b.prototype.remove.call(this),this._xScale&&this._xScale.broadcaster.deregisterListener("yDomainAdjustment"+this._plottableID),this._yScale&&this._yScale.broadcaster.deregisterListener("xDomainAdjustment"+this._plottableID),this},c.prototype.automaticallyAdjustYScaleOverVisiblePoints=function(a){return this._autoAdjustYScaleDomain=a,this.adjustYDomainOnChangeFromX(),this},c.prototype.automaticallyAdjustXScaleOverVisiblePoints=function(a){return this._autoAdjustXScaleDomain=a,this.adjustXDomainOnChangeFromY(),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=a.x,d=a.y;return a.defined=function(a,b,e,f){var g=c(a,b,e,f),h=d(a,b,e,f);return null!=g&&g===g&&null!=h&&h===h},a},c.prototype._computeLayout=function(c,d,e,f){b.prototype._computeLayout.call(this,c,d,e,f),this._xScale.range([0,this.width()]),this._yScale.range(this._yScale instanceof a.Scale.Ordinal?[0,this.height()]:[this.height(),0])},c.prototype._updateXDomainer=function(){if(this._xScale instanceof a.Scale.AbstractQuantitative){var b=this._xScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype._updateYDomainer=function(){if(this._yScale instanceof a.Scale.AbstractQuantitative){var b=this._yScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype.showAllData=function(){this._xScale.autoDomain(),this._autoAdjustYScaleDomain||this._yScale.autoDomain()},c.prototype.adjustYDomainOnChangeFromX=function(){this._autoAdjustYScaleDomain&&this.adjustDomainToVisiblePoints(this._xScale,this._yScale,!0)},c.prototype.adjustXDomainOnChangeFromY=function(){this._autoAdjustXScaleDomain&&this.adjustDomainToVisiblePoints(this._yScale,this._xScale,!1)},c.prototype.adjustDomainToVisiblePoints=function(b,c,d){if(c instanceof a.Scale.AbstractQuantitative){var e=c,f=this.normalizeDatasets(d),g=this.adjustDomainOverVisiblePoints(f,b.domain());if(0===g.length)return;g=e.domainer().computeDomain([g],e),e.domain(g)}},c.prototype.normalizeDatasets=function(b){var c=this,d=this._projections[b?"x":"y"].accessor,e=this._projections[b?"y":"x"].accessor;return a._Util.Methods.flatten(this._datasetKeysInOrder.map(function(a){var b=c._key2PlotDatasetKey.get(a).dataset,f=c._key2PlotDatasetKey.get(a).plotMetadata;return b.data().map(function(a,c){return{a:d(a,c,b.metadata(),f),b:e(a,c,b.metadata(),f)}})}))},c.prototype.adjustDomainOverVisiblePoints=function(b,c){var d=b.filter(function(a){return c[0]<=a.a&&a.a<=c[1]}).map(function(a){return a.b}),e=[];return 0!==d.length&&(e=[a._Util.Methods.min(d,null),a._Util.Methods.max(d,null)]),e},c}(b.AbstractPlot);b.AbstractXYPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.closeDetectionRadius=5,this.classed("scatter-plot",!0),this.project("r",3),this.project("opacity",.6);var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this._animators["circles-reset"]=new a.Animator.Null,this._animators.circles=(new a.Animator.Base).duration(250).delay(5)}return __extends(c,b),c.prototype.project=function(a,c,d){return a="cx"===a?"x":a,a="cy"===a?"y":a,b.prototype.project.call(this,a,c,d),this},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("circle")},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this);return a.cx=a.x,delete a.x,a.cy=a.y,delete a.y,a},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.r=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("circles-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("circles")}),a},c.prototype._getClosestStruckPoint=function(a,b){var c,d,e=this._getDrawersInOrder(),f=this._generateAttrToProjector(),g=function(b,c){var d=f.cx(b,c,null,null)-a.x,e=f.cy(b,c,null,null)-a.y;return d*d+e*e},h=!1,i=b*b;if(e.forEach(function(a){a._getDrawSelection().each(function(a,b){var e=g(a,b),j=f.r(a,b,null,null);j*j>e?((!h||i>e)&&(c=this,d=b,i=e),h=!0):!h&&i>e&&(c=this,d=b,i=e)})}),!c)return{selection:null,pixelPositions:null,data:null};var j=d3.select(c),k=j.data(),l={x:f.cx(k[0],d,null,null),y:f.cy(k[0],d,null,null)};return{selection:j,pixelPositions:[l],data:k}},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){},c.prototype._doHover=function(a){return this._getClosestStruckPoint(a,this.closeDetectionRadius)},c}(b.AbstractXYPlot);b.Scatter=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){b.call(this,c,d),this._animators={cells:new a.Animator.Null},this.classed("grid-plot",!0),this._xScale.rangeType("bands",0,0),this._yScale.rangeType("bands",0,0),this._colorScale=e,this.project("fill","value",e),this._animators.cells=new a.Animator.Null}return __extends(c,b),c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Grid plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("rect")},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"fill"===a&&(this._colorScale=this._projections.fill.scale),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=this._xScale.rangeBand(),d=this._yScale.rangeBand();return a.width=function(){return c},a.height=function(){return d},a},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("cells")}]},c}(b.AbstractXYPlot);b.Grid=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this._barAlignmentFactor=.5,this._barLabelFormatter=a.Formatters.identity(),this._barLabelsEnabled=!1,this._hoverMode="point",this.hideBarsIfAnyAreTooWide=!0,this.classed("bar-plot",!0);var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this._animators["bars-reset"]=new a.Animator.Null,this._animators.bars=new a.Animator.Base,this._animators.baseline=new a.Animator.Null,this.baseline(0)}return __extends(c,b),c.prototype._getDrawer=function(b){return new a._Drawer.Rect(b,this._isVertical)},c.prototype._setup=function(){b.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},c.prototype.baseline=function(a){return null==a?this._baselineValue:(this._baselineValue=a,this._updateXDomainer(),this._updateYDomainer(),this._render(),this)},c.prototype.barAlignment=function(a){var b=a.toLowerCase(),c=this.constructor._BarAlignmentToFactor;if(void 0===c[b])throw new Error("unsupported bar alignment");return this._barAlignmentFactor=c[b],this._render(),this},c.prototype.parseExtent=function(a){if("number"==typeof a)return{min:a,max:a};if(a instanceof Object&&"min"in a&&"max"in a)return a;throw new Error("input '"+a+"' can't be parsed as an Extent")},c.prototype.barLabelsEnabled=function(a){return void 0===a?this._barLabelsEnabled:(this._barLabelsEnabled=a,this._render(),this)},c.prototype.barLabelFormatter=function(a){return null==a?this._barLabelFormatter:(this._barLabelFormatter=a,this._render(),this)},c.prototype.getAllBars=function(){return this._renderArea.selectAll("rect")},c.prototype.getBars=function(a,b){if(!this._isSetup)return d3.select();var c=[],d=this.parseExtent(a),e=this.parseExtent(b),f=.5;return this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").each(function(){var a=this.getBBox();a.x+a.width>=d.min-f&&a.x<=d.max+f&&a.y+a.height>=e.min-f&&a.y<=e.max+f&&c.push(this)})}),d3.selectAll(c)},c.prototype.deselectAll=function(){return this._isSetup&&this._getDrawersInOrder().forEach(function(a){return a._renderArea.selectAll("rect").classed("selected",!1)}),this},c.prototype._updateDomainer=function(b){if(b instanceof a.Scale.AbstractQuantitative){var c=b;c._userSetDomainer||(null!=this._baselineValue?c.domainer().addPaddingException(this._baselineValue,"BAR_PLOT+"+this._plottableID).addIncludedValue(this._baselineValue,"BAR_PLOT+"+this._plottableID):c.domainer().removePaddingException("BAR_PLOT+"+this._plottableID).removeIncludedValue("BAR_PLOT+"+this._plottableID),c.domainer().pad()),c._autoDomainIfAutomaticMode()}},c.prototype._updateYDomainer=function(){this._isVertical?this._updateDomainer(this._yScale):b.prototype._updateYDomainer.call(this)},c.prototype._updateXDomainer=function(){this._isVertical?b.prototype._updateXDomainer.call(this):this._updateDomainer(this._xScale)},c.prototype._additionalPaint=function(b){var c=this,d=this._isVertical?this._yScale:this._xScale,e=d.scale(this._baselineValue),f={x1:this._isVertical?0:e,y1:this._isVertical?e:0,x2:this._isVertical?this.width():e,y2:this._isVertical?e:this.height()};this._getAnimator("baseline").animate(this._baseline,f);var g=this._getDrawersInOrder();g.forEach(function(a){return a.removeLabels()}),this._barLabelsEnabled&&a._Util.Methods.setTimeout(function(){return c._drawLabels()},b)},c.prototype._drawLabels=function(){var a=this,b=this._getDrawersInOrder(),c=this._generateAttrToProjector(),d=this._getDataToDraw();this._datasetKeysInOrder.forEach(function(e,f){return b[f].drawText(d.get(e),c,a._key2PlotDatasetKey.get(e).dataset.metadata(),a._key2PlotDatasetKey.get(e).plotMetadata)}),this.hideBarsIfAnyAreTooWide&&b.some(function(a){return a._someLabelsTooWide})&&b.forEach(function(a){return a.removeLabels()})},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged&&this._animate){var b=this._generateAttrToProjector(),c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue),e=this._isVertical?"y":"x",f=this._isVertical?"height":"width";b[e]=function(){return d},b[f]=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("bars-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("bars")}),a},c.prototype._generateAttrToProjector=function(){var c=this,d=b.prototype._generateAttrToProjector.call(this),e=this._isVertical?this._yScale:this._xScale,f=this._isVertical?this._xScale:this._yScale,g=this._isVertical?"y":"x",h=this._isVertical?"x":"y",i=e.scale(this._baselineValue);d.width||(d.width=function(){return c._getBarPixelWidth()});var j=d[h],k=d.width,l=f instanceof a.Scale.Ordinal&&"bands"===f.rangeType();if(l){var m=f.rangeBand();d[h]=function(a,b,c,d){return j(a,b,c,d)-k(a,b,c,d)/2+m/2}}else d[h]=function(a,b,d,e){return j(a,b,d,e)-k(a,b,d,e)*c._barAlignmentFactor};var n=d[g];d[g]=function(a,b,c,d){var e=n(a,b,c,d);return e>i?i:e},d.height=function(a,b,c,d){return Math.abs(i-n(a,b,c,d))};var o=this._projections[g].accessor;return this.barLabelsEnabled&&this.barLabelFormatter&&(d.label=function(a,b,d,e){return c._barLabelFormatter(o(a,b,d,e))},d.positive=function(a,b,c,d){return n(a,b,c,d)<=i}),d},c.prototype._getBarPixelWidth=function(){var b,c=this,d=this._isVertical?this._xScale:this._yScale;if(d instanceof a.Scale.Ordinal){var e=d;if("bands"===e.rangeType())b=e.rangeBand();else{var f=2*e._outerPadding,g=this._isVertical?this.width():this.height(),h=g/(f+e.domain().length-1);b=h*f*.5}}else{var i=this._isVertical?this._projections.x.accessor:this._projections.y.accessor,j=d3.set(a._Util.Methods.flatten(this._datasetKeysInOrder.map(function(a){var b=c._key2PlotDatasetKey.get(a).dataset,d=c._key2PlotDatasetKey.get(a).plotMetadata;return b.data().map(function(a,c){return i(a,c,b.metadata(),d)})}))).values();if(j.some(function(a){return"undefined"===a}))return-1;var k=d3.set(a._Util.Methods.flatten(this._datasetKeysInOrder.map(function(a){var b=c._key2PlotDatasetKey.get(a).dataset,d=c._key2PlotDatasetKey.get(a).plotMetadata;return b.data().map(function(a,c){return i(a,c,b.metadata(),d).valueOf()})}))).values().map(function(a){return+a});k.sort(function(a,b){return a-b});var l=d3.pairs(k),m=this._isVertical?this.width():this.height();b=.95*a._Util.Methods.min(l,function(a){return Math.abs(d.scale(a[1])-d.scale(a[0]))},.4*m)}return b},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode");return this._hoverMode=b,this},c.prototype.clearHoverSelection=function(){this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed("not-hovered hovered",!1)})},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){this.clearHoverSelection()},c.prototype._doHover=function(a){var b=this,c=a.x,d=a.y;if("line"===this._hoverMode){var e={min:-1/0,max:1/0};this._isVertical?d=e:c=e}var f=this.getBars(c,d);if(f.empty())return this.clearHoverSelection(),{data:null,pixelPositions:null,selection:null};this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed({hovered:!1,"not-hovered":!0})}),f.classed({hovered:!0,"not-hovered":!1});var g=[],h=this._generateAttrToProjector();return f.each(function(a,c){g.push(b._isVertical?{x:h.x(a,c,null,null)+h.width(a,c,null,null)/2,y:h.y(a,c,null,null)+(h.positive(a,c,null,null)?0:h.height(a,c,null,null))}:{x:h.x(a,c,null,null)+(h.positive(a,c,null,null)?0:h.width(a,c,null,null)),y:h.y(a,c,null,null)+h.height(a,c,null,null)/2})}),{data:f.data(),pixelPositions:g,selection:f}},c._BarAlignmentToFactor={},c._DEFAULT_WIDTH=10,c}(b.AbstractXYPlot);b.AbstractBarPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){this._isVertical=!0,a.call(this,b,c)}return __extends(b,a),b.prototype._updateYDomainer=function(){this._updateDomainer(this._yScale)},b._BarAlignmentToFactor={left:0,center:.5,right:1},b}(a.AbstractBarPlot);a.VerticalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){a.call(this,b,c)}return __extends(b,a),b.prototype._updateXDomainer=function(){this._updateDomainer(this._xScale)},b.prototype._generateAttrToProjector=function(){var b=a.prototype._generateAttrToProjector.call(this),c=b.width;return b.width=b.height,b.height=c,b},b._BarAlignmentToFactor={top:0,center:.5,bottom:1},b}(a.AbstractBarPlot);a.HorizontalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.hoverDetectionRadius=15,this.classed("line-plot",!0);var e=(new a.Scale.Color).range()[0];this.project("stroke",function(){return e}),this.project("stroke-width",function(){return"2px"}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this.hoverTarget=this._foregroundContainer.append("circle").classed("hover-target",!0).style("visibility","hidden")},c.prototype._rejectNullsAndNaNs=function(a,b,c,d,e){var f=e(a,b,c,d);return null!=f&&f===f},c.prototype._getDrawer=function(b){return new a._Drawer.Line(b)},c.prototype._getResetYFunction=function(){var a=this._yScale.domain(),b=Math.max(a[0],a[1]),c=Math.min(a[0],a[1]),d=0>b&&b||c>0&&c||0,e=this._yScale.scale(d);return function(){return e}},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.y=this._getResetYFunction(),a.push({attrToProjector:b,animator:this._getAnimator("reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("main")}),a},c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this),d=this._wholeDatumAttributes(),e=function(a){return-1===d.indexOf(a)},f=d3.keys(c).filter(e);f.forEach(function(a){var b=c[a];c[a]=function(a,c,d,e){return a.length>0?b(a[0],c,d,e):null}});var g=c.x,h=c.y;return c.defined=function(b,c,d,e){return a._rejectNullsAndNaNs(b,c,d,e,g)&&a._rejectNullsAndNaNs(b,c,d,e,h)},c},c.prototype._wholeDatumAttributes=function(){return["x","y"]},c.prototype._getClosestWithinRange=function(a,b){var c,d,e=this._generateAttrToProjector(),f=e.x,g=e.y,h=function(b,c){var d=+f(b,c,null,null)-a.x,e=+g(b,c,null,null)-a.y;return d*d+e*e},i=b*b;return this.datasets().forEach(function(a){a.data().forEach(function(a,b){var e=h(a,b);i>e&&(c=a,d={x:f(a,b,null,null),y:g(a,b,null,null)},i=e)})}),{closestValue:c,closestPoint:d}},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){},c.prototype._doHover=function(a){var b=this._getClosestWithinRange(a,this.hoverDetectionRadius),c=b.closestValue;if(void 0===c)return{data:null,pixelPositions:null,selection:null};var d=b.closestPoint;return this.hoverTarget.attr({cx:b.closestPoint.x,cy:b.closestPoint.y}),{data:[c],pixelPositions:[d],selection:this.hoverTarget}},c}(b.AbstractXYPlot);b.Line=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.classed("area-plot",!0),this.project("y0",0,d),this.project("fill-opacity",function(){return.25});var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this.project("stroke",function(){return e}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),null!=this._yScale&&this._updateYDomainer()},c.prototype._getDrawer=function(b){return new a._Drawer.Area(b)},c.prototype._updateYDomainer=function(){var c=this;b.prototype._updateYDomainer.call(this);var d,e=this._projections.y0,f=e&&e.accessor;if(null!=f){var g=this.datasets().map(function(a){return a._getExtent(f,c._yScale._typeCoercer)}),h=a._Util.Methods.flatten(g),i=a._Util.Methods.uniq(h);1===i.length&&(d=i[0])}this._yScale._userSetDomainer||(null!=d?this._yScale.domainer().addPaddingException(d,"AREA_PLOT+"+this._plottableID):this._yScale.domainer().removePaddingException("AREA_PLOT+"+this._plottableID),this._yScale._autoDomainIfAutomaticMode())},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"y0"===a&&this._updateYDomainer(),this},c.prototype._getResetYFunction=function(){return this._generateAttrToProjector().y0},c.prototype._wholeDatumAttributes=function(){var a=b.prototype._wholeDatumAttributes.call(this);return a.push("y0"),a},c}(b.Line);b.Area=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(a,b,d){void 0===d&&(d=!0),this._isVertical=d,c.call(this,a,b)}return __extends(d,c),d.prototype._generateAttrToProjector=function(){var a=c.prototype._generateAttrToProjector.call(this),b=this.makeInnerScale(),d=function(){return b.rangeBand()},e=a.height;a.width=this._isVertical?d:e,a.height=this._isVertical?e:d;var f=function(a){return a._PLOTTABLE_PROTECTED_FIELD_POSITION};return a.x=this._isVertical?f:a.x,a.y=this._isVertical?a.y:f,a},d.prototype._getDataToDraw=function(){var b=this,c=this._isVertical?this._projections.x.accessor:this._projections.y.accessor,d=this.makeInnerScale(),e=d3.map();return this._datasetKeysInOrder.forEach(function(f){var g=b._key2PlotDatasetKey.get(f).dataset,h=b._key2PlotDatasetKey.get(f).plotMetadata;e.set(f,g.data().map(function(e,i){var j=c(e,i,g.metadata(),h),k=b._isVertical?b._xScale:b._yScale,l=a._Util.Methods.copyMap(e);return l._PLOTTABLE_PROTECTED_FIELD_POSITION=k.scale(j)+d.scale(f),l}))}),e},d.prototype.makeInnerScale=function(){var c=new a.Scale.Ordinal;if(c.domain(this._datasetKeysInOrder),this._projections.width){var d=this._projections.width,e=d.accessor,f=d.scale,g=f?function(a,b,c,d){return f.scale(e(a,b,c,d))}:e;c.range([0,g(null,0,null,null)])}else{var h=this._isVertical?this._xScale:this._yScale,i=h instanceof a.Scale.Ordinal&&"bands"===h.rangeType(),j=i?h.rangeBand():b.AbstractBarPlot._DEFAULT_WIDTH;c.range([0,j])}return c},d}(b.AbstractBarPlot);b.ClusteredBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.stackedExtent=[0,0]}return __extends(c,b),c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),this._projections.x&&this._projections.y&&("x"===a||"y"===a)&&this._updateStackOffsets(),this},c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),this._datasetKeysInOrder&&this._projections.x&&this._projections.y&&this._updateStackOffsets()},c.prototype._updateStackOffsets=function(){var b=this._generateDefaultMapArray(),c=this._getDomainKeys(),d=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.max(0,b.get(a).value)}})}),e=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.min(b.get(a).value,0)}})});this._setDatasetStackOffsets(this._stack(d),this._stack(e)),this._updateStackExtents()},c.prototype._updateStackExtents=function(){var b=this,c=(this.datasets(),this._valueAccessor()),d=a._Util.Methods.max(this._datasetKeysInOrder,function(d){var e=b._key2PlotDatasetKey.get(d).dataset,f=b._key2PlotDatasetKey.get(d).plotMetadata;return a._Util.Methods.max(e.data(),function(a,b){return+c(a,b,e.metadata(),f)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0),e=a._Util.Methods.min(this._datasetKeysInOrder,function(d){var e=b._key2PlotDatasetKey.get(d).dataset,f=b._key2PlotDatasetKey.get(d).plotMetadata;return a._Util.Methods.min(e.data(),function(a,b){return+c(a,b,e.metadata(),f)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0);this.stackedExtent=[Math.min(e,0),Math.max(0,d)]},c.prototype._stack=function(a){var b=this,c=function(a,b){a.offset=b};return d3.layout.stack().x(function(a){return a.key}).y(function(a){return+a.value}).values(function(a){return b._getDomainKeys().map(function(b){return a.get(b)})}).out(c)(a),a},c.prototype._setDatasetStackOffsets=function(a,b){var c=this,d=this._keyAccessor(),e=this._valueAccessor();this._datasetKeysInOrder.forEach(function(f,g){var h=c._key2PlotDatasetKey.get(f).dataset,i=c._key2PlotDatasetKey.get(f).plotMetadata,j=a[g],k=b[g],l=h.data().every(function(a,b){return e(a,b,h.metadata(),i)<=0 +});h.data().forEach(function(a,b){var c=j.get(d(a,b,h.metadata(),i)).offset,f=k.get(d(a,b,h.metadata(),i)).offset,g=e(a,b,h.metadata(),i);a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET=0===g?l?f:c:g>0?c:f})})},c.prototype._getDomainKeys=function(){{var a=this,b=this._keyAccessor(),c=d3.set();this.datasets()}return this._datasetKeysInOrder.forEach(function(d){var e=a._key2PlotDatasetKey.get(d).dataset,f=a._key2PlotDatasetKey.get(d).plotMetadata;e.data().forEach(function(a,d){c.add(b(a,d,e.metadata(),f))})}),c.values()},c.prototype._generateDefaultMapArray=function(){var b=this,c=this._keyAccessor(),d=this._valueAccessor(),e=this.datasets(),f=this._getDomainKeys(),g=e.map(function(){return a._Util.Methods.populateMap(f,function(a){return{key:a,value:0}})});return this._datasetKeysInOrder.forEach(function(a,e){var f=b._key2PlotDatasetKey.get(a).dataset,h=b._key2PlotDatasetKey.get(a).plotMetadata;f.data().forEach(function(a,b){var i=c(a,b,f.metadata(),h),j=d(a,b,f.metadata(),h);g[e].set(i,{key:i,value:j})})}),g},c.prototype._updateScaleExtents=function(){b.prototype._updateScaleExtents.call(this);var a=this._isVertical?this._yScale:this._xScale;a&&(this._isAnchored&&this.stackedExtent.length>0?a._updateExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT",this.stackedExtent):a._removeExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT"))},c.prototype._keyAccessor=function(){return this._isVertical?this._projections.x.accessor:this._projections.y.accessor},c.prototype._valueAccessor=function(){return this._isVertical?this._projections.y.accessor:this._projections.x.accessor},c}(b.AbstractXYPlot);b.AbstractStacked=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d){c.call(this,b,d),this._baselineValue=0,this.classed("area-plot",!0);var e=(new a.Scale.Color).range()[0];this.project("fill",function(){return e}),this._isVertical=!0}return __extends(d,c),d.prototype._getDrawer=function(b){return new a._Drawer.Area(b).drawLine(!1)},d.prototype._setup=function(){c.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},d.prototype._updateStackOffsets=function(){var b=this,d=this._getDomainKeys(),e=this._isVertical?this._projections.x.accessor:this._projections.y.accessor,f=this._datasetKeysInOrder.map(function(a){var c=b._key2PlotDatasetKey.get(a).dataset,d=b._key2PlotDatasetKey.get(a).plotMetadata;return d3.set(c.data().map(function(a,b){return e(a,b,c.metadata(),d).toString()})).values()});f.some(function(a){return a.length!==d.length})&&a._Util.Methods.warn("the domains across the datasets are not the same. Plot may produce unintended behavior."),c.prototype._updateStackOffsets.call(this)},d.prototype._additionalPaint=function(){var a=this._yScale.scale(this._baselineValue),b={x1:0,y1:a,x2:this.width(),y2:a};this._getAnimator("baseline").animate(this._baseline,b)},d.prototype._updateYDomainer=function(){c.prototype._updateYDomainer.call(this);var a=this._yScale;a._userSetDomainer||(a.domainer().addPaddingException(0,"STACKED_AREA_PLOT+"+this._plottableID),a._autoDomainIfAutomaticMode())},d.prototype._onDatasetUpdate=function(){c.prototype._onDatasetUpdate.call(this),b.Area.prototype._onDatasetUpdate.apply(this)},d.prototype._generateAttrToProjector=function(){var a=this,b=c.prototype._generateAttrToProjector.call(this),d=this._wholeDatumAttributes(),e=function(a){return-1===d.indexOf(a)},f=d3.keys(b).filter(e);f.forEach(function(a){var c=b[a];b[a]=function(a,b,d,e){return a.length>0?c(a[0],b,d,e):null}});var g=this._projections.y.accessor;return b.y=function(b,c,d,e){return a._yScale.scale(+g(b,c,d,e)+b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},b.y0=function(b){return a._yScale.scale(b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},b},d.prototype._wholeDatumAttributes=function(){return["x","y","defined"]},d}(b.AbstractStacked);b.StackedArea=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=!0),this._isVertical=e,this._baselineValue=0,c.call(this,b,d),this.classed("bar-plot",!0);var f=(new a.Scale.Color).range()[0];this.project("fill",function(){return f}),this.baseline(this._baselineValue),this._isVertical=e}return __extends(d,c),d.prototype._getAnimator=function(b){if(this._animate&&this._animateOnNextRender){if(this._animators[b])return this._animators[b];if("stacked-bar"===b){var c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue);return new a.Animator.MovingRect(d,this._isVertical)}}return new a.Animator.Null},d.prototype._generateAttrToProjector=function(){var a=this,c=b.AbstractBarPlot.prototype._generateAttrToProjector.apply(this),d=this._isVertical?"y":"x",e=this._isVertical?this._yScale:this._xScale,f=this._projections[d].accessor,g=function(a){return e.scale(a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},h=function(a,b,c,d){return e.scale(+f(a,b,c,d)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},i=function(a,b,c,d){return Math.abs(h(a,b,c,d)-g(a,b,c,d))},j=c.width;c.height=this._isVertical?i:j,c.width=this._isVertical?j:i;var k=function(a,b,c,d){return+f(a,b,c,d)<0?g(a,b,c,d):h(a,b,c,d)};return c[d]=function(b,c,d,e){return a._isVertical?k(b,c,d,e):k(b,c,d,e)-i(b,c,d,e)},c},d.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("stacked-bar")}]},d.prototype.project=function(a,d,e){return c.prototype.project.call(this,a,d,e),b.AbstractStacked.prototype.project.apply(this,[a,d,e]),this},d.prototype._onDatasetUpdate=function(){return c.prototype._onDatasetUpdate.call(this),b.AbstractStacked.prototype._onDatasetUpdate.apply(this),this},d.prototype._updateStackOffsets=function(){b.AbstractStacked.prototype._updateStackOffsets.call(this)},d.prototype._updateStackExtents=function(){b.AbstractStacked.prototype._updateStackExtents.call(this)},d.prototype._stack=function(a){return b.AbstractStacked.prototype._stack.call(this,a)},d.prototype._setDatasetStackOffsets=function(a,c){b.AbstractStacked.prototype._setDatasetStackOffsets.call(this,a,c)},d.prototype._getDomainKeys=function(){return b.AbstractStacked.prototype._getDomainKeys.call(this)},d.prototype._generateDefaultMapArray=function(){return b.AbstractStacked.prototype._generateDefaultMapArray.call(this)},d.prototype._updateScaleExtents=function(){b.AbstractStacked.prototype._updateScaleExtents.call(this)},d.prototype._keyAccessor=function(){return b.AbstractStacked.prototype._keyAccessor.call(this)},d.prototype._valueAccessor=function(){return b.AbstractStacked.prototype._valueAccessor.call(this)},d.prototype._getBarPixelWidth=function(){return b.AbstractBarPlot.prototype._getBarPixelWidth.apply(this)},d}(b.AbstractBarPlot);b.StackedBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.prototype.getTiming=function(){return 0},a.prototype.animate=function(a,b){return a.attr(b)},a}();a.Null=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._duration=a.DEFAULT_DURATION_MILLISECONDS,this._delay=a.DEFAULT_DELAY_MILLISECONDS,this._easing=a.DEFAULT_EASING,this._maxIterativeDelay=a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS,this._maxTotalDuration=a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS}return a.prototype.getTiming=function(a){var b=Math.max(this.maxTotalDuration()-this.duration(),0),c=Math.min(this.maxIterativeDelay(),b/Math.max(a-1,1)),d=c*a+this.delay()+this.duration();return d},a.prototype.animate=function(a,b){var c=this,d=a[0].length,e=Math.max(this.maxTotalDuration()-this.duration(),0),f=Math.min(this.maxIterativeDelay(),e/Math.max(d-1,1));return a.transition().ease(this.easing()).duration(this.duration()).delay(function(a,b){return c.delay()+f*b}).attr(b)},a.prototype.duration=function(a){return null==a?this._duration:(this._duration=a,this)},a.prototype.delay=function(a){return null==a?this._delay:(this._delay=a,this)},a.prototype.easing=function(a){return null==a?this._easing:(this._easing=a,this)},a.prototype.maxIterativeDelay=function(a){return null==a?this._maxIterativeDelay:(this._maxIterativeDelay=a,this)},a.prototype.maxTotalDuration=function(a){return null==a?this._maxTotalDuration:(this._maxTotalDuration=a,this)},a.DEFAULT_DURATION_MILLISECONDS=300,a.DEFAULT_DELAY_MILLISECONDS=0,a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS=15,a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS=600,a.DEFAULT_EASING="exp-out",a}();a.Base=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===b&&(b=!0),void 0===c&&(c=!1),a.call(this),this.isVertical=b,this.isReverse=c}return __extends(b,a),b.prototype.animate=function(c,d){var e={};return b.ANIMATED_ATTRIBUTES.forEach(function(a){return e[a]=d[a]}),e[this.getMovingAttr()]=this._startMovingProjector(d),e[this.getGrowingAttr()]=function(){return 0},c.attr(e),a.prototype.animate.call(this,c,d)},b.prototype._startMovingProjector=function(a){if(this.isVertical===this.isReverse)return a[this.getMovingAttr()];var b=a[this.getMovingAttr()],c=a[this.getGrowingAttr()];return function(a,d,e,f){return b(a,d,e,f)+c(a,d,e,f)}},b.prototype.getGrowingAttr=function(){return this.isVertical?"height":"width"},b.prototype.getMovingAttr=function(){return this.isVertical?"y":"x"},b.ANIMATED_ATTRIBUTES=["height","width","x","y","fill"],b}(a.Base);a.Rect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===c&&(c=!0),a.call(this,c),this.startPixelValue=b}return __extends(b,a),b.prototype._startMovingProjector=function(){return d3.functor(this.startPixelValue)},b}(a.Rect);a.MovingRect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(b){a.call(this),this._event2Callback={},this.connected=!1,this._target=b}return __extends(b,a),b.prototype.target=function(a){if(null==a)return this._target;var b=this.connected;return this.disconnect(),this._target=a,b&&this.connect(),this},b.prototype._getEventString=function(a){return a+".dispatcher"+this._plottableID},b.prototype.connect=function(){var a=this;if(this.connected)throw new Error("Can't connect dispatcher twice!");return this._target&&(this.connected=!0,Object.keys(this._event2Callback).forEach(function(b){var c=a._event2Callback[b];a._target.on(a._getEventString(b),c)})),this},b.prototype.disconnect=function(){var a=this;return this.connected=!1,this._target&&Object.keys(this._event2Callback).forEach(function(b){a._target.on(a._getEventString(b),null)}),this},b}(a.Core.PlottableObject);b.AbstractDispatcher=c}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this._event2Callback.mouseover=function(){null!=c._mouseover&&c._mouseover(c.getMousePosition())},this._event2Callback.mousemove=function(){null!=c._mousemove&&c._mousemove(c.getMousePosition())},this._event2Callback.mouseout=function(){null!=c._mouseout&&c._mouseout(c.getMousePosition())}}return __extends(b,a),b.prototype.getMousePosition=function(){var a=d3.mouse(this._target.node());return{x:a[0],y:a[1]}},b.prototype.mouseover=function(a){return void 0===a?this._mouseover:(this._mouseover=a,this)},b.prototype.mousemove=function(a){return void 0===a?this._mousemove:(this._mousemove=a,this)},b.prototype.mouseout=function(a){return void 0===a?this._mouseout:(this._mouseout=a,this)},b}(a.AbstractDispatcher);a.Mouse=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this.mousedOverTarget=!1,this.keydownListenerTarget=d3.select(document),this._event2Callback.mouseover=function(){c.mousedOverTarget=!0},this._event2Callback.mouseout=function(){c.mousedOverTarget=!1}}return __extends(b,a),b.prototype.connect=function(){var b=this;return a.prototype.connect.call(this),this.keydownListenerTarget.on(this._getEventString("keydown"),function(){b.mousedOverTarget&&b._onKeyDown&&b._onKeyDown(d3.event)}),this},b.prototype.disconnect=function(){return a.prototype.disconnect.call(this),this.keydownListenerTarget.on(this._getEventString("keydown"),null),this},b.prototype.onKeyDown=function(a){return void 0===a?this._onKeyDown:(this._onKeyDown=a,this)},b}(a.AbstractDispatcher);a.Keypress=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(a,b){this._componentToListenTo=a,this._hitBox=b},b}(a.Core.PlottableObject);b.AbstractInteraction=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(b,c){var d=this;a.prototype._anchor.call(this,b,c),c.on(this._listenTo(),function(){var a=d3.mouse(c.node()),b=a[0],e=a[1];d._callback({x:b,y:e})})},b.prototype._listenTo=function(){return"click"},b.prototype.callback=function(a){return this._callback=a,this},b}(a.AbstractInteraction);a.Click=b;var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._listenTo=function(){return"dblclick"},b}(b);a.DoubleClick=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.activated=!1,this.keyCode2Callback={},this.dispatcher=new a.Dispatcher.Keypress}return __extends(c,b),c.prototype._anchor=function(a,c){var d=this;b.prototype._anchor.call(this,a,c),this.dispatcher.target(this._hitBox),this.dispatcher.onKeyDown(function(a){d.keyCode2Callback[a.keyCode]&&d.keyCode2Callback[a.keyCode]()}),this.dispatcher.connect()},c.prototype.on=function(a,b){return this.keyCode2Callback[a]=b,this},c}(b.AbstractInteraction);b.Key=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;b.call(this),null==c&&(c=new a.Scale.Linear),null==d&&(d=new a.Scale.Linear),this._xScale=c,this._yScale=d,this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return e.rerenderZoomed()})}return __extends(c,b),c.prototype.resetZoom=function(){var a=this;this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return a.rerenderZoomed()}),this.zoom(this._hitBox)},c.prototype._anchor=function(a,c){b.prototype._anchor.call(this,a,c),this.zoom(c)},c.prototype.rerenderZoomed=function(){var a=this._xScale._d3Scale.domain(),b=this._yScale._d3Scale.domain();this._xScale.domain(a),this._yScale.domain(b)},c}(b.AbstractInteraction);b.PanZoom=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){var b=this;a.call(this),this.dragInitialized=!1,this.origin=[0,0],this.location=[0,0],this._isDragging=!1,this.dragBehavior=d3.behavior.drag(),this.dragBehavior.on("dragstart",function(){return b._dragstart()}),this.dragBehavior.on("drag",function(){return b._drag()}),this.dragBehavior.on("dragend",function(){return b._dragend()})}return __extends(b,a),b.prototype.dragstart=function(a){return void 0===a?this.ondragstart:(this.ondragstart=a,this)},b.prototype._setOrigin=function(a,b){this.origin=[a,b]},b.prototype._getOrigin=function(){return this.origin.slice()},b.prototype._setLocation=function(a,b){this.location=[a,b]},b.prototype._getLocation=function(){return this.location.slice()},b.prototype.drag=function(a){return void 0===a?this.ondrag:(this.ondrag=a,this)},b.prototype.dragend=function(a){return void 0===a?this.ondragend:(this.ondragend=a,this)},b.prototype._dragstart=function(){this._isDragging=!0;var a=this._componentToListenTo.width(),b=this._componentToListenTo.height(),c=function(a,b){return function(c){return Math.min(Math.max(c,a),b)}};this._constrainX=c(0,a),this._constrainY=c(0,b);var d=d3.mouse(this._hitBox[0][0].parentNode);this._setOrigin(d[0],d[1]),this._doDragstart()},b.prototype._doDragstart=function(){null!=this.ondragstart&&this.ondragstart({x:this._getOrigin()[0],y:this._getOrigin()[1]})},b.prototype._drag=function(){this._setLocation(this._constrainX(d3.event.x),this._constrainY(d3.event.y)),this._doDrag()},b.prototype._doDrag=function(){if(null!=this.ondrag){var a={x:this._getOrigin()[0],y:this._getOrigin()[1]},b={x:this._getLocation()[0],y:this._getLocation()[1]};this.ondrag(a,b)}},b.prototype._dragend=function(){var a=d3.mouse(this._hitBox[0][0].parentNode);this._setLocation(a[0],a[1]),this._isDragging=!1,this._doDragend()},b.prototype._doDragend=function(){if(null!=this.ondragend){var a={x:this._getOrigin()[0],y:this._getOrigin()[1]},b={x:this._getLocation()[0],y:this._getLocation()[1]};this.ondragend(a,b)}},b.prototype._anchor=function(b,c){return a.prototype._anchor.call(this,b,c),c.call(this.dragBehavior),this},b.prototype.setupZoomCallback=function(a,b){function c(c,g){return null==c||null==g?(f&&(null!=a&&a.domain(d),null!=b&&b.domain(e)),void(f=!f)):(f=!1,null!=a&&a.domain([a.invert(c.x),a.invert(g.x)]),null!=b&&b.domain([b.invert(g.y),b.invert(c.y)]),void this.clearBox())}var d=null!=a?a.domain():null,e=null!=b?b.domain():null,f=!1;return this.drag(c),this.dragend(c),this},b}(a.AbstractInteraction);a.Drag=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this._boxIsDrawn=!1,this._resizeXEnabled=!1,this._resizeYEnabled=!1,this.cursorStyle=""}return __extends(b,a),b.prototype.resizeEnabled=function(a){return null==a?this._resizeXEnabled||this._resizeYEnabled:(this._resizeXEnabled=a&&this.constructor._CAN_RESIZE_X,this._resizeYEnabled=a&&this.constructor._CAN_RESIZE_Y,this)},b.prototype.isResizingX=function(){return!!this.xResizing},b.prototype.isResizingY=function(){return!!this.yResizing},b.prototype.boxIsDrawn=function(){return this._boxIsDrawn},b.prototype.isResizing=function(){return this.isResizingX()||this.isResizingY()},b.prototype._dragstart=function(){var b=d3.mouse(this._hitBox[0][0].parentNode);if(this.boxIsDrawn()){var c=this.getResizeInfo(b[0],b[1]);if(this.xResizing=c.xResizing,this.yResizing=c.yResizing,this.isResizing())return}a.prototype._dragstart.call(this),this.clearBox()},b.prototype.getResizeInfo=function(a,c){function d(a,b,c,d){return Math.min(b,c)-d<=a&&a<=Math.max(b,c)+d}function e(a,b,c,d){var e=Math.min(a,b),f=Math.max(a,b),g=Math.min(d,(f-e)/2);return c>e-d&&e+g>c?{offset:c-e,positive:!1,origin:a===e}:c>f-g&&f+d>c?{offset:c-f,positive:!0,origin:a===f}:null}var f=null,g=null,h=this._getOrigin()[0],i=this._getOrigin()[1],j=this._getLocation()[0],k=this._getLocation()[1];return this._resizeXEnabled&&d(c,i,k,b.RESIZE_PADDING)&&(f=e(h,j,a,b.RESIZE_PADDING)),this._resizeYEnabled&&d(a,h,j,b.RESIZE_PADDING)&&(g=e(i,k,c,b.RESIZE_PADDING)),{xResizing:f,yResizing:g}},b.prototype._drag=function(){if(this.isResizing()){if(this.isResizingX()){var b=this.xResizing.offset,c=d3.event.x;0!==b&&(c+=b,this.xResizing.offset+=b>0?-1:1),this.xResizing.origin?this._setOrigin(this._constrainX(c),this._getOrigin()[1]):this._setLocation(this._constrainX(c),this._getLocation()[1])}if(this.isResizingY()){var d=this.yResizing.offset,e=d3.event.y;0!==d&&(e+=d,this.yResizing.offset+=d>0?-1:1),this.yResizing.origin?this._setOrigin(this._getOrigin()[0],this._constrainY(e)):this._setLocation(this._getLocation()[0],this._constrainY(e))}this._doDrag()}else a.prototype._drag.call(this);this.setBox(this._getOrigin()[0],this._getLocation()[0],this._getOrigin()[1],this._getLocation()[1])},b.prototype._dragend=function(){this.xResizing=null,this.yResizing=null,a.prototype._dragend.call(this)},b.prototype.clearBox=function(){return null!=this.dragBox?(this.dragBox.attr("height",0).attr("width",0),this._boxIsDrawn=!1,this):void 0},b.prototype.setBox=function(a,b,c,d){if(null!=this.dragBox){var e=Math.abs(a-b),f=Math.abs(c-d),g=Math.min(a,b),h=Math.min(c,d);return this.dragBox.attr({x:g,y:h,width:e,height:f}),this._boxIsDrawn=e>0&&f>0,this}},b.prototype._anchor=function(c,d){var e=this;a.prototype._anchor.call(this,c,d);var f=b.CLASS_DRAG_BOX,g=this._componentToListenTo._backgroundContainer;return this.dragBox=g.append("rect").classed(f,!0).attr("x",0).attr("y",0),d.on("mousemove",function(){return e._hover()}),this},b.prototype._hover=function(){if(this.resizeEnabled()&&!this._isDragging&&this._boxIsDrawn){var a=d3.mouse(this._hitBox[0][0].parentNode);this.cursorStyle=this.getCursorStyle(a[0],a[1])}else this._boxIsDrawn||(this.cursorStyle="");this._hitBox.style("cursor",this.cursorStyle)},b.prototype.getCursorStyle=function(a,b){var c=this.getResizeInfo(a,b),d=c.xResizing&&!c.xResizing.positive,e=c.xResizing&&c.xResizing.positive,f=c.yResizing&&!c.yResizing.positive,g=c.yResizing&&c.yResizing.positive;return d&&f||g&&e?"nwse-resize":f&&e||g&&d?"nesw-resize":d||e?"ew-resize":f||g?"ns-resize":""},b.CLASS_DRAG_BOX="drag-box",b.RESIZE_PADDING=10,b._CAN_RESIZE_X=!0,b._CAN_RESIZE_Y=!0,b}(a.Drag);a.DragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._setOrigin=function(b){a.prototype._setOrigin.call(this,b,0)},b.prototype._setLocation=function(b){a.prototype._setLocation.call(this,b,this._componentToListenTo.height())},b._CAN_RESIZE_Y=!1,b}(a.DragBox);a.XDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){a._Util.Methods.warn("XYDragBox is deprecated; use DragBox instead"),b.call(this)}return __extends(c,b),c}(b.DragBox);b.XYDragBox=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._setOrigin=function(b,c){a.prototype._setOrigin.call(this,0,c)},b.prototype._setLocation=function(b,c){a.prototype._setLocation.call(this,this._componentToListenTo.width(),c)},b._CAN_RESIZE_X=!1,b}(a.DragBox);a.YDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentHoverData={data:null,pixelPositions:null,selection:null}}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mouseover(function(a){e._componentToListenTo._hoverOverComponent(a),e.handleHoverOver(a)}),this.dispatcher.mouseout(function(a){e._componentToListenTo._hoverOutComponent(a),e.safeHoverOut(e.currentHoverData),e.currentHoverData={data:null,pixelPositions:null,selection:null}}),this.dispatcher.mousemove(function(a){return e.handleHoverOver(a)}),this.dispatcher.connect()},c.diffHoverData=function(a,b){if(null==a.data||null==b.data)return a;var c=[],d=[],e=[];return a.data.forEach(function(f,g){-1===b.data.indexOf(f)&&(c.push(f),d.push(a.pixelPositions[g]),e.push(a.selection[0][g]))}),0===c.length?{data:null,pixelPositions:null,selection:null}:{data:c,pixelPositions:d,selection:d3.selectAll(e)}},c.prototype.handleHoverOver=function(a){var b=this.currentHoverData,d=this._componentToListenTo._doHover(a);this.currentHoverData=d;var e=c.diffHoverData(b,d);this.safeHoverOut(e);var f=c.diffHoverData(d,b);this.safeHoverOver(f)},c.prototype.safeHoverOut=function(a){this.hoverOutCallback&&a.data&&this.hoverOutCallback(a)},c.prototype.safeHoverOver=function(a){this.hoverOverCallback&&a.data&&this.hoverOverCallback(a)},c.prototype.onHoverOver=function(a){return this.hoverOverCallback=a,this},c.prototype.onHoverOut=function(a){return this.hoverOutCallback=a,this},c.prototype.getCurrentHoverData=function(){return this.currentHoverData},c}(b.AbstractInteraction);b.Hover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={})); \ No newline at end of file diff --git a/plottable.zip b/plottable.zip index 4978e34052..08bf286c54 100644 Binary files a/plottable.zip and b/plottable.zip differ diff --git a/quicktests/html/clustered_bar.html b/quicktests/html/clustered_bar.html index b71fcd3646..14c70d8573 100644 --- a/quicktests/html/clustered_bar.html +++ b/quicktests/html/clustered_bar.html @@ -12,8 +12,6 @@ padding: 20px; } - - diff --git a/quicktests/html/domain_adjustment_algorithm.html b/quicktests/html/domain_adjustment_algorithm.html index 026d580512..2d4e4ab0be 100644 --- a/quicktests/html/domain_adjustment_algorithm.html +++ b/quicktests/html/domain_adjustment_algorithm.html @@ -1,7 +1,7 @@ - Y Scale domain adjustment algorithm + Domain Adjustment Algorithm + + + + + + + + + +
+ + + diff --git a/quicktests/html/interaction_hover_scatter.html b/quicktests/html/interaction_hover_scatter.html index 891c08f3ff..5969da4f71 100644 --- a/quicktests/html/interaction_hover_scatter.html +++ b/quicktests/html/interaction_hover_scatter.html @@ -1,6 +1,7 @@ + - Interaction.Hover + Plot.Scatter + Interaction Hover Scatter + + + + + + + + + +
+ + + diff --git a/quicktests/html/tick_generator.html b/quicktests/html/tick_generator.html index 85b8d6d4da..fe2c79a9f1 100644 --- a/quicktests/html/tick_generator.html +++ b/quicktests/html/tick_generator.html @@ -1,7 +1,7 @@ - Tick generator + Tick Generator