diff --git a/Gruntfile.js b/Gruntfile.js index 596aa17666..60af2106ee 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -51,32 +51,12 @@ module.exports = function(grunt) { } }; - var prefixMatch = "\\n *(function |var |static )?"; - var varNameMatch = "[^(:;]*(\\([^)]*\\))?"; // catch function args too - var nestedBraceMatch = ": \\{[^{}]*\\}"; - var typeNameMatch = ": [^;]*"; - var finalMatch = "((" + nestedBraceMatch + ")|(" + typeNameMatch + "))?\\n?;"; - var jsdocInit = "\\n *\\/\\*\\* *\\n"; - var jsdocMid = "( *\\*[^\\n]*\\n)+"; - var jsdocEnd = " *\\*\\/ *"; - var jsdoc = "(" + jsdocInit + jsdocMid + jsdocEnd + ")?"; - var sedConfig = { - privateDefinitions: { - pattern: jsdoc + prefixMatch + "private " + varNameMatch + finalMatch, - replacement: "", - path: "build/plottable.d.ts" - }, definitions: { pattern: '/// *', replacement: "", path: "build/plottable.d.ts" }, - sublime: { - pattern: "(.*\\.ts)", - replacement: '/// ', - path: "build/sublime.d.ts" - }, versionNumber: { pattern: "@VERSION", replacement: "<%= pkg.version %>", @@ -92,7 +72,7 @@ module.exports = function(grunt) { // on each recompile var updateTsFiles = function() { tsFiles = grunt.file.read("src/reference.ts") - .split("\n") + .split(grunt.util.linefeed) .filter(function(s) { return s !== ""; }).map(function(s) { @@ -104,7 +84,7 @@ module.exports = function(grunt) { var testTsFiles; var updateTestTsFiles = function() { testTsFiles = grunt.file.read("test/testReference.ts") - .split("\n") + .split(grunt.util.linefeed) .filter(function(s) { return s !== ""; }).map(function(s) { @@ -271,12 +251,6 @@ module.exports = function(grunt) { } }; - var shellConfig = { - sublime: { - command: "(echo 'src/reference.ts'; find typings -name '*.d.ts') > build/sublime.d.ts" - } - }; - var saucelabsMochaConfig = { all: { options: { @@ -325,7 +299,6 @@ module.exports = function(grunt) { gitcommit: gitcommitConfig, compress: compressConfig, uglify: uglifyConfig, - shell: shellConfig, "saucelabs-mocha": saucelabsMochaConfig }); @@ -356,7 +329,6 @@ module.exports = function(grunt) { "concat:svgtypewriter", "concat:definitions", "sed:definitions", - "sed:privateDefinitions", "umd:all", "concat:header", "sed:versionNumber", @@ -391,9 +363,6 @@ module.exports = function(grunt) { grunt.registerTask("test-travis", ["dev-compile", "test-local"]); } - // Tooling - grunt.registerTask("sublime", ["shell:sublime", "sed:sublime"]); - grunt.registerTask("update-quicktests", function() { var qtJSON = []; var rawtests = grunt.file.expand("quicktests/overlaying/tests/**/*.js"); diff --git a/bower.json b/bower.json index 9164b1558c..35895b4954 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "plottable", "description": "A modular charting library built on D3", - "version": "1.14.0", + "version": "1.15.0", "main": ["plottable.js", "plottable.css"], "typescript": { "definition": "plottable.d.ts" diff --git a/package.json b/package.json index cfa9ce3fc7..b0cbf37e66 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plottable.js", "description": "A modular charting library built on D3", - "version": "1.14.0", + "version": "1.15.0", "license": "MIT", "repository": { "type": "git", diff --git a/plottable.d.ts b/plottable.d.ts index f2f7a5e139..c2a9a13b0d 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -67,6 +67,8 @@ declare module Plottable { * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map */ class Map { + private _keyValuePairs; + private _es6Map; constructor(); set(key: K, value: V): Map; get(key: K): V; @@ -86,6 +88,8 @@ declare module Plottable { */ class Set { size: number; + private _values; + private _es6Set; constructor(); add(value: T): Set; delete(value: T): boolean; @@ -350,6 +354,9 @@ declare module Plottable { declare module Plottable { module Utils { class ClientToSVGTranslator { + private static _TRANSLATOR_KEY; + private _svg; + private _measureRect; /** * Returns the ClientToSVGTranslator for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -391,6 +398,9 @@ declare module Plottable { declare module Plottable { type DatasetCallback = (dataset: Dataset) => void; class Dataset { + private _data; + private _metadata; + private _callbacks; /** * A Dataset contains an array of data and some metadata. * Changes to the data or metadata will cause anything subscribed to the Dataset to update. @@ -472,6 +482,7 @@ declare module Plottable { * but useful for browsers that don't suppoort `requestAnimationFrame`. */ class Timeout implements RenderPolicy { + private _timeoutMsec; render(): void; } } @@ -754,6 +765,10 @@ declare module Plottable { } } class Scale { + private _callbacks; + private _autoDomainAutomatically; + private _domainModificationInProgress; + private _includedValuesProviders; /** * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. * @@ -850,6 +865,12 @@ declare module Plottable { declare module Plottable { class QuantitativeScale extends Scale { protected static _DEFAULT_NUM_TICKS: number; + private _tickGenerator; + private _padProportion; + private _paddingExceptionsProviders; + private _domainMin; + private _domainMax; + private _snappingDomainEnabled; /** * A QuantitativeScale is a Scale that maps number-like values to numbers. * It is invertible and continuous. @@ -889,6 +910,7 @@ declare module Plottable { * @returns {QuantitativeScale} The calling QuantitativeScale. */ padProportion(padProportion: number): QuantitativeScale; + private _padDomain(domain); /** * Gets whether or not the scale snaps its domain to nice values. */ @@ -967,6 +989,7 @@ declare module Plottable { declare module Plottable { module Scales { class Linear extends QuantitativeScale { + private _d3Scale; /** * @constructor */ @@ -989,6 +1012,10 @@ declare module Plottable { declare module Plottable { module Scales { class ModifiedLog extends QuantitativeScale { + private _base; + private _d3Scale; + private _pivot; + private _untransformedDomain; /** * A ModifiedLog Scale acts as a regular log scale for large numbers. * As it approaches 0, it gradually becomes linear. @@ -1008,12 +1035,44 @@ declare module Plottable { * For negative values, scale(-x) = -scale(x). */ constructor(base?: number); + /** + * Returns an adjusted log10 value for graphing purposes. The first + * adjustment is that negative values are changed to positive during + * the calculations, and then the answer is negated at the end. The + * second is that, for values less than 10, an increasingly large + * (0 to 1) scaling factor is added such that at 0 the value is + * adjusted to 1, resulting in a returned result of 0. + */ + private _adjustedLog(x); + private _invertedAdjustedLog(x); scale(x: number): number; invert(x: number): number; protected _getDomain(): number[]; protected _setDomain(values: number[]): void; protected _setBackingScaleDomain(values: number[]): void; ticks(): number[]; + /** + * Return an appropriate number of ticks from lower to upper. + * + * This will first try to fit as many powers of this.base as it can from + * lower to upper. + * + * If it still has ticks after that, it will generate ticks in "clusters", + * e.g. [20, 30, ... 90, 100] would be a cluster, [200, 300, ... 900, 1000] + * would be another cluster. + * + * This function will generate clusters as large as it can while not + * drastically exceeding its number of ticks. + */ + private _logTicks(lower, upper); + /** + * How many ticks does the range [lower, upper] deserve? + * + * e.g. if your domain was [10, 1000] and I asked _howManyTicks(10, 100), + * I would get 1/2 of the ticks. The range 10, 100 takes up 1/2 of the + * distance when plotted. + */ + private _howManyTicks(lower, upper); protected _niceDomain(domain: number[], count?: number): number[]; protected _defaultExtent(): number[]; protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; @@ -1028,6 +1087,10 @@ declare module Plottable { declare module Plottable { module Scales { class Category extends Scale { + private _d3Scale; + private _range; + private _innerPadding; + private _outerPadding; /** * A Category Scale maps strings to numbers. * @@ -1041,6 +1104,8 @@ declare module Plottable { protected _setDomain(values: string[]): void; range(): [number, number]; range(values: [number, number]): Category; + private static _convertToPlottableInnerPadding(d3InnerPadding); + private static _convertToPlottableOuterPadding(d3OuterPadding, d3InnerPadding); /** * Returns the width of the range band. * @@ -1104,6 +1169,10 @@ declare module Plottable { declare module Plottable { module Scales { class Color extends Scale { + private static _LOOP_LIGHTEN_FACTOR; + private static _MAXIMUM_COLORS_FROM_CSS; + private static _plottableColorCache; + private _d3Scale; /** * A Color Scale maps string values to color hex values expressed as a string. * @@ -1116,6 +1185,7 @@ declare module Plottable { extentOfValues(values: string[]): string[]; protected _getExtent(): string[]; static invalidateColorCache(): void; + private static _getPlottableColors(); /** * Returns the color-string corresponding to a given string. * If there are not enough colors in the range(), a lightened version of an existing color will be used. @@ -1136,6 +1206,7 @@ declare module Plottable { declare module Plottable { module Scales { class Time extends QuantitativeScale { + private _d3Scale; /** * A Time Scale maps Date objects to numbers. * @@ -1177,6 +1248,9 @@ declare module Plottable { static REDS: string[]; static BLUES: string[]; static POSNEG: string[]; + private _colorRange; + private _colorScale; + private _d3Scale; /** * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. * @@ -1184,6 +1258,15 @@ declare module Plottable { */ constructor(scaleType?: string); extentOfValues(values: number[]): number[]; + /** + * Generates the converted QuantitativeScale. + */ + private _d3InterpolatedScale(); + /** + * Generates the d3 interpolator for colors. + */ + private _interpolateColors(); + private _resetScale(); autoDomain(): InterpolatedColor; scale(value: number): string; protected _getDomain(): number[]; @@ -1247,8 +1330,12 @@ declare module Plottable { }; } class Drawer { + private _renderArea; protected _svgElementName: string; protected _className: string; + private _dataset; + private _cachedSelectionValid; + private _cachedSelection; /** * A Drawer draws svg elements based on the input Dataset. * @@ -1271,7 +1358,20 @@ declare module Plottable { * Removes the Drawer and its renderArea */ remove(): void; + /** + * Binds data to selection + * + * @param{any[]} data The data to be drawn + */ + private _bindSelectionData(data); protected _applyDefaultAttributes(selection: d3.Selection): void; + /** + * Draws data using one step + * + * @param{AppliedDrawStep} step The step, how data should be drawn. + */ + private _drawStep(step); + private _appliedProjectors(attrToProjector); /** * Calculates the total time it takes to use the input drawSteps to draw the input data * @@ -1381,10 +1481,31 @@ declare module Plottable { } } class Component { + private _element; + private _content; protected _boundingBox: d3.Selection; + private _backgroundContainer; + private _foregroundContainer; protected _clipPathEnabled: boolean; + private _origin; + private _parent; + private _xAlignment; + private static _xAlignToProportion; + private _yAlignment; + private static _yAlignToProportion; protected _isSetup: boolean; protected _isAnchored: boolean; + private _boxes; + private _boxContainer; + private _rootSVG; + private _isTopLevelComponent; + private _width; + private _height; + private _cssClasses; + private _destroyed; + private _clipPathID; + private _onAnchorCallbacks; + private _onDetachCallbacks; constructor(); /** * Attaches the Component as a child of a given d3 Selection. @@ -1444,6 +1565,7 @@ declare module Plottable { * @returns {Component} The calling Component. */ render(): Component; + private _scheduleComputeLayout(); /** * Renders the Component without waiting for the next frame. */ @@ -1486,6 +1608,9 @@ declare module Plottable { * @returns {Component} The calling Component. */ yAlignment(yAlignment: string): Component; + private _addBox(className?, parentElement?); + private _generateClipPath(); + private _updateClipPath(); /** * Checks if the Component has a given CSS class. * @@ -1604,6 +1729,7 @@ declare module Plottable { declare module Plottable { class ComponentContainer extends Component { + private _detachCallback; constructor(); anchor(selection: d3.Selection): ComponentContainer; render(): ComponentContainer; @@ -1638,6 +1764,7 @@ declare module Plottable { declare module Plottable { module Components { class Group extends ComponentContainer { + private _components; /** * Constructs a Group. * @@ -1706,12 +1833,28 @@ declare module Plottable { * The css class applied to each annotation label, which shows the formatted annotation text. */ static ANNOTATION_LABEL_CLASS: string; + private static _ANNOTATION_LABEL_PADDING; protected _tickMarkContainer: d3.Selection; protected _tickLabelContainer: d3.Selection; protected _baseline: d3.Selection; protected _scale: Scale; + private _formatter; + private _orientation; protected _computedWidth: number; protected _computedHeight: number; + private _endTickLength; + private _innerTickLength; + private _tickLabelPadding; + private _margin; + private _showEndTickLabels; + private _rescaleCallback; + private _annotatedTicks; + private _annotationFormatter; + private _annotationsEnabled; + private _annotationTierCount; + private _annotationContainer; + private _annotationMeasurer; + private _annotationWriter; /** * Constructs an Axis. * An Axis is a visual representation of a Scale. @@ -1774,6 +1917,7 @@ declare module Plottable { */ annotationTierCount(annotationTierCount: number): Axis; protected _drawAnnotations(): void; + private _annotatedTicksToRender(); /** * Retrieves the size of the core pieces. * @@ -1781,6 +1925,7 @@ declare module Plottable { */ protected _coreSize(): number; protected _annotationTierHeight(): number; + private _annotationToTier(measurements); protected _removeAnnotations(): void; protected _generateBaselineAttrHash(): { [key: string]: number; @@ -1788,7 +1933,6 @@ declare module Plottable { protected _generateTickMarkAttrHash(isEndTickMark?: boolean): { [key: string]: number | ((d: any) => number); }; - redraw(): Component; protected _setDefaultAlignment(): void; /** * Gets the Formatter on the Axis. Tick values are passed through the @@ -1925,6 +2069,17 @@ declare module Plottable { * The CSS class applied to each Time Axis tier */ static TIME_AXIS_TIER_CLASS: string; + private static _DEFAULT_TIME_AXIS_CONFIGURATIONS; + private _tierLabelContainers; + private _tierMarkContainers; + private _tierBaselines; + private _tierHeights; + private _possibleTimeAxisConfigurations; + private _numTiers; + private _measurer; + private _mostPreciseConfigIndex; + private _tierLabelPositions; + private static _LONG_DATE; /** * Constructs a Time Axis. * @@ -1958,16 +2113,36 @@ declare module Plottable { * @returns {Axes.Time} The calling Time Axis. */ axisConfigurations(configurations: TimeAxisConfiguration[]): Time; + /** + * Gets the index of the most precise TimeAxisConfiguration that will fit in the current width. + */ + private _getMostPreciseConfigurationIndex(); orientation(): string; orientation(orientation: string): Time; protected _computeHeight(): number; + private _getIntervalLength(config); + private _maxWidthForInterval(config); + /** + * Check if tier configuration fits in the current width. + */ + private _checkTimeAxisTierConfigurationWidth(config); protected _sizeFromOffer(availableWidth: number, availableHeight: number): { width: number; height: number; }; protected _setup(): void; + private _setupDomElements(); + private _getTickIntervalValues(config); protected _getTickValues(): any[]; + private _cleanTiers(); + private _getTickValuesForConfiguration(config); + private _renderTierLabels(container, config, index); + private _renderTickMarks(tickValues, index); + private _renderLabellessTickMarks(tickValues); + private _generateLabellessTicks(); renderImmediately(): Time; + private _hideOverflowingTiers(); + private _hideOverlappingAndCutOffLabels(index); } } } @@ -1976,6 +2151,10 @@ declare module Plottable { declare module Plottable { module Axes { class Numeric extends Axis { + private _tickLabelPositioning; + private _usesTextWidthApproximation; + private _measurer; + private _wrapper; /** * Constructs a Numeric Axis. * @@ -1988,10 +2167,17 @@ declare module Plottable { constructor(scale: QuantitativeScale, orientation: string); protected _setup(): void; protected _computeWidth(): number; + private _computeExactTextWidth(); + private _computeApproximateTextWidth(); protected _computeHeight(): number; protected _getTickValues(): number[]; protected _rescale(): void; renderImmediately(): Numeric; + private _showAllTickMarks(); + /** + * Hides the Tick Marks which have no corresponding Tick Labels + */ + private _hideTickMarksWithoutLabel(); /** * Gets the tick label position relative to the tick marks. * @@ -2022,6 +2208,20 @@ declare module Plottable { * @returns {Axes.Numeric} The calling Axes.Numeric. */ usesTextWidthApproximation(enable: boolean): Axes.Numeric; + private _hideEndTickLabels(); + private _hideOverflowingTickLabels(); + private _hideOverlappingTickLabels(); + /** + * The method is responsible for evenly spacing the labels on the axis. + * @return test to see if taking every `interval` recrangle from `rects` + * will result in labels not overlapping + * + * For top, bottom, left, right positioning of the thicks, we want the padding + * between the labels to be 3x, such that the label will be `padding` distance + * from the tick and 2 * `padding` distance (or more) from the next tick + * + */ + private _hasOverlapWithInterval(interval, rects); } } } @@ -2030,6 +2230,10 @@ declare module Plottable { declare module Plottable { module Axes { class Category extends Axis { + private _tickLabelAngle; + private _measurer; + private _wrapper; + private _writer; /** * Constructs a Category Axis. * @@ -2057,6 +2261,18 @@ declare module Plottable { * @returns {Category} The calling Category Axis. */ tickLabelAngle(angle: number): Category; + /** + * Measures the size of the ticks while also writing them to the DOM. + * @param {d3.Selection} ticks The tick elements to be written to. + */ + private _drawTicks(axisWidth, axisHeight, scale, ticks); + /** + * Measures the size of the ticks without making any (permanent) DOM + * changes. + * + * @param {string[]} ticks The strings that will be printed on the ticks. + */ + private _measureTicks(axisWidth, axisHeight, scale, ticks); renderImmediately(): Category; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; } @@ -2067,6 +2283,13 @@ declare module Plottable { declare module Plottable { module Components { class Label extends Component { + private _textContainer; + private _text; + private _angle; + private _measurer; + private _wrapper; + private _writer; + private _padding; /** * A Label is a Component that displays a single line of text. * @@ -2151,6 +2374,17 @@ declare module Plottable { * The css class applied to each legend symbol */ static LEGEND_SYMBOL_CLASS: string; + private _padding; + private _colorScale; + private _formatter; + private _maxEntriesPerRow; + private _comparator; + private _measurer; + private _wrapper; + private _writer; + private _symbolFactoryAccessor; + private _symbolOpacityAccessor; + private _redrawCallback; /** * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. * @@ -2211,7 +2445,9 @@ declare module Plottable { */ colorScale(colorScale: Scales.Color): Legend; destroy(): void; + private _calculateLayoutInfo(availableWidth, availableHeight); requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + private _packRows(availableWidth, entries, entryLengths); /** * Gets the Entities (representing Legend entries) at a particular point. * Returns an empty array if no Entities are present at that location. @@ -2257,6 +2493,20 @@ declare module Plottable { declare module Plottable { module Components { class InterpolatedColorLegend extends Component { + private static _DEFAULT_NUM_SWATCHES; + private _measurer; + private _wrapper; + private _writer; + private _scale; + private _orientation; + private _padding; + private _formatter; + private _expands; + private _swatchContainer; + private _swatchBoundingBox; + private _lowerLabel; + private _upperLabel; + private _redrawCallback; /** * The css class applied to the legend labels. */ @@ -2295,6 +2545,7 @@ declare module Plottable { * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. */ expands(expands: boolean): InterpolatedColorLegend; + private static _ensureOrientation(orientation); /** * Gets the orientation. */ @@ -2308,8 +2559,10 @@ declare module Plottable { orientation(orientation: string): InterpolatedColorLegend; fixedWidth(): boolean; fixedHeight(): boolean; + private _generateTicks(numSwatches?); protected _setup(): void; requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; + private _isVertical(); renderImmediately(): InterpolatedColorLegend; } } @@ -2319,6 +2572,11 @@ declare module Plottable { declare module Plottable { module Components { class Gridlines extends Component { + private _xScale; + private _yScale; + private _xLinesContainer; + private _yLinesContainer; + private _renderCallback; /** * @constructor * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. @@ -2329,6 +2587,8 @@ declare module Plottable { protected _setup(): void; renderImmediately(): Gridlines; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Gridlines; + private _redrawXLines(); + private _redrawYLines(); } } } @@ -2337,6 +2597,14 @@ declare module Plottable { declare module Plottable { module Components { class Table extends ComponentContainer { + private _rowPadding; + private _columnPadding; + private _rows; + private _rowWeights; + private _columnWeights; + private _nRows; + private _nCols; + private _calculatedLayout; /** * A Table combines Components in the form of a grid. A * common case is combining a y-axis, x-axis, and the plotted data via @@ -2372,6 +2640,8 @@ declare module Plottable { */ add(component: Component, row: number, col: number): Table; protected _remove(component: Component): boolean; + private _iterateLayout(availableWidth, availableHeight, isFinalOffer?); + private _determineGuarantees(offeredWidths, offeredHeights, isFinalOffer?); requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; /** @@ -2447,6 +2717,10 @@ declare module Plottable { columnWeight(index: number, weight: number): Table; fixedWidth(): boolean; fixedHeight(): boolean; + private _padTableToSize(nRows, nCols); + private static _calcComponentWeights(setWeights, componentGroups, fixityAccessor); + private static _calcProportionalSpace(weights, freeSpace); + private static _fixedSpace(componentGroup, fixityAccessor); } } } @@ -2460,6 +2734,14 @@ declare module Plottable { } class SelectionBoxLayer extends Component { protected _box: d3.Selection; + private _boxArea; + private _boxVisible; + private _boxBounds; + private _xExtent; + private _yExtent; + private _xScale; + private _yScale; + private _adjustBoundsCallback; protected _xBoundsMode: PropertyMode; protected _yBoundsMode: PropertyMode; constructor(); @@ -2480,6 +2762,7 @@ declare module Plottable { */ bounds(newBounds: Bounds): SelectionBoxLayer; protected _setBounds(newBounds: Bounds): void; + private _getBounds(); renderImmediately(): SelectionBoxLayer; /** * Gets whether the box is being shown. @@ -2536,6 +2819,7 @@ declare module Plottable { xExtent(xExtent: (number | { valueOf(): number; })[]): SelectionBoxLayer; + private _getXExtent(); protected _setXExtent(xExtent: (number | { valueOf(): number; })[]): void; @@ -2553,6 +2837,7 @@ declare module Plottable { yExtent(yExtent: (number | { valueOf(): number; })[]): SelectionBoxLayer; + private _getYExtent(); protected _setYExtent(yExtent: (number | { valueOf(): number; })[]): void; @@ -2567,6 +2852,13 @@ declare module Plottable { class GuideLineLayer extends Component { static ORIENTATION_VERTICAL: string; static ORIENTATION_HORIZONTAL: string; + private _orientation; + private _value; + private _scale; + private _pixelPosition; + private _scaleUpdateCallback; + private _guideLine; + private _mode; constructor(orientation: string); protected _setup(): void; protected _sizeFromOffer(availableWidth: number, availableHeight: number): { @@ -2578,6 +2870,7 @@ declare module Plottable { fixedHeight(): boolean; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): GuideLineLayer; renderImmediately(): GuideLineLayer; + private _syncPixelPositionAndValue(); protected _setPixelPositionWithoutChangingMode(pixelPosition: number): void; /** * Gets the QuantitativeScale on the GuideLineLayer. @@ -2646,8 +2939,16 @@ declare module Plottable { } class Plot extends Component { protected static _ANIMATION_MAX_DURATION: number; + private _dataChanged; + private _datasetToDrawer; protected _renderArea: d3.Selection; + private _attrBindings; + private _attrExtents; + private _includedValuesProvider; + private _animate; + private _animators; protected _renderCallback: ScaleCallback>; + private _onDatasetUpdateCallback; protected _propertyExtents: d3.Map; protected _propertyBindings: d3.Map>; /** @@ -2688,6 +2989,7 @@ declare module Plottable { */ attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; protected _bindProperty(property: string, value: any, scale: Scale): void; + private _bindAttr(attr, value, scale); protected _generateAttrToProjector(): AttributeToProjector; renderImmediately(): Plot; /** @@ -2699,16 +3001,24 @@ declare module Plottable { */ animated(willAnimate: boolean): Plot; detach(): Plot; + /** + * @returns {Scale[]} A unique array of all scales currently used by the Plot. + */ + private _scales(); /** * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. */ protected _updateExtents(): void; + private _updateExtentsForAttr(attr); protected _updateExtentsForProperty(property: string): void; protected _filterForProperty(property: string): Accessor; + private _updateExtentsForKey(key, bindings, extents, filter); + private _computeExtent(dataset, accScaleBinding, filter); /** * Override in subclass to add special extents, such as included values */ protected _extentsForProperty(property: string): any[]; + private _includedValuesForScale(scale); /** * Get the Animator associated with the specified Animator key. * @@ -2746,6 +3056,7 @@ declare module Plottable { protected _generateDrawSteps(): Drawers.DrawStep[]; protected _additionalPaint(time: number): void; protected _getDataToDraw(): Utils.Map; + private _paint(); /** * Retrieves Selections of this Plot for the specified Datasets. * @@ -2762,6 +3073,8 @@ declare module Plottable { * @return {Plots.PlotEntity[]} */ entities(datasets?: Dataset[]): Plots.PlotEntity[]; + private _lightweightEntities(datasets?); + private _lightweightPlotEntityToPlotEntity(entity); /** * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. * @@ -2787,6 +3100,14 @@ declare module Plottable { declare module Plottable { module Plots { class Pie extends Plot { + private static _INNER_RADIUS_KEY; + private static _OUTER_RADIUS_KEY; + private static _SECTOR_VALUE_KEY; + private _startAngles; + private _endAngles; + private _labelFormatter; + private _labelsEnabled; + private _strokeDrawers; /** * @constructor */ @@ -2888,6 +3209,7 @@ declare module Plottable { labelFormatter(formatter: Formatter): Pie; entitiesAt(queryPoint: Point): PlotEntity[]; protected _propertyProjectors(): AttributeToProjector; + private _updatePieAngles(); protected _getDataToDraw(): Utils.Map; protected static _isValidData(value: any): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): { @@ -2895,6 +3217,9 @@ declare module Plottable { y: number; }; protected _additionalPaint(time: number): void; + private _generateStrokeDrawSteps(); + private _sliceIndexForPoint(p); + private _drawLabels(); } } } @@ -2904,6 +3229,13 @@ declare module Plottable { class XYPlot extends Plot { protected static _X_KEY: string; protected static _Y_KEY: string; + private _autoAdjustXScaleDomain; + private _autoAdjustYScaleDomain; + private _adjustYDomainOnChangeFromXCallback; + private _adjustXDomainOnChangeFromYCallback; + private _deferredRendering; + private _cachedDomainX; + private _cachedDomainY; /** * An XYPlot is a Plot that displays data along two primary directions, X and Y. * @@ -2968,6 +3300,7 @@ declare module Plottable { */ y(y: Y | Accessor, yScale: Scale): XYPlot; protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; + private _makeFilterByProperty(property); protected _uninstallScaleForKey(scale: Scale, key: string): void; protected _installScaleForKey(scale: Scale, key: string): void; destroy(): XYPlot; @@ -2987,6 +3320,8 @@ declare module Plottable { */ autorangeMode(autorangeMode: string): XYPlot; computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; + private _updateXExtentsAndAutodomain(); + private _updateYExtentsAndAutodomain(); /** * Adjusts the domains of both X and Y scales to show all data. * This call does not override the autorange() behavior. @@ -2994,6 +3329,8 @@ declare module Plottable { * @returns {XYPlot} The calling XYPlot. */ showAllData(): XYPlot; + private _adjustYDomainOnChangeFromX(); + private _adjustXDomainOnChangeFromY(); protected _projectorsReady(): boolean; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _getDataToDraw(): Utils.Map; @@ -3004,6 +3341,10 @@ declare module Plottable { declare module Plottable { module Plots { class Rectangle extends XYPlot { + private static _X2_KEY; + private static _Y2_KEY; + private _labelsEnabled; + private _label; /** * A Rectangle Plot displays rectangles based on the data. * The left and right edges of each rectangle can be set with x() and x2(). @@ -3109,6 +3450,8 @@ declare module Plottable { * @returns {PlotEntity[]} */ entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + private _entityBBox(datum, index, dataset, attrToProjector); + private _entitiesIntersecting(xValOrRange, yValOrRange); /** * Gets the accessor for labels. * @@ -3141,8 +3484,12 @@ declare module Plottable { x: any; y: any; }; + private _rectangleWidth(scale); protected _getDataToDraw(): Utils.Map; protected _additionalPaint(time: number): void; + private _drawLabels(); + private _drawLabel(dataToDraw, dataset, datasetIndex); + private _overlayLabel(labelXRange, labelYRange, datumIndex, datasetIndex, dataToDraw); } } } @@ -3151,6 +3498,8 @@ declare module Plottable { declare module Plottable { module Plots { class Scatter extends XYPlot { + private static _SIZE_KEY; + private static _SYMBOL_KEY; /** * A Scatter Plot draws a symbol at each data point. * @@ -3230,7 +3579,22 @@ declare module Plottable { class Bar extends XYPlot { static ORIENTATION_VERTICAL: string; static ORIENTATION_HORIZONTAL: string; + private static _BAR_WIDTH_RATIO; + private static _SINGLE_BAR_DIMENSION_RATIO; + private static _BAR_AREA_CLASS; + private static _LABEL_AREA_CLASS; + private static _LABEL_VERTICAL_PADDING; + private static _LABEL_HORIZONTAL_PADDING; + private _baseline; + private _baselineValue; protected _isVertical: boolean; + private _labelFormatter; + private _labelsEnabled; + private _hideBarsIfAnyAreTooWide; + private _labelConfig; + private _baselineValueProvider; + private _barPixelWidth; + private _updateBarPixelWidthCallback; /** * A Bar Plot draws bars growing out from a baseline to some value * @@ -3338,11 +3702,15 @@ declare module Plottable { * @returns {PlotEntity[]} */ entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + private _entitiesIntersecting(xValOrRange, yValOrRange); + private _updateValueScale(); protected _additionalPaint(time: number): void; /** * Makes sure the extent takes into account the widths of the bars */ protected _extentsForProperty(property: string): any[]; + private _drawLabels(); + private _drawLabel(data, dataset); protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; @@ -3355,6 +3723,7 @@ declare module Plottable { * two adjacent data points, padded for visualisation. */ protected _getBarPixelWidth(): number; + private _updateBarPixelWidth(); entities(datasets?: Dataset[]): PlotEntity[]; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; protected _uninstallScaleForKey(scale: Scale, key: string): void; @@ -3367,6 +3736,10 @@ declare module Plottable { declare module Plottable { module Plots { class Line extends XYPlot { + private _interpolator; + private _autorangeSmooth; + private _croppedRenderingEnabled; + private _downsamplingEnabled; /** * A Line Plot draws line segments starting from the first data point to the next. * @@ -3392,6 +3765,7 @@ declare module Plottable { * and deactivating the nice domain feature on the scales */ autorangeSmooth(autorangeSmooth: boolean): Plots.Line; + private _setScaleSnapping(); /** * Gets the interpolation function associated with the plot. * @@ -3418,6 +3792,18 @@ declare module Plottable { interpolator(interpolator: "cardinal-open"): Line; interpolator(interpolator: "cardinal-closed"): Line; interpolator(interpolator: "monotone"): Line; + /** + * Gets if downsampling is enabled + * + * When downsampling is enabled, two consecutive lines with the same slope will be merged to one line. + */ + downsamplingEnabled(): boolean; + /** + * Sets if downsampling is enabled + * + * @returns {Plots.Line} The calling Plots.Line + */ + downsamplingEnabled(downsampling: boolean): Plots.Line; /** * Gets if croppedRendering is enabled * @@ -3432,6 +3818,7 @@ declare module Plottable { croppedRenderingEnabled(croppedRendering: boolean): Plots.Line; protected _createDrawer(dataset: Dataset): Drawer; protected _extentsForProperty(property: string): any[]; + private _getEdgeIntersectionPoints(); protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _generateAttrToProjector(): { @@ -3447,6 +3834,8 @@ declare module Plottable { protected _propertyProjectors(): AttributeToProjector; protected _constructLineProjector(xProjector: Projector, yProjector: Projector): (datum: any, index: number, dataset: Dataset) => string; protected _getDataToDraw(): Utils.Map; + private _filterCroppedRendering(dataset, indices); + private _filterDownsampling(dataset, indices); } } } @@ -3455,6 +3844,9 @@ declare module Plottable { declare module Plottable { module Plots { class Area extends Line { + private static _Y0_KEY; + private _lineDrawers; + private _constantBaselineValueProvider; /** * An Area Plot draws a filled region (area) between Y and Y0. * @@ -3482,6 +3874,8 @@ declare module Plottable { protected _addDataset(dataset: Dataset): Area; protected _removeDatasetNodes(dataset: Dataset): void; protected _additionalPaint(): void; + private _generateLineDrawSteps(); + private _generateLineAttrToProjector(); protected _createDrawer(dataset: Dataset): Drawers.Area; protected _generateDrawSteps(): Drawers.DrawStep[]; protected _updateYScale(): void; @@ -3497,6 +3891,7 @@ declare module Plottable { declare module Plottable { module Plots { class ClusteredBar extends Bar { + private _clusterOffsets; /** * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. @@ -3509,6 +3904,8 @@ declare module Plottable { protected _generateAttrToProjector(): { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; }; + private _updateClusterPosition(); + private _makeInnerScale(); protected _getDataToDraw(): Utils.Map; } } @@ -3518,6 +3915,11 @@ declare module Plottable { declare module Plottable { module Plots { class StackedArea extends Area { + private _stackingResult; + private _stackedExtent; + private _baseline; + private _baselineValue; + private _baselineValueProvider; /** * @constructor */ @@ -3530,11 +3932,36 @@ declare module Plottable { y(): Plots.AccessorScaleBinding; y(y: number | Accessor): StackedArea; y(y: number | Accessor, yScale: QuantitativeScale): StackedArea; + /** + * Gets if downsampling is enabled + * + * When downsampling is enabled, two consecutive lines with the same slope will be merged to one line. + */ + downsamplingEnabled(): boolean; + /** + * Sets if downsampling is enabled + * + * For now, downsampling is always disabled in stacked area plot + * @returns {Plots.StackedArea} The calling Plots.StackedArea + */ + downsamplingEnabled(downsampling: boolean): Plots.Line; protected _additionalPaint(): void; protected _updateYScale(): void; protected _onDatasetUpdate(): StackedArea; protected _updateExtentsForProperty(property: string): void; protected _extentsForProperty(attr: string): any[]; + private _updateStackExtentsAndOffsets(); + private _checkSameDomain(datasets, keyAccessor); + /** + * Given an array of Datasets and the accessor function for the key, computes the + * set reunion (no duplicates) of the domain of each Dataset. The keys are stringified + * before being returned. + * + * @param {Dataset[]} datasets The Datasets for which we extract the domain keys + * @param {Accessor} keyAccessor The accessor for the key of the data + * @return {string[]} An array of stringified keys + */ + private static _domainKeys(datasets, keyAccessor); protected _propertyProjectors(): AttributeToProjector; protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; } @@ -3545,6 +3972,8 @@ declare module Plottable { declare module Plottable { module Plots { class StackedBar extends Bar { + private _stackingResult; + private _stackedExtent; /** * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. * On a vertical StackedBar Plot, the bars with the same X value are stacked. @@ -3568,6 +3997,7 @@ declare module Plottable { protected _onDatasetUpdate(): StackedBar; protected _updateExtentsForProperty(property: string): void; protected _extentsForProperty(attr: string): any[]; + private _updateStackExtentsAndOffsets(); } } } @@ -3576,6 +4006,8 @@ declare module Plottable { declare module Plottable { module Plots { class Segment extends XYPlot { + private static _X2_KEY; + private static _Y2_KEY; /** * A Segment Plot displays line segments based on the data. * @@ -3666,6 +4098,9 @@ declare module Plottable { * @returns {PlotEntity[]} */ entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; + private _entitiesIntersecting(xRange, yRange); + private _lineIntersectsBox(entity, xRange, yRange, attrToProjector); + private _lineIntersectsSegment(point1, point2, point3, point4); } } } @@ -3674,6 +4109,16 @@ declare module Plottable { declare module Plottable { module Plots { class Waterfall extends Bar { + private static _BAR_DECLINE_CLASS; + private static _BAR_GROWTH_CLASS; + private static _BAR_TOTAL_CLASS; + private static _CONNECTOR_CLASS; + private static _CONNECTOR_AREA_CLASS; + private static _TOTAL_KEY; + private _connectorArea; + private _connectorsEnabled; + private _extent; + private _subtotals; constructor(); /** * Gets whether connectors are enabled. @@ -3706,6 +4151,9 @@ declare module Plottable { [attr: string]: (datum: any, index: number, dataset: Dataset) => any; }; protected _onDatasetUpdate(): Waterfall; + private _calculateSubtotalsAndExtent(dataset); + private _drawConnectors(); + private _updateSubtotals(); } } } @@ -3714,6 +4162,10 @@ declare module Plottable { declare module Plottable { module Plots { class Wheel extends Plot { + private static _R_KEY; + private static _R2_KEY; + private static _T_KEY; + private static _T2_KEY; /** * @constructor */ @@ -3842,6 +4294,31 @@ declare module Plottable { * An Animator with easing and configurable durations and delays. */ class Easing implements Animator { + /** + * The default starting delay of the animation in milliseconds + */ + private static _DEFAULT_START_DELAY_MILLISECONDS; + /** + * The default duration of one animation step in milliseconds + */ + private static _DEFAULT_STEP_DURATION_MILLISECONDS; + /** + * The default maximum start delay between each step of an animation + */ + private static _DEFAULT_ITERATIVE_DELAY_MILLISECONDS; + /** + * The default maximum total animation duration + */ + private static _DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS; + /** + * The default easing of the animation + */ + private static _DEFAULT_EASING_MODE; + private _startDelay; + private _stepDuration; + private _stepDelay; + private _maxTotalDuration; + private _easingMode; /** * Constructs the default animator * @@ -3923,6 +4400,10 @@ declare module Plottable { * @returns {Easing} The calling Easing Animator. */ easingMode(easingMode: string): Easing; + /** + * Adjust the iterative delay, such that it takes into account the maxTotalDuration constraint + */ + private _getAdjustedIterativeDelay(numberOfSteps); } } } @@ -3934,6 +4415,10 @@ declare module Plottable { [eventName: string]: (e: Event) => any; }; protected _callbacks: Utils.CallbackSet[]; + private _connected; + private _hasNoListeners(); + private _connect(); + private _disconnect(); protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; } @@ -3944,6 +4429,14 @@ declare module Plottable { module Dispatchers { type MouseCallback = (p: Point, event: MouseEvent) => void; class Mouse extends Dispatcher { + private static _DISPATCHER_KEY; + private _translator; + private _lastMousePosition; + private _moveCallbacks; + private _downCallbacks; + private _upCallbacks; + private _wheelCallbacks; + private _dblClickCallbacks; /** * Get a Mouse Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4029,6 +4522,11 @@ declare module Plottable { * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. */ offDblClick(callback: MouseCallback): Dispatchers.Mouse; + /** + * Computes the mouse position from the given event, and if successful + * calls all the callbacks in the provided callbackSet. + */ + private _measureAndDispatch(event, callbackSet, scope?); eventInsideSVG(event: MouseEvent): boolean; /** * Returns the last computed mouse position in coordinate space. @@ -4047,6 +4545,12 @@ declare module Plottable { [id: number]: Point; }, event: TouchEvent) => void; class Touch extends Dispatcher { + private static _DISPATCHER_KEY; + private _translator; + private _startCallbacks; + private _moveCallbacks; + private _endCallbacks; + private _cancelCallbacks; /** * Gets a Touch Dispatcher for the containing elem. * If one already exists on that , it will be returned; otherwise, a new one will be created. @@ -4118,6 +4622,11 @@ declare module Plottable { * @return {Dispatchers.Touch} The calling Touch Dispatcher. */ offTouchCancel(callback: TouchCallback): Dispatchers.Touch; + /** + * Computes the Touch position from the given event, and if successful + * calls all the callbacks in the provided callbackSet. + */ + private _measureAndDispatch(event, callbackSet, scope?); eventInsideSVG(event: TouchEvent): boolean; } } @@ -4128,6 +4637,9 @@ declare module Plottable { module Dispatchers { type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; class Key extends Dispatcher { + private static _DISPATCHER_KEY; + private _keydownCallbacks; + private _keyupCallbacks; /** * Gets a Key Dispatcher. If one already exists it will be returned; * otherwise, a new one will be created. @@ -4168,6 +4680,8 @@ declare module Plottable { * @return {Dispatchers.Key} The calling Key Dispatcher. */ offKeyUp(callback: KeyCallback): Key; + private _processKeydown(event); + private _processKeyup(event); } } } @@ -4176,6 +4690,9 @@ declare module Plottable { declare module Plottable { class Interaction { protected _componentAttachedTo: Component; + private _anchorCallback; + private _isAnchored; + private _enabled; protected _anchor(component: Component): void; protected _unanchor(): void; /** @@ -4186,6 +4703,7 @@ declare module Plottable { * @returns {Interaction} The calling Interaction. */ attachTo(component: Component): Interaction; + private _connect(); /** * Detaches this Interaction from the Component. * This Interaction can be reused. @@ -4194,6 +4712,7 @@ declare module Plottable { * @returns {Interaction} The calling Interaction. */ detachFrom(component: Component): Interaction; + private _disconnect(); /** * Gets whether this Interaction is enabled. */ @@ -4227,8 +4746,19 @@ declare module Plottable { type ClickCallback = (point: Point) => void; module Interactions { class Click extends Interaction { + private _mouseDispatcher; + private _touchDispatcher; + private _clickedDown; + private _onClickCallbacks; + private _mouseDownCallback; + private _mouseUpCallback; + private _touchStartCallback; + private _touchEndCallback; + private _touchCancelCallback; protected _anchor(component: Component): void; protected _unanchor(): void; + private _handleClickDown(p); + private _handleClickUp(p); /** * Adds a callback to be called when the Component is clicked. * @@ -4251,8 +4781,25 @@ declare module Plottable { declare module Plottable { module Interactions { class DoubleClick extends Interaction { + private _mouseDispatcher; + private _touchDispatcher; + private _clickState; + private _clickedDown; + private _clickedPoint; + private _onDoubleClickCallbacks; + private _mouseDownCallback; + private _mouseUpCallback; + private _dblClickCallback; + private _touchStartCallback; + private _touchEndCallback; + private _touchCancelCallback; protected _anchor(component: Component): void; protected _unanchor(): void; + private _handleClickDown(p); + private _handleClickUp(p); + private _handleDblClick(); + private _handleClickCancel(); + private static _pointsEqual(p1, p2); /** * Adds a callback to be called when the Component is double-clicked. * @@ -4276,8 +4823,22 @@ declare module Plottable { type KeyCallback = (keyCode: number) => void; module Interactions { class Key extends Interaction { + /** + * A Key Interaction listens to key events that occur while the Component is + * moused over. + */ + private _positionDispatcher; + private _keyDispatcher; + private _keyPressCallbacks; + private _keyReleaseCallbacks; + private _mouseMoveCallback; + private _downedKeys; + private _keyDownCallback; + private _keyUpCallback; protected _anchor(component: Component): void; protected _unanchor(): void; + private _handleKeyDownEvent(keyCode, event); + private _handleKeyUpEvent(keyCode); /** * Adds a callback to be called when the key with the given keyCode is * pressed and the user is moused over the Component. @@ -4323,8 +4884,19 @@ declare module Plottable { type PointerCallback = (point: Point) => void; module Interactions { class Pointer extends Interaction { + private _mouseDispatcher; + private _touchDispatcher; + private _insideComponent; + private _pointerEnterCallbacks; + private _pointerMoveCallbacks; + private _pointerExitCallbacks; + private _mouseMoveCallback; + private _touchStartCallback; protected _anchor(component: Component): void; protected _unanchor(): void; + private _handleMouseEvent(p, e); + private _handleTouchEvent(p, e); + private _handlePointerEvent(p, insideSVG); /** * Adds a callback to be called when the pointer enters the Component. * @@ -4375,6 +4947,23 @@ declare module Plottable { declare module Plottable { module Interactions { class PanZoom extends Interaction { + /** + * The number of pixels occupied in a line. + */ + private static _PIXELS_PER_LINE; + private _xScales; + private _yScales; + private _dragInteraction; + private _mouseDispatcher; + private _touchDispatcher; + private _touchIds; + private _wheelCallback; + private _touchStartCallback; + private _touchMoveCallback; + private _touchEndCallback; + private _touchCancelCallback; + private _minDomainExtents; + private _maxDomainExtents; /** * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale * in response to the user panning or zooming. @@ -4386,6 +4975,17 @@ declare module Plottable { constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); protected _anchor(component: Component): void; protected _unanchor(): void; + private _handleTouchStart(ids, idToPoint, e); + private _handlePinch(ids, idToPoint, e); + private static _centerPoint(point1, point2); + private static _pointDistance(point1, point2); + private _handleTouchEnd(ids, idToPoint, e); + private _magnifyScale(scale, magnifyAmount, centerValue); + private _translateScale(scale, translateAmount); + private _handleWheelEvent(p, e); + private _constrainedZoomAmount(scale, zoomAmount); + private _setupDragInteraction(); + private _nonLinearScaleWithExtents(scale); /** * Gets the x scales for this PanZoom Interaction. */ @@ -4485,8 +5085,26 @@ declare module Plottable { type DragCallback = (start: Point, end: Point) => void; module Interactions { class Drag extends Interaction { + private _dragging; + private _constrainedToComponent; + private _mouseDispatcher; + private _touchDispatcher; + private _dragOrigin; + private _dragStartCallbacks; + private _dragCallbacks; + private _dragEndCallbacks; + private _mouseDownCallback; + private _mouseMoveCallback; + private _mouseUpCallback; + private _touchStartCallback; + private _touchMoveCallback; + private _touchEndCallback; protected _anchor(component: Component): void; protected _unanchor(): void; + private _translateAndConstrain(p); + private _startDrag(point, event); + private _doDrag(point, event); + private _endDrag(point, event); /** * Gets whether the Drag Interaction constrains Points passed to its * callbacks to lie inside its Component. @@ -4561,7 +5179,23 @@ declare module Plottable { type DragBoxCallback = (bounds: Bounds) => void; module Components { class DragBoxLayer extends Components.SelectionBoxLayer { + private _dragInteraction; + private _detectionEdgeT; + private _detectionEdgeB; + private _detectionEdgeL; + private _detectionEdgeR; + private _detectionCornerTL; + private _detectionCornerTR; + private _detectionCornerBL; + private _detectionCornerBR; + private _detectionRadius; + private _resizable; + private _movable; protected _hasCorners: boolean; + private _dragStartCallbacks; + private _dragCallbacks; + private _dragEndCallbacks; + private _disconnectInteraction; /** * Constructs a DragBoxLayer. * @@ -4572,7 +5206,9 @@ declare module Plottable { * @constructor */ constructor(); + private _setUpCallbacks(); protected _setup(): void; + private _getResizingEdges(p); renderImmediately(): DragBoxLayer; /** * Gets the detection radius of the drag box in pixels. @@ -4608,6 +5244,7 @@ declare module Plottable { * @return {DragBoxLayer} The calling DragBoxLayer. */ movable(movable: boolean): DragBoxLayer; + private _setMovableClass(); /** * Sets the callback to be called when dragging starts. * @@ -4665,6 +5302,7 @@ declare module Plottable { destroy(): void; detach(): Component; anchor(selection: d3.Selection): Component; + private _resetState(); } } } @@ -4736,6 +5374,14 @@ declare module Plottable { } module Components { class DragLineLayer extends GuideLineLayer { + private _dragInteraction; + private _detectionRadius; + private _detectionEdge; + private _enabled; + private _dragStartCallbacks; + private _dragCallbacks; + private _dragEndCallbacks; + private _disconnectInteraction; constructor(orientation: string); protected _setup(): void; renderImmediately(): DragLineLayer; diff --git a/plottable.js b/plottable.js index d7fe07bc11..0c3d5c0578 100644 --- a/plottable.js +++ b/plottable.js @@ -1,5 +1,5 @@ /*! -Plottable 1.14.0 (https://github.com/palantir/plottable) +Plottable 1.15.0 (https://github.com/palantir/plottable) Copyright 2014-2015 Palantir Technologies Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE) */ @@ -370,16 +370,16 @@ var Plottable; * @returns {boolean} If the ClientRects overlap each other. */ function clientRectsOverlap(clientRectA, clientRectB) { - if (clientRectA.right < clientRectB.left) { + if (nativeMath.floor(clientRectA.right) <= nativeMath.ceil(clientRectB.left)) { return false; } - if (clientRectA.left > clientRectB.right) { + if (nativeMath.ceil(clientRectA.left) >= nativeMath.floor(clientRectB.right)) { return false; } - if (clientRectA.bottom < clientRectB.top) { + if (nativeMath.floor(clientRectA.bottom) <= nativeMath.ceil(clientRectB.top)) { return false; } - if (clientRectA.top > clientRectB.bottom) { + if (nativeMath.ceil(clientRectA.top) >= nativeMath.floor(clientRectB.bottom)) { return false; } return true; @@ -908,7 +908,7 @@ var Plottable; /// var Plottable; (function (Plottable) { - Plottable.version = "1.14.0"; + Plottable.version = "1.15.0"; })(Plottable || (Plottable = {})); /// @@ -3709,20 +3709,14 @@ var Plottable; var requestedWidth = 0; var requestedHeight = 0; if (this._isHorizontal()) { - if (this._computedHeight == null) { - this._computeHeight(); - } - requestedHeight = this._computedHeight + this._margin; + requestedHeight = this._computeHeight() + this._margin; if (this.annotationsEnabled()) { var tierHeight = this._annotationMeasurer.measure().height + 2 * Axis._ANNOTATION_LABEL_PADDING; requestedHeight += tierHeight * this.annotationTierCount(); } } else { - if (this._computedWidth == null) { - this._computeWidth(); - } - requestedWidth = this._computedWidth + this._margin; + requestedWidth = this._computeWidth() + this._margin; if (this.annotationsEnabled()) { var tierHeight = this._annotationMeasurer.measure().height + 2 * Axis._ANNOTATION_LABEL_PADDING; requestedWidth += tierHeight * this.annotationTierCount(); @@ -3954,7 +3948,7 @@ var Plottable; */ Axis.prototype._coreSize = function () { var relevantDimension = this._isHorizontal() ? this.height() : this.width(); - var axisHeightWithoutMargin = this._isHorizontal() ? this._computedHeight : this._computedWidth; + var axisHeightWithoutMargin = this._isHorizontal() ? this._computeHeight() : this._computeWidth(); return Math.min(axisHeightWithoutMargin, relevantDimension); }; Axis.prototype._annotationTierHeight = function () { @@ -4059,11 +4053,6 @@ var Plottable; } return tickMarkAttrHash; }; - Axis.prototype.redraw = function () { - this._computedWidth = null; - this._computedHeight = null; - return _super.prototype.redraw.call(this); - }; Axis.prototype._setDefaultAlignment = function () { switch (this._orientation) { case "bottom": @@ -4414,9 +4403,18 @@ var Plottable; var tickLabelsEnter = tickLabels.enter().append("g").classed(Plottable.Axis.TICK_LABEL_CLASS, true); tickLabelsEnter.append("text"); var xTranslate = (this._tierLabelPositions[index] === "center" || config.step === 1) ? 0 : this.tickLabelPadding(); - var yTranslate = this.orientation() === "bottom" ? - d3.sum(this._tierHeights.slice(0, index + 1)) - this.tickLabelPadding() : - this.height() - d3.sum(this._tierHeights.slice(0, index)) - this.tickLabelPadding(); + var yTranslate; + if (this.orientation() === "bottom") { + yTranslate = d3.sum(this._tierHeights.slice(0, index + 1)) - this.tickLabelPadding(); + } + else { + if (this._tierLabelPositions[index] === "center") { + yTranslate = this.height() - d3.sum(this._tierHeights.slice(0, index)) - this.tickLabelPadding() - this._maxLabelTickLength(); + } + else { + yTranslate = this.height() - d3.sum(this._tierHeights.slice(0, index)) - this.tickLabelPadding(); + } + } var textSelection = tickLabels.selectAll("text"); if (textSelection.size() > 0) { Plottable.Utils.DOM.translate(textSelection, xTranslate, yTranslate); @@ -5418,7 +5416,10 @@ var Plottable; this._colorScale.onUpdate(this._redrawCallback); this._formatter = Plottable.Formatters.identity(); this.xAlignment("right").yAlignment("top"); - this.comparator(function (a, b) { return 0; }); + this.comparator(function (a, b) { + var formattedText = _this._colorScale.domain().slice().map(function (d) { return _this._formatter(d); }); + return formattedText.indexOf(a) - formattedText.indexOf(b); + }); this._symbolFactoryAccessor = function () { return Plottable.SymbolFactories.circle(); }; this._symbolOpacityAccessor = function () { return 1; }; } @@ -8428,8 +8429,9 @@ var Plottable; return this._isVertical ? Bar.ORIENTATION_VERTICAL : Bar.ORIENTATION_HORIZONTAL; }; Bar.prototype.render = function () { - _super.prototype.render.call(this); this._updateBarPixelWidth(); + this._updateExtents(); + _super.prototype.render.call(this); return this; }; Bar.prototype._createDrawer = function (dataset) { @@ -8993,6 +8995,7 @@ var Plottable; this._interpolator = "linear"; this._autorangeSmooth = false; this._croppedRenderingEnabled = true; + this._downsamplingEnabled = false; this.addClass("line-plot"); var animator = new Plottable.Animators.Easing(); animator.stepDuration(Plottable.Plot._ANIMATION_MAX_DURATION); @@ -9059,6 +9062,13 @@ var Plottable; this.render(); return this; }; + Line.prototype.downsamplingEnabled = function (downsampling) { + if (downsampling == null) { + return this._downsamplingEnabled; + } + this._downsamplingEnabled = downsampling; + return this; + }; Line.prototype.croppedRenderingEnabled = function (croppedRendering) { if (croppedRendering == null) { return this._croppedRenderingEnabled; @@ -9256,12 +9266,17 @@ var Plottable; var dataToDraw = new Plottable.Utils.Map(); this.datasets().forEach(function (dataset) { var data = dataset.data(); - if (!_this._croppedRenderingEnabled) { + if (!_this._croppedRenderingEnabled && !_this._downsamplingEnabled) { dataToDraw.set(dataset, [data]); return; } var filteredDataIndices = data.map(function (d, i) { return i; }); - filteredDataIndices = _this._filterCroppedRendering(dataset, filteredDataIndices); + if (_this._croppedRenderingEnabled) { + filteredDataIndices = _this._filterCroppedRendering(dataset, filteredDataIndices); + } + if (_this._downsamplingEnabled) { + filteredDataIndices = _this._filterDownsampling(dataset, filteredDataIndices); + } dataToDraw.set(dataset, [filteredDataIndices.map(function (d, i) { return data[d]; })]); }); return dataToDraw; @@ -9296,6 +9311,66 @@ var Plottable; } return filteredDataIndices; }; + Line.prototype._filterDownsampling = function (dataset, indices) { + if (indices.length === 0) { + return []; + } + var data = dataset.data(); + var scaledXAccessor = Plottable.Plot._scaledAccessor(this.x()); + var scaledYAccessor = Plottable.Plot._scaledAccessor(this.y()); + var filteredIndices = [indices[0]]; + var indexOnCurrentSlope = function (i, currentSlope) { + var p1x = scaledXAccessor(data[indices[i]], indices[i], dataset); + var p1y = scaledYAccessor(data[indices[i]], indices[i], dataset); + var p2x = scaledXAccessor(data[indices[i + 1]], indices[i + 1], dataset); + var p2y = scaledYAccessor(data[indices[i + 1]], indices[i + 1], dataset); + if (currentSlope === Infinity) { + return Math.floor(p1x) === Math.floor(p2x); + } + else { + var expectedP2y = p1y + (p2x - p1x) * currentSlope; + return Math.floor(p2y) === Math.floor(expectedP2y); + } + }; + for (var i = 0; i < indices.length - 1;) { + var indexFirst = indices[i]; + var p1x = scaledXAccessor(data[indices[i]], indices[i], dataset); + var p1y = scaledYAccessor(data[indices[i]], indices[i], dataset); + var p2x = scaledXAccessor(data[indices[i + 1]], indices[i + 1], dataset); + var p2y = scaledYAccessor(data[indices[i + 1]], indices[i + 1], dataset); + var currentSlope = (Math.floor(p1x) === Math.floor(p2x)) ? Infinity : (p2y - p1y) / (p2x - p1x); + var indexMin = indices[i]; + var minScaledValue = (currentSlope === Infinity) ? p1y : p1x; + var indexMax = indexMin; + var maxScaledValue = minScaledValue; + var firstIndexOnCurrentSlope = true; + while (i < indices.length - 1 && (firstIndexOnCurrentSlope || indexOnCurrentSlope(i, currentSlope))) { + i++; + firstIndexOnCurrentSlope = false; + var currScaledValue = currentSlope === Infinity ? scaledYAccessor(data[indices[i]], indices[i], dataset) : + scaledXAccessor(data[indices[i]], indices[i], dataset); + if (currScaledValue > maxScaledValue) { + maxScaledValue = currScaledValue; + indexMax = indices[i]; + } + if (currScaledValue < minScaledValue) { + minScaledValue = currScaledValue; + indexMin = indices[i]; + } + } + var indexLast = indices[i]; + if (indexMin !== indexFirst) { + filteredIndices.push(indexMin); + } + if (indexMax !== indexMin && indexMax !== indexFirst) { + filteredIndices.push(indexMax); + } + if (indexLast !== indexFirst && indexLast !== indexMin && indexLast !== indexMax) { + filteredIndices.push(indexLast); + } + } + return filteredIndices; + }; return Line; })(Plottable.XYPlot); Plots.Line = Line; @@ -9600,6 +9675,13 @@ var Plottable; this._updateStackExtentsAndOffsets(); return this; }; + StackedArea.prototype.downsamplingEnabled = function (downsampling) { + if (downsampling == null) { + return _super.prototype.downsamplingEnabled.call(this); + } + Plottable.Utils.Window.warn("Warning: Stacked Area Plot does not support downsampling"); + return this; + }; StackedArea.prototype._additionalPaint = function () { var scaledBaseline = this.y().scale.scale(this._baselineValue); var baselineAttr = { diff --git a/plottable.min.js b/plottable.min.js index 6e676a2977..38035fd59a 100644 --- a/plottable.min.js +++ b/plottable.min.js @@ -1,8 +1,8 @@ -!function(a,b){if("object"==typeof exports)module.exports=b(require,exports,module);else if("function"==typeof define&&define.amd)define(["require","exports","module"],b);else{var c=function(b){return a[b]},d=a,e={exports:d};a.Plottable=b(c,d,e)}}(this,function(a,b,c){var d;!function(a){var b;!function(b){var c;!function(b){function c(a,b,c){return l.min(b,c)<=a&&a<=l.max(b,c)}function d(a,b,c){return l.min(l.max(b,a),c)}function e(a,b,c){var d="function"==typeof b?b:null,e=null==d?b:c,f=null==d?d3.max(a):d3.max(a,d);return void 0!==f?f:e}function f(a,b,c){var d="function"==typeof b?b:null,e=null==d?b:c,f=null==d?d3.min(a):d3.min(a,d);return void 0!==f?f:e}function g(a){return a!==a}function h(b){return"number"==typeof b&&!a.Utils.Math.isNaN(b)&&isFinite(b)}function i(a,b,c){if(void 0===c&&(c=1),0===c)throw new Error("step cannot be 0");for(var d=l.max(l.ceil((b-a)/c),0),e=[],f=0;d>f;++f)e[f]=a+c*f;return e}function j(a,b){return l.pow(b.y-a.y,2)+l.pow(b.x-a.x,2)}function k(a){return a/360*l.PI*2}var l=window.Math;b.inRange=c,b.clamp=d,b.max=e,b.min=f,b.isNaN=g,b.isValidNumber=h,b.range=i,b.distanceSquared=j,b.degreesToRadians=k}(c=b.Math||(b.Math={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function b(){"function"==typeof window.Map?this._es6Map=new window.Map:this._keyValuePairs=[]}return b.prototype.set=function(b,c){if(a.Math.isNaN(b))throw new Error("NaN may not be used as a key to the Map");if(null!=this._es6Map)return this._es6Map.set(b,c),this;for(var d=0;db.right?!1:a.bottomb.bottom?!1:!0}function h(a,b){return n.floor(b.left)<=n.ceil(a.left)&&n.floor(b.top)<=n.ceil(a.top)&&n.floor(a.right)<=n.ceil(b.right)&&n.floor(a.bottom)<=n.ceil(b.bottom)}function i(a){var b=a.ownerSVGElement;return null!=b?b:"svg"===a.nodeName.toLowerCase()?a:null}function j(){return"plottableClipPath"+ ++o}function k(a,b,c,d){void 0===d&&(d=.5);var e=l(a),f=l(b);return c.x+c.width>=e.min-d&&c.x<=e.max+d&&c.y+c.height>=f.min-d&&c.y<=f.max+d}function l(a){if("number"==typeof a){var b=a;return{min:b,max:b}}var c=a;if(c instanceof Object&&"min"in c&&"max"in c)return c;throw new Error("input '"+a+"' can't be parsed as an Range")}function m(a,b){var c=a.getPropertyValue(b),d=parseFloat(c);return d||0}var n=window.Math;a.elementBBox=b,a.SCREEN_REFRESH_RATE_MILLISECONDS=1e3/60,a.requestAnimationFramePolyfill=c,a.elementWidth=d,a.elementHeight=e,a.translate=f,a.clientRectsOverlap=g,a.clientRectInside=h,a.boundingSVG=i;var o=0;a.generateUniqueClipPathId=j,a.intersectsBBox=k}(b=a.DOM||(a.DOM={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b;!function(a){function b(a,b){var c=e(a)+.05,d=e(b)+.05;return c>d?c/d:d/c}function c(a,b){var c=d3.hsl(a).brighter(b);return c.rgb().toString()}function d(a,b){a.classed(b,!0);var c=a.style("background-color");if("transparent"===c)return null;var d=/\((.+)\)/.exec(c)[1].split(",").map(function(a){var b=+a,c=b.toString(16);return 16>b?"0"+c:c});if(4===d.length&&"00"===d[3])return null;var e="#"+d.join("");return a.classed(b,!1),e}function e(a){var b=d3.rgb(a),c=function(a){return a/=255,.03928>=a?a/12.92:f.pow((a+.055)/1.055,2.4)},d=c(b.r),e=c(b.g),g=c(b.b);return.2126*d+.7152*e+.0722*g}var f=window.Math;a.contrast=b,a.lightenColor=c,a.colorTest=d}(b=a.Color||(a.Color={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b;!function(a){function b(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 c(a){var b=d3.set(),c=[];return a.forEach(function(a){b.has(String(a))||(b.add(String(a)),c.push(a))}),c}function d(a){return f.prototype.concat.apply([],a)}function e(a,b){for(var c=[],d=0;b>d;d++)c[d]="function"==typeof a?a(d):a;return c}var f=window.Array;a.add=b,a.uniq=c,a.flatten=d,a.createFilledArray=e}(b=a.Array||(a.Array={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments)}return e(b,a),b.prototype.callCallbacks=function(){for(var a=this,b=[],c=0;c=0?f:g;m.has(k)?(j=m.get(k),m.set(k,j+l)):(j=0,m.set(k,l)),i.set(k,{value:l,offset:j})}),h.set(b,i)}),h}function d(b,c,d){var g=[];b.forEach(function(a,b){b.data().forEach(function(f,h){if(null==d||d(f,h,b)){var i=a.get(e(c(f,h,b)));g.push(i.value+i.offset)}})});var h=a.Math.max(g,0),i=a.Math.min(g,0);return[f.min(i,0),f.max(0,h)]}function e(a){return String(a)}var f=window.Math;b.stack=c,b.stackedExtent=d,b.normalizeKey=e}(b=a.Stacking||(a.Stacking={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(b){var c;!function(c){function d(b){a.Configs.SHOW_WARNINGS&&null!=window.console&&(null!=window.console.warn?console.warn(b):null!=window.console.log&&console.log(b))}function e(a,b){for(var c=[],d=2;da&&(b="-"+b)),b}}function d(a){return void 0===a&&(a=3),m(a),function(b){return b.toFixed(a)}}function e(a){return void 0===a&&(a=3),m(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),m(a),function(b){return d3.format("."+a+"s")(b)}}function i(a){void 0===a&&(a=3),m(a);var b="KMBTQ",c=d3.format("."+a+"e"),d=d3.format("."+a+"f"),e=Math.pow(10,3*(b.length+1)),f=Math.pow(10,-a);return function(a){var g=Math.abs(a);if((f>g||g>=e)&&0!==g)return c(a);for(var h=-1;g>=Math.pow(1e3,h+2)&&h0&&"1000"===i.substr(0,4)||0>a&&"-1000"===i.substr(0,5))&&(hd;d++)if(b[d].filter(c))return d3.time.format(b[d].format)(c)}}function k(a){return d3.time.format(a)}function l(b,c,d){return void 0===b&&(b=0),void 0===c&&(c=a.MILLISECONDS_IN_ONE_DAY),void 0===d&&(d=""),a.Utils.Window.deprecated("relativeDate()","v1.3.0","Not safe for use with time zones."),function(a){var e=Math.round((a.valueOf()-b)/c);return e.toString()+d}}function m(a){if(0>a||a>20)throw new RangeError("Formatter precision must be between 0 and 20");if(a!==Math.floor(a))throw new RangeError("Formatter precision must be an integer")}b.currency=c,b.fixed=d,b.general=e,b.identity=f,b.percentage=g,b.siSuffix=h,b.shortScale=i,b.multiTime=j,b.time=k,b.relativeDate=l}(b=a.Formatters||(a.Formatters={}))}(d||(d={}));var d;!function(a){var b;!function(a){function b(){return function(a){return d3.svg.symbol().type("circle").size(Math.PI*Math.pow(a/2,2))(null)}}function c(){return function(a){return d3.svg.symbol().type("square").size(Math.pow(a,2))(null)}}function d(){return function(a){return d3.svg.symbol().type("cross").size(5/9*Math.pow(a,2))(null)}}function e(){return function(a){return d3.svg.symbol().type("diamond").size(Math.tan(Math.PI/6)*Math.pow(a,2)/2)(null)}}function f(){return function(a){return d3.svg.symbol().type("triangle-up").size(Math.sqrt(3)*Math.pow(a/2,2))(null)}}function g(){return function(a){return d3.svg.symbol().type("triangle-down").size(Math.sqrt(3)*Math.pow(a/2,2))(null)}}a.circle=b,a.square=c,a.cross=d,a.diamond=e,a.triangleUp=f,a.triangleDown=g}(b=a.SymbolFactories||(a.SymbolFactories={}))}(d||(d={}));var d;!function(a){var b=function(){function b(){this._autoDomainAutomatically=!0,this._domainModificationInProgress=!1,this._callbacks=new a.Utils.CallbackSet,this._includedValuesProviders=new a.Utils.Set}return b.prototype.extentOfValues=function(a){return[]},b.prototype._getAllIncludedValues=function(){var a=this,b=[];return this._includedValuesProviders.forEach(function(c){var d=c(a);b=b.concat(d)}),b},b.prototype._getExtent=function(){return[]},b.prototype.onUpdate=function(a){return this._callbacks.add(a),this},b.prototype.offUpdate=function(a){return this._callbacks["delete"](a),this},b.prototype._dispatchUpdate=function(){this._callbacks.callCallbacks(this)},b.prototype.autoDomain=function(){return this._autoDomainAutomatically=!0,this._setDomain(this._getExtent()),this},b.prototype._autoDomainIfAutomaticMode=function(){this._autoDomainAutomatically&&this.autoDomain()},b.prototype.scale=function(a){throw new Error("Subclasses should override scale")},b.prototype.domain=function(a){return null==a?this._getDomain():(this._autoDomainAutomatically=!1,this._setDomain(a),this)},b.prototype._getDomain=function(){throw new Error("Subclasses should override _getDomain")},b.prototype._setDomain=function(a){this._domainModificationInProgress||(this._domainModificationInProgress=!0,this._setBackingScaleDomain(a),this._dispatchUpdate(),this._domainModificationInProgress=!1)},b.prototype._setBackingScaleDomain=function(a){throw new Error("Subclasses should override _setBackingDomain")},b.prototype.range=function(a){return null==a?this._getRange():(this._setRange(a),this)},b.prototype._getRange=function(){throw new Error("Subclasses should override _getRange")},b.prototype._setRange=function(a){throw new Error("Subclasses should override _setRange")},b.prototype.addIncludedValuesProvider=function(a){return this._includedValuesProviders.add(a),this._autoDomainIfAutomaticMode(),this},b.prototype.removeIncludedValuesProvider=function(a){return this._includedValuesProviders["delete"](a),this._autoDomainIfAutomaticMode(),this},b}();a.Scale=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b=function(b){function c(){b.call(this),this._tickGenerator=function(a){return a.defaultTicks()},this._padProportion=.05,this._snappingDomainEnabled=!0,this._paddingExceptionsProviders=new a.Utils.Set}return e(c,b),c.prototype.autoDomain=function(){return this._domainMin=null,this._domainMax=null,b.prototype.autoDomain.call(this),this},c.prototype._autoDomainIfAutomaticMode=function(){if(null!=this._domainMin&&null!=this._domainMax)return void this._setDomain([this._domainMin,this._domainMax]);var a=this._getExtent();if(null!=this._domainMin){var c=a[1];return this._domainMin>=c&&(c=this._expandSingleValueDomain([this._domainMin,this._domainMin])[1]),void this._setDomain([this._domainMin,c])}if(null!=this._domainMax){var d=a[0];return this._domainMax<=d&&(d=this._expandSingleValueDomain([this._domainMax,this._domainMax])[0]),void this._setDomain([d,this._domainMax])}b.prototype._autoDomainIfAutomaticMode.call(this)},c.prototype._getExtent=function(){var b=this._getAllIncludedValues(),c=this._defaultExtent();if(0!==b.length){var d=[a.Utils.Math.min(b,c[0]),a.Utils.Math.max(b,c[1])];c=this._padDomain(d)}return null!=this._domainMin&&(c[0]=this._domainMin),null!=this._domainMax&&(c[1]=this._domainMax),c},c.prototype.addPaddingExceptionsProvider=function(a){return this._paddingExceptionsProviders.add(a),this._autoDomainIfAutomaticMode(),this},c.prototype.removePaddingExceptionsProvider=function(a){return this._paddingExceptionsProviders["delete"](a),this._autoDomainIfAutomaticMode(),this},c.prototype.padProportion=function(a){if(null==a)return this._padProportion;if(0>a)throw new Error("padProportion must be non-negative");return this._padProportion=a,this._autoDomainIfAutomaticMode(),this},c.prototype._padDomain=function(a){var b=this;if(a[0].valueOf()===a[1].valueOf())return this._expandSingleValueDomain(a);if(0===this._padProportion)return a;var c=this._padProportion/2,d=a[0],e=a[1],f=!1,g=!1;this._paddingExceptionsProviders.forEach(function(a){var c=a(b);c.forEach(function(a){a.valueOf()===d.valueOf()&&(f=!0),a.valueOf()===e.valueOf()&&(g=!0)})});var h=f?d:this.invert(this.scale(d)-(this.scale(e)-this.scale(d))*c),i=g?e:this.invert(this.scale(e)+(this.scale(e)-this.scale(d))*c);return this._snappingDomainEnabled?this._niceDomain([h,i]):[h,i]},c.prototype.snappingDomainEnabled=function(a){return null==a?this._snappingDomainEnabled:(this._snappingDomainEnabled=a,this._autoDomainIfAutomaticMode(),this)},c.prototype._expandSingleValueDomain=function(a){return a},c.prototype.invert=function(a){throw new Error("Subclasses should override invert")},c.prototype.domain=function(a){return null!=a&&(this._domainMin=a[0],this._domainMax=a[1]),b.prototype.domain.call(this,a)},c.prototype.domainMin=function(a){return null==a?this.domain()[0]:(this._domainMin=a,this._autoDomainIfAutomaticMode(),this)},c.prototype.domainMax=function(a){return null==a?this.domain()[1]:(this._domainMax=a,this._autoDomainIfAutomaticMode(),this)},c.prototype.extentOfValues=function(b){var c=d3.extent(b.filter(function(b){return a.Utils.Math.isValidNumber(+b)}));return null==c[0]||null==c[1]?[]:c},c.prototype._setDomain=function(c){var d=function(b){return a.Utils.Math.isNaN(b)||b===1/0||b===-(1/0)};return d(c[0])||d(c[1])?void a.Utils.Window.warn("Warning: QuantitativeScales cannot take NaN or Infinity as a domain value. Ignoring."):void b.prototype._setDomain.call(this,c)},c.prototype.defaultTicks=function(){throw new Error("Subclasses should override _getDefaultTicks")},c.prototype.ticks=function(){return this._tickGenerator(this)},c.prototype._niceDomain=function(a,b){throw new Error("Subclasses should override _niceDomain")},c.prototype._defaultExtent=function(){throw new Error("Subclasses should override _defaultExtent")},c.prototype.tickGenerator=function(a){return null==a?this._tickGenerator:(this._tickGenerator=a,this)},c._DEFAULT_NUM_TICKS=10,c}(a.Scale);a.QuantitativeScale=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function c(){a.call(this),this._d3Scale=d3.scale.linear()}return e(c,a),c.prototype._defaultExtent=function(){return[0,1]},c.prototype._expandSingleValueDomain=function(a){return a[0]===a[1]?[a[0]-1,a[1]+1]:a},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setBackingScaleDomain=function(a){this._d3Scale.domain(a)},c.prototype._getRange=function(){return this._d3Scale.range()},c.prototype._setRange=function(a){this._d3Scale.range(a)},c.prototype.invert=function(a){return this._d3Scale.invert(a)},c.prototype.defaultTicks=function(){return this._d3Scale.ticks(b.Linear._DEFAULT_NUM_TICKS)},c.prototype._niceDomain=function(a,b){return this._d3Scale.copy().domain(a).nice(b).domain()},c}(a.QuantitativeScale);b.Linear=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(a){if(void 0===a&&(a=10),c.call(this),this._d3Scale=d3.scale.linear(),this._base=a,this._pivot=this._base,this._setDomain(this._defaultExtent()),1>=a)throw new Error("ModifiedLogScale: The base must be > 1")}return e(d,c),d.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=b&&c>=a}),n=m.sort(function(a,b){return a-b});return n},d.prototype._howManyTicks=function(c,d){var e=this._adjustedLog(a.Utils.Math.min(this._untransformedDomain,0)),f=this._adjustedLog(a.Utils.Math.max(this._untransformedDomain,0)),g=this._adjustedLog(c),h=this._adjustedLog(d),i=(h-g)/(f-e),j=Math.ceil(i*b.ModifiedLog._DEFAULT_NUM_TICKS);return j},d.prototype._niceDomain=function(a,b){return a},d.prototype._defaultExtent=function(){return[0,this._base]},d.prototype._expandSingleValueDomain=function(a){if(a[0]===a[1]){var b=a[0];return b>0?[b/this._base,b*this._base]:0===b?[-this._base,this._base]:[b*this._base,b/this._base]}return a},d.prototype._getRange=function(){return this._d3Scale.range()},d.prototype._setRange=function(a){this._d3Scale.range(a)},d.prototype.defaultTicks=function(){return this._d3Scale.ticks(b.ModifiedLog._DEFAULT_NUM_TICKS)},d}(a.QuantitativeScale);b.ModifiedLog=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this._range=[0,1],this._d3Scale=d3.scale.ordinal();var a=.3;this._innerPadding=c._convertToPlottableInnerPadding(a),this._outerPadding=c._convertToPlottableOuterPadding(.5,a)}return e(c,b),c.prototype.extentOfValues=function(b){return a.Utils.Array.uniq(b)},c.prototype._getExtent=function(){return a.Utils.Array.uniq(this._getAllIncludedValues())},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){if(null==a)return this._range;this._range=a;var b=1-1/(1+this.innerPadding()),c=this.outerPadding()/(1+this.innerPadding());return this._d3Scale.rangeBands(a,b,c),this},c._convertToPlottableInnerPadding=function(a){return 1/(1-a)-1},c._convertToPlottableOuterPadding=function(a,b){return a/(1-b)},c.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},c.prototype.stepWidth=function(){return this.rangeBand()*(1+this.innerPadding())},c.prototype.innerPadding=function(a){return null==a?this._innerPadding:(this._innerPadding=a,this.range(this.range()),this._dispatchUpdate(),this)},c.prototype.outerPadding=function(a){return null==a?this._outerPadding:(this._outerPadding=a,this.range(this.range()),this._dispatchUpdate(),this)},c.prototype.scale=function(a){return this._d3Scale(a)+this.rangeBand()/2},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setBackingScaleDomain=function(a){this._d3Scale.domain(a)},c.prototype._getRange=function(){return this._d3Scale.range()},c.prototype._setRange=function(a){this._d3Scale.range(a)},c}(a.Scale);b.Category=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a){b.call(this);var d;switch(a){case null:case void 0:null==c._plottableColorCache&&(c._plottableColorCache=c._getPlottableColors()),d=d3.scale.ordinal().range(c._plottableColorCache);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")}this._d3Scale=d}return e(c,b),c.prototype.extentOfValues=function(b){return a.Utils.Array.uniq(b)},c.prototype._getExtent=function(){return a.Utils.Array.uniq(this._getAllIncludedValues())},c.invalidateColorCache=function(){c._plottableColorCache=null},c._getPlottableColors=function(){for(var b,c=[],d=d3.select("body").append("plottable-color-tester"),e=a.Utils.Color.colorTest(d,""),f=0;null!==(b=a.Utils.Color.colorTest(d,"plottable-colors-"+f))&&f0&&this._setDomain([a.Utils.Math.min(b,0),a.Utils.Math.max(b,0)]),this},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setBackingScaleDomain=function(a){this._d3Scale.domain(a)},c.prototype._getRange=function(){return this._colorRange},c.prototype._setRange=function(a){this._colorRange=a,this._resetScale()},c.REDS=["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],c.BLUES=["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],c.POSNEG=["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],c}(a.Scale);b.InterpolatedColor=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d;!function(a){var b;!function(b){var c;!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.Utils.Math.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.defaultTicks();return b.filter(function(a,c){return a%1===0||0===c||c===b.length-1})}}b.intervalTickGenerator=c,b.integerTickGenerator=d}(c=b.TickGenerators||(b.TickGenerators={}))}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d;!function(a){var b=function(){function b(a){this._cachedSelectionValid=!1,this._dataset=a}return b.prototype.renderArea=function(a){return null==a?this._renderArea:(this._renderArea=a,this._cachedSelectionValid=!1,this)},b.prototype.remove=function(){null!=this.renderArea()&&this.renderArea().remove()},b.prototype._bindSelectionData=function(a){var b=this.selection().data(a);b.enter().append(this._svgElementName),b.exit().remove(),this._applyDefaultAttributes(b)},b.prototype._applyDefaultAttributes=function(a){null!=this._className&&a.classed(this._className,!0)},b.prototype._drawStep=function(a){var b=this.selection(),c=["fill","stroke"];c.forEach(function(c){null!=a.attrToAppliedProjector[c]&&b.attr(c,a.attrToAppliedProjector[c])}),a.animator.animate(b,a.attrToAppliedProjector),null!=this._className&&this.selection().classed(this._className,!0)},b.prototype._appliedProjectors=function(a){var b=this,c={};return Object.keys(a).forEach(function(d){c[d]=function(c,e){return a[d](c,e,b._dataset)}}),c},b.prototype.totalDrawTime=function(a,b){var c=0;return b.forEach(function(b,d){c+=b.animator.totalTime(a.length)}),c},b.prototype.draw=function(b,c){var d=this,e=c.map(function(a){var b=d._appliedProjectors(a.attrToProjector);return{attrToAppliedProjector:b,animator:a.animator}});this._bindSelectionData(b),this._cachedSelectionValid=!1;var f=0;return e.forEach(function(c,e){a.Utils.Window.setTimeout(function(){return d._drawStep(c)},f),f+=c.animator.totalTime(b.length)}),this},b.prototype.selection=function(){return this._cachedSelectionValid||(this._cachedSelection=this.renderArea().selectAll(this.selector()),this._cachedSelectionValid=!0),this._cachedSelection},b.prototype.selector=function(){return this._svgElementName},b.prototype.selectionForIndex=function(a){return d3.select(this.selection()[0][a])},b}();a.Drawer=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="line",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("fill","none")},b.prototype.selectionForIndex=function(a){return d3.select(this.selection()[0][0])},b}(a.Drawer);b.Line=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="area",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("stroke","none")},b.prototype.selectionForIndex=function(a){return d3.select(this.selection()[0][0])},b}(a.Drawer);b.Area=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._svgElementName="rect"}return e(b,a),b}(a.Drawer);b.Rectangle=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="arc fill",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("stroke","none")},b}(a.Drawer);b.Arc=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="arc outline",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("fill","none")},b}(a.Drawer);b.ArcOutline=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._svgElementName="path",this._className="symbol"}return e(b,a),b}(a.Drawer);b.Symbol=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._svgElementName="line"}return e(b,a),b}(a.Drawer);b.Segment=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function a(){}return a.TOP="top",a.BOTTOM="bottom",a.LEFT="left",a.RIGHT="right",a.CENTER="center",a}();a.Alignment=b}(b=a.Components||(a.Components={}));var c=function(){function b(){this._clipPathEnabled=!1,this._origin={x:0,y:0},this._xAlignment="left",this._yAlignment="top",this._isSetup=!1,this._isAnchored=!1,this._boxes=[],this._isTopLevelComponent=!1,this._cssClasses=new a.Utils.Set,this._destroyed=!1,this._onAnchorCallbacks=new a.Utils.CallbackSet,this._onDetachCallbacks=new a.Utils.CallbackSet,this._cssClasses.add("component")}return b.prototype.anchor=function(a){if(this._destroyed)throw new Error("Can't reuse destroy()-ed Components!");return"svg"===a.node().nodeName.toLowerCase()&&(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,this._onAnchorCallbacks.callCallbacks(this),this},b.prototype.onAnchor=function(a){return this._isAnchored&&a(this),this._onAnchorCallbacks.add(a),this},b.prototype.offAnchor=function(a){return this._onAnchorCallbacks["delete"](a),this},b.prototype._setup=function(){var b=this;this._isSetup||(this._cssClasses.forEach(function(a){b._element.classed(a,!0)}),this._cssClasses=new a.Utils.Set,this._backgroundContainer=this._element.append("g").classed("background-container",!0),this._addBox("background-fill",this._backgroundContainer),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._boundingBox=this._addBox("bounding-box"),this._isSetup=!0)},b.prototype.requestedSpace=function(a,b){return{minWidth:0,minHeight:0}},b.prototype.computeLayout=function(c,d,e){var f=this;if(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");c={x:0,y: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.Utils.DOM.elementWidth(g),e=a.Utils.DOM.elementHeight(g)}var h=this._sizeFromOffer(d,e);this._width=h.width,this._height=h.height;var i=b._xAlignToProportion[this._xAlignment],j=b._yAlignToProportion[this._yAlignment];return this._origin={x:c.x+(d-this.width())*i,y:c.y+(e-this.height())*j},this._element.attr("transform","translate("+this._origin.x+","+this._origin.y+")"),this._boxes.forEach(function(a){return a.attr("width",f.width()).attr("height",f.height())}),this},b.prototype._sizeFromOffer=function(a,b){var c=this.requestedSpace(a,b);return{width:this.fixedWidth()?Math.min(a,c.minWidth):a,height:this.fixedHeight()?Math.min(b,c.minHeight):b}},b.prototype.render=function(){return this._isAnchored&&this._isSetup&&this.width()>=0&&this.height()>=0&&a.RenderController.registerToRender(this),this},b.prototype._scheduleComputeLayout=function(){this._isAnchored&&this._isSetup&&a.RenderController.registerToComputeLayout(this)},b.prototype.renderImmediately=function(){return this._clipPathEnabled&&this._updateClipPath(),this},b.prototype.redraw=function(){return this._isAnchored&&this._isSetup&&(this._isTopLevelComponent?this._scheduleComputeLayout():this.parent().redraw()),this},b.prototype.renderTo=function(b){if(this.detach(),null!=b){var c;if(c="string"==typeof b?d3.select(b):b instanceof Element?d3.select(b):b,!c.node()||"svg"!==c.node().nodeName.toLowerCase())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.RenderController.flush(),this},b.prototype.xAlignment=function(a){if(null==a)return this._xAlignment;if(a=a.toLowerCase(),null==b._xAlignToProportion[a])throw new Error("Unsupported alignment: "+a);return this._xAlignment=a,this.redraw(),this},b.prototype.yAlignment=function(a){if(null==a)return this._yAlignment;if(a=a.toLowerCase(),null==b._yAlignToProportion[a])throw new Error("Unsupported alignment: "+a);return this._yAlignment=a,this.redraw(),this},b.prototype._addBox=function(a,b){if(null==this._element)throw new Error("Adding boxes before anchoring is currently disallowed");b=null==b?this._boxContainer:b;var 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},b.prototype._generateClipPath=function(){this._clipPathID=a.Utils.DOM.generateUniqueClipPathId();var b=this._boxContainer.append("clipPath").attr("id",this._clipPathID);this._addBox("clip-rect",b),this._updateClipPath()},b.prototype._updateClipPath=function(){var a=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;a=a.split("#")[0],this._element.attr("clip-path",'url("'+a+"#"+this._clipPathID+'")')},b.prototype.hasClass=function(a){return null==a?!1:null==this._element?this._cssClasses.has(a):this._element.classed(a)},b.prototype.addClass=function(a){return null==a?this:(null==this._element?this._cssClasses.add(a):this._element.classed(a,!0),this)},b.prototype.removeClass=function(a){return null==a?this:(null==this._element?this._cssClasses["delete"](a):this._element.classed(a,!1),this)},b.prototype.fixedWidth=function(){return!1},b.prototype.fixedHeight=function(){return!1},b.prototype.detach=function(){return this.parent(null),this._isAnchored&&this._element.remove(),this._isAnchored=!1,this._onDetachCallbacks.callCallbacks(this),this},b.prototype.onDetach=function(a){return this._onDetachCallbacks.add(a),this},b.prototype.offDetach=function(a){return this._onDetachCallbacks["delete"](a),this},b.prototype.parent=function(a){if(void 0===a)return this._parent;if(null!==a&&!a.has(this))throw new Error("Passed invalid parent");return this._parent=a,this},b.prototype.destroy=function(){this._destroyed=!0,this.detach()},b.prototype.width=function(){return this._width},b.prototype.height=function(){return this._height},b.prototype.origin=function(){return{x:this._origin.x,y:this._origin.y}},b.prototype.originToSVG=function(){for(var a=this.origin(),b=this.parent();null!=b;){var c=b.origin();a.x+=c.x,a.y+=c.y,b=b.parent()}return a},b.prototype.foreground=function(){return this._foregroundContainer},b.prototype.content=function(){return this._content},b.prototype.background=function(){return this._backgroundContainer},b._xAlignToProportion={left:0,center:.5,right:1},b._yAlignToProportion={top:0,center:.5,bottom:1},b}();a.Component=c}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b=function(a){function b(){var b=this;a.call(this),this._detachCallback=function(a){return b.remove(a)}}return e(b,a),b.prototype.anchor=function(b){var c=this;return a.prototype.anchor.call(this,b),this._forEach(function(a){return a.anchor(c.content())}),this},b.prototype.render=function(){return this._forEach(function(a){return a.render()}),this},b.prototype.has=function(a){throw new Error("has() is not implemented on ComponentContainer")},b.prototype._adoptAndAnchor=function(a){a.parent(this),a.onDetach(this._detachCallback),this._isAnchored&&a.anchor(this.content())},b.prototype.remove=function(a){return this.has(a)&&(a.offDetach(this._detachCallback),this._remove(a),a.detach(),this.redraw()),this},b.prototype._remove=function(a){return!1},b.prototype._forEach=function(a){throw new Error("_forEach() is not implemented on ComponentContainer")},b.prototype.destroy=function(){a.prototype.destroy.call(this),this._forEach(function(a){return a.destroy()})},b}(a.Component);a.ComponentContainer=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this._components=[],this.addClass("component-group"),a.forEach(function(a){return c.append(a)})}return e(c,b),c.prototype._forEach=function(a){this.components().forEach(a)},c.prototype.has=function(a){return this._components.indexOf(a)>=0},c.prototype.requestedSpace=function(b,c){var d=this._components.map(function(a){return a.requestedSpace(b,c)});return{minWidth:a.Utils.Math.max(d,function(a){return a.minWidth},0),minHeight:a.Utils.Math.max(d,function(a){return a.minHeight},0)}},c.prototype.computeLayout=function(a,c,d){var e=this;return b.prototype.computeLayout.call(this,a,c,d),this._forEach(function(a){a.computeLayout({x:0,y:0},e.width(),e.height())}),this},c.prototype._sizeFromOffer=function(a,b){return{width:a,height:b}},c.prototype.fixedWidth=function(){return this._components.every(function(a){return a.fixedWidth()})},c.prototype.fixedHeight=function(){return this._components.every(function(a){return a.fixedHeight()})},c.prototype.components=function(){return this._components.slice()},c.prototype.append=function(a){return null==a||this.has(a)||(a.detach(),this._components.push(a),this._adoptAndAnchor(a),this.redraw()),this},c.prototype._remove=function(a){var b=this._components.indexOf(a);return b>=0?(this._components.splice(b,1),!0):!1},c}(a.ComponentContainer);b.Group=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b=function(b){function c(c,d){var e=this;if(b.call(this),this._endTickLength=5,this._innerTickLength=5,this._tickLabelPadding=10,this._margin=15,this._showEndTickLabels=!1,this._annotationsEnabled=!1,this._annotationTierCount=1,null==c||null==d)throw new Error("Axis requires a scale and orientation");this._scale=c,this.orientation(d),this._setDefaultAlignment(),this.addClass("axis"),this._isHorizontal()?this.addClass("x-axis"):this.addClass("y-axis"),this.formatter(a.Formatters.identity()),this._rescaleCallback=function(a){return e._rescale()},this._scale.onUpdate(this._rescaleCallback),this._annotatedTicks=[],this._annotationFormatter=a.Formatters.identity()}return e(c,b),c.prototype.destroy=function(){b.prototype.destroy.call(this),this._scale.offUpdate(this._rescaleCallback)},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 d=0,e=0;if(this._isHorizontal()){if(null==this._computedHeight&&this._computeHeight(),e=this._computedHeight+this._margin,this.annotationsEnabled()){var f=this._annotationMeasurer.measure().height+2*c._ANNOTATION_LABEL_PADDING;e+=f*this.annotationTierCount()}}else if(null==this._computedWidth&&this._computeWidth(),d=this._computedWidth+this._margin,this.annotationsEnabled()){var f=this._annotationMeasurer.measure().height+2*c._ANNOTATION_LABEL_PADDING;d+=f*this.annotationTierCount()}return{minWidth:d,minHeight:e}},c.prototype.fixedHeight=function(){return this._isHorizontal()},c.prototype.fixedWidth=function(){return!this._isHorizontal()},c.prototype._rescale=function(){this.render()},c.prototype.computeLayout=function(a,c,d){return b.prototype.computeLayout.call(this,a,c,d),this._isHorizontal()?this._scale.range([0,this.width()]):this._scale.range([this.height(),0]),this},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),this._annotationContainer=this.content().append("g").classed("annotation-container",!0),this._annotationContainer.append("g").classed("annotation-line-container",!0),this._annotationContainer.append("g").classed("annotation-circle-container",!0),this._annotationContainer.append("g").classed("annotation-rect-container",!0);var a=this._annotationContainer.append("g").classed("annotation-label-container",!0);this._annotationMeasurer=new f.Measurers.Measurer(a),this._annotationWriter=new f.Writers.Writer(this._annotationMeasurer)},c.prototype._getTickValues=function(){return[]},c.prototype.renderImmediately=function(){var a=this._getTickValues(),b=this._tickMarkContainer.selectAll("."+c.TICK_MARK_CLASS).data(a);return 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()),this.annotationsEnabled()?this._drawAnnotations():this._removeAnnotations(),this},c.prototype.annotatedTicks=function(a){return null==a?this._annotatedTicks:(this._annotatedTicks=a,this.render(),this)},c.prototype.annotationFormatter=function(a){return null==a?this._annotationFormatter:(this._annotationFormatter=a,this.render(),this)},c.prototype.annotationsEnabled=function(a){return null==a?this._annotationsEnabled:(this._annotationsEnabled=a,this.redraw(),this)},c.prototype.annotationTierCount=function(a){if(null==a)return this._annotationTierCount;if(0>a)throw new Error("annotationTierCount cannot be negative");return this._annotationTierCount=a,this.redraw(),this},c.prototype._drawAnnotations=function(){var b=this,d=c._ANNOTATION_LABEL_PADDING,e=new a.Utils.Map,f=this._annotatedTicksToRender();f.forEach(function(a){var c=b._annotationMeasurer.measure(b.annotationFormatter()(a)),f={width:c.width+2*d,height:c.height+2*d};e.set(a,f)});var g=this._annotationMeasurer.measure().height+2*d,h=this._annotationToTier(e),i=new a.Utils.Set,j=this._isHorizontal()?this.height():this.width(),k=this._coreSize(),l=Math.min(this.annotationTierCount(),Math.floor((j-k)/g));h.forEach(function(a,b){(-1===a||a>=l)&&i.add(b)});var m,n=function(a,b,c){var d=a.selectAll("."+c).data(f);return d.enter().append(b).classed(c,!0),d.exit().remove(),d},o=function(a){switch(b.orientation()){case"bottom":case"right":return h.get(a)*g+k;case"top":case"left":return j-k-h.get(a)*g}},p=function(a){return b._scale.scale(a)},q=function(a){return i.has(a)?"hidden":"visible"};switch(this.orientation()){case"bottom":case"right":m=0;break;case"top":m=this.height();break;case"left":m=this.width()}var r=this._isHorizontal();n(this._annotationContainer.select(".annotation-line-container"),"line",c.ANNOTATION_LINE_CLASS).attr({x1:r?p:m,x2:r?p:o,y1:r?m:p,y2:r?o:p,visibility:q}),n(this._annotationContainer.select(".annotation-circle-container"),"circle",c.ANNOTATION_CIRCLE_CLASS).attr({cx:r?p:m,cy:r?m:p,r:3});var s=function(a){switch(b.orientation()){case"bottom":case"right":return o(a);case"top":case"left":return o(a)-e.get(a).height}};n(this._annotationContainer.select(".annotation-rect-container"),"rect",c.ANNOTATION_RECT_CLASS).attr({x:r?p:s,y:r?s:p,width:r?function(a){return e.get(a).width}:function(a){return e.get(a).height},height:r?function(a){return e.get(a).height}:function(a){return e.get(a).width},visibility:q});var t=this._annotationWriter,u=this.annotationFormatter(),v=n(this._annotationContainer.select(".annotation-label-container"),"g",c.ANNOTATION_LABEL_CLASS);v.selectAll(".text-container").remove(),v.attr({transform:function(a){var b=r?p(a):s(a),c=r?s(a):p(a);return"translate("+b+","+c+")"},visibility:q}).each(function(a){var b={selection:d3.select(this),xAlign:"center",yAlign:"center",textRotation:r?0:90};t.write(u(a),r?e.get(a).width:e.get(a).height,r?e.get(a).height:e.get(a).width,b)})},c.prototype._annotatedTicksToRender=function(){var b=this,c=this._scale.range();return a.Utils.Array.uniq(this.annotatedTicks().filter(function(d){return null==d?!1:a.Utils.Math.inRange(b._scale.scale(d),c[0],c[1])}))},c.prototype._coreSize=function(){var a=this._isHorizontal()?this.height():this.width(),b=this._isHorizontal()?this._computedHeight:this._computedWidth;return Math.min(b,a)},c.prototype._annotationTierHeight=function(){return this._annotationMeasurer.measure().height+2*c._ANNOTATION_LABEL_PADDING},c.prototype._annotationToTier=function(b){var c=this,d=[[]],e=new a.Utils.Map,f=this._isHorizontal()?this.width():this.height();return this._annotatedTicksToRender().forEach(function(a){var g=c._scale.scale(a),h=b.get(a).width;if(0>g||g+h>f)return void e.set(a,-1);for(var i=function(a){return d[a].some(function(a){var d=c._scale.scale(a),e=b.get(a).width;return g+h>=d&&d+e>=g})},j=0;i(j);)j++,d.length===j&&d.push([]);d[j].push(a),e.set(a,j)}),e},c.prototype._removeAnnotations=function(){this._annotationContainer.selectAll(".annotation-line").remove(),this._annotationContainer.selectAll(".annotation-circle").remove(),this._annotationContainer.selectAll(".annotation-rect").remove(),this._annotationContainer.selectAll(".annotation-label").remove()},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._innerTickLength;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.redraw=function(){return this._computedWidth=null,this._computedHeight=null,b.prototype.redraw.call(this)},c.prototype._setDefaultAlignment=function(){switch(this._orientation){case"bottom":this.yAlignment("top");break;case"top":this.yAlignment("bottom");break;case"left":this.xAlignment("right");break;case"right":this.xAlignment("left")}},c.prototype.formatter=function(a){return null==a?this._formatter:(this._formatter=a,this.redraw(),this)},c.prototype.tickLength=function(b){return a.Utils.Window.deprecated("tickLength()","v1.3.0","Replaced by innerTickLength()"),this.innerTickLength(b)},c.prototype.innerTickLength=function(a){if(null==a)return this._innerTickLength;if(0>a)throw new Error("inner tick length must be positive");return this._innerTickLength=a,this.redraw(),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.redraw(),this},c.prototype._maxLabelTickLength=function(){return this.showEndTickLabels()?Math.max(this.innerTickLength(),this.endTickLength()):this.innerTickLength()},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.redraw(),this},c.prototype.margin=function(a){if(null==a)return this._margin;if(0>a)throw new Error("margin size must be positive");return this._margin=a,this.redraw(),this},c.prototype.orientation=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.redraw(),this},c.prototype.showEndTickLabels=function(a){return null==a?this._showEndTickLabels:(this._showEndTickLabels=a,this.render(),this)},c.END_TICK_MARK_CLASS="end-tick-mark",c.TICK_MARK_CLASS="tick-mark",c.TICK_LABEL_CLASS="tick-label",c.ANNOTATION_LINE_CLASS="annotation-line",c.ANNOTATION_RECT_CLASS="annotation-rect",c.ANNOTATION_CIRCLE_CLASS="annotation-circle",c.ANNOTATION_LABEL_CLASS="annotation-label",c._ANNOTATION_LABEL_PADDING=4,c}(a.Component);a.Axis=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){a.second="second",a.minute="minute",a.hour="hour",a.day="day",a.week="week",a.month="month",a.year="year"}(b=a.TimeInterval||(a.TimeInterval={}));var c;!function(c){var d=function(c){function d(b,e){c.call(this,b,e),this._tierLabelPositions=[],this.addClass("time-axis"),this.tickLabelPadding(5),this.axisConfigurations(d._DEFAULT_TIME_AXIS_CONFIGURATIONS),this.annotationFormatter(a.Formatters.time("%a %b %d, %Y"))}return e(d,c),d.prototype.tierLabelPositions=function(a){if(null==a)return this._tierLabelPositions;if(!a.every(function(a){return"between"===a.toLowerCase()||"center"===a.toLowerCase()}))throw new Error("Unsupported position for tier labels");return this._tierLabelPositions=a,this.redraw(),this},d.prototype.axisConfigurations=function(b){if(null==b)return this._possibleTimeAxisConfigurations;this._possibleTimeAxisConfigurations=b,this._numTiers=a.Utils.Math.max(this._possibleTimeAxisConfigurations.map(function(a){return a.length}),0),this._isAnchored&&this._setupDomElements();for(var c=this.tierLabelPositions(),d=[],e=0;ed&&a.every(function(a){return b._checkTimeAxisTierConfigurationWidth(a)})&&(c=d)}),c===this._possibleTimeAxisConfigurations.length&&(a.Utils.Window.warn("zoomed out too far: could not find suitable interval to display labels"),--c),c},d.prototype.orientation=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.orientation.call(this,a)},d.prototype._computeHeight=function(){var a=this._measurer.measure().height;this._tierHeights=[];for(var b=0;bthis._scale.domain()[1])return this.width();var f=Math.abs(this._scale.scale(e)-this._scale.scale(c));return f},d.prototype._maxWidthForInterval=function(a){return this._measurer.measure(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._sizeFromOffer=function(a,b){var d=c.prototype._sizeFromOffer.call(this,a,b),e=this._tierHeights.reduce(function(a,b,c,e){return a+b>d.height?a:a+b}),f=this.margin()+(this.annotationsEnabled()?this.annotationTierCount()*this._annotationTierHeight():0);return d.height=Math.min(d.height,e+f),d},d.prototype._setup=function(){c.prototype._setup.call(this),this._setupDomElements()},d.prototype._setupDomElements=function(){this.content().selectAll("."+d.TIME_AXIS_TIER_CLASS).remove(),this._tierLabelContainers=[],this._tierMarkContainers=[],this._tierBaselines=[],this._tickLabelContainer.remove(),this._baseline.remove();for(var b=0;b=f.length||g.push(new Date((f[b+1].valueOf()-f[b].valueOf())/2+f[b].valueOf()))}):g=f;var h=b.selectAll("."+a.Axis.TICK_LABEL_CLASS).data(g,function(a){return String(a.valueOf())}),i=h.enter().append("g").classed(a.Axis.TICK_LABEL_CLASS,!0);i.append("text");var j="center"===this._tierLabelPositions[d]||1===c.step?0:this.tickLabelPadding(),k="bottom"===this.orientation()?d3.sum(this._tierHeights.slice(0,d+1))-this.tickLabelPadding():this.height()-d3.sum(this._tierHeights.slice(0,d))-this.tickLabelPadding(),l=h.selectAll("text");l.size()>0&&a.Utils.DOM.translate(l,j,k),h.exit().remove(),h.attr("transform",function(a){return"translate("+e._scale.scale(a)+",0)"});var m="center"===this._tierLabelPositions[d]||1===c.step?"middle":"start";h.selectAll("text").text(c.formatter).style("text-anchor",m)},d.prototype._renderTickMarks=function(b,c){var d=this._tierMarkContainers[c].selectAll("."+a.Axis.TICK_MARK_CLASS).data(b);d.enter().append("line").classed(a.Axis.TICK_MARK_CLASS,!0);var e=this._generateTickMarkAttrHash(),f=this._tierHeights.slice(0,c).reduce(function(a,b){return a+b},0);"bottom"===this.orientation()?(e.y1=f,e.y2=f+("center"===this._tierLabelPositions[c]?this.innerTickLength():this._tierHeights[c])):(e.y1=this.height()-f,e.y2=this.height()-(f+("center"===this._tierLabelPositions[c]?this.innerTickLength():this._tierHeights[c]))),d.attr(e),"bottom"===this.orientation()?(e.y1=f,e.y2=f+("center"===this._tierLabelPositions[c]?this.endTickLength():this._tierHeights[c])):(e.y1=this.height()-f,e.y2=this.height()-(f+("center"===this._tierLabelPositions[c]?this.endTickLength():this._tierHeights[c]))),d3.select(d[0][0]).attr(e),d3.select(d[0][d.size()-1]).attr(e),d3.select(d[0][0]).classed(a.Axis.END_TICK_MARK_CLASS,!0),d3.select(d[0][d.size()-1]).classed(a.Axis.END_TICK_MARK_CLASS,!0),d.exit().remove()},d.prototype._renderLabellessTickMarks=function(b){var c=this._tickMarkContainer.selectAll("."+a.Axis.TICK_MARK_CLASS).data(b);c.enter().append("line").classed(a.Axis.TICK_MARK_CLASS,!0);var d=this._generateTickMarkAttrHash();d.y2="bottom"===this.orientation()?this.tickLabelPadding():this.height()-this.tickLabelPadding(),c.attr(d),c.exit().remove()},d.prototype._generateLabellessTicks=function(){return this._mostPreciseConfigIndex<1?[]:this._getTickIntervalValues(this._possibleTimeAxisConfigurations[this._mostPreciseConfigIndex-1][0])},d.prototype.renderImmediately=function(){var a=this;this._mostPreciseConfigIndex=this._getMostPreciseConfigurationIndex();var b=this._possibleTimeAxisConfigurations[this._mostPreciseConfigIndex];this._cleanTiers(),b.forEach(function(b,c){return a._renderTierLabels(a._tierLabelContainers[c],b,c)});for(var c=b.map(function(b,c){return a._getTickValuesForConfiguration(b)}),d=0,e=0;e=i&&(g=this._generateLabellessTicks()),this._renderLabellessTickMarks(g),this._hideOverflowingTiers();for(var e=0;e=c?"inherit":"hidden"})},d.prototype._hideOverlappingAndCutOffLabels=function(b){var c,d=this,e=this._boundingBox.node().getBoundingClientRect(),f=function(a){return Math.floor(e.left)<=Math.ceil(a.left)&&Math.floor(e.top)<=Math.ceil(a.top)&&Math.floor(a.right)<=Math.ceil(e.left+d.width())&&Math.floor(a.bottom)<=Math.ceil(e.top+d.height())},g=this._tierMarkContainers[b].selectAll("."+a.Axis.TICK_MARK_CLASS).filter(function(a,b){var c=d3.select(this).style("visibility");return"visible"===c||"inherit"===c}),h=g[0].map(function(a){return a.getBoundingClientRect()}),i=this._tierLabelContainers[b].selectAll("."+a.Axis.TICK_LABEL_CLASS).filter(function(a,b){var c=d3.select(this).style("visibility");return"visible"===c||"inherit"===c});i.each(function(b,d){var e=this.getBoundingClientRect(),g=d3.select(this),i=h[d],j=h[d+1],k=null!=c&&a.Utils.DOM.clientRectsOverlap(e,c),l=null!=i&&a.Utils.DOM.clientRectsOverlap(e,i),m=null!=j&&a.Utils.DOM.clientRectsOverlap(e,j);!f(e)||k||l||m?g.style("visibility","hidden"):(c=e,g.style("visibility","inherit"))})},d.TIME_AXIS_TIER_CLASS="time-axis-tier",d._DEFAULT_TIME_AXIS_CONFIGURATIONS=[[{interval:b.second,step:1,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:5,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:10,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:15,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:30,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:1,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:5,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:10,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:15,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:30,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:1,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:3,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:6,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:12,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.day,step:1,formatter:a.Formatters.time("%a %e")},{interval:b.month,step:1,formatter:a.Formatters.time("%B %Y")}],[{interval:b.day,step:1,formatter:a.Formatters.time("%e")},{interval:b.month,step:1,formatter:a.Formatters.time("%B %Y")}],[{interval:b.month,step:1,formatter:a.Formatters.time("%B")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.month,step:1,formatter:a.Formatters.time("%b")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.month,step:3,formatter:a.Formatters.time("%b")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.month,step:6,formatter:a.Formatters.time("%b")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:1,formatter:a.Formatters.time("%y")}],[{interval:b.year,step:5,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:25,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:50,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:100,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:200,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:500,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:1e3,formatter:a.Formatters.time("%Y")}]],d._LONG_DATE=new Date(9999,8,29,12,59,9999),d}(a.Axis);c.Time=d}(c=a.Axes||(a.Axes={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this._tickLabelPositioning="center",this._usesTextWidthApproximation=!1,this.formatter(a.Formatters.general())}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this._measurer=new f.Measurers.Measurer(this._tickLabelContainer,a.Axis.TICK_LABEL_CLASS),this._wrapper=(new f.Wrappers.Wrapper).maxLines(1)},c.prototype._computeWidth=function(){var a=this._usesTextWidthApproximation?this._computeApproximateTextWidth():this._computeExactTextWidth();return"center"===this._tickLabelPositioning?this._computedWidth=this._maxLabelTickLength()+this.tickLabelPadding()+a:this._computedWidth=Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+a),this._computedWidth},c.prototype._computeExactTextWidth=function(){var b=this,c=this._getTickValues(),d=c.map(function(a){var c=b.formatter()(a);return b._measurer.measure(c).width});return a.Utils.Math.max(d,0)},c.prototype._computeApproximateTextWidth=function(){var b=this,c=this._getTickValues(),d=this._measurer.measure("M").width,e=c.map(function(a){var c=b.formatter()(a);return c.length*d});return a.Utils.Math.max(e,0)},c.prototype._computeHeight=function(){var a=this._measurer.measure().height;return"center"===this._tickLabelPositioning?this._computedHeight=this._maxLabelTickLength()+this.tickLabelPadding()+a:this._computedHeight=Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+a),this._computedHeight},c.prototype._getTickValues=function(){var a=this._scale,b=a.domain(),c=b[0]<=b[1]?b[0]:b[1],d=b[0]>=b[1]?b[0]:b[1];return c===b[0]?a.ticks().filter(function(a){return a>=c&&d>=a}):a.ticks().filter(function(a){return a>=c&&d>=a}).reverse()},c.prototype._rescale=function(){if(this._isSetup){if(!this._isHorizontal()){var a=this._computeWidth();if(a>this.width()||a=f.left)return!1}else if(e.top-c<=f.bottom)return!1}return!0},c}(a.Axis);b.Numeric=c}(b=a.Axes||(a.Axes={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a,c){b.call(this,a,c),this._tickLabelAngle=0,this.addClass("category-axis")}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this._measurer=new f.Measurers.CacheCharacterMeasurer(this._tickLabelContainer),this._wrapper=new f.Wrappers.SingleLineWrapper,this._writer=new f.Writers.Writer(this._measurer,this._wrapper)},c.prototype._rescale=function(){return this.redraw()},c.prototype.requestedSpace=function(a,b){var c=this._isHorizontal()?0:this._maxLabelTickLength()+this.tickLabelPadding()+this.margin(),d=this._isHorizontal()?this._maxLabelTickLength()+this.tickLabelPadding()+this.margin():0;if(0===this._scale.domain().length)return{minWidth:0,minHeight:0};if(this.annotationsEnabled()){var e=this._annotationTierHeight()*this.annotationTierCount();this._isHorizontal()?d+=e:c+=e}var f=this._scale,g=this._measureTicks(a,b,f,f.domain());return{minWidth:g.usedWidth+c,minHeight:g.usedHeight+d}},c.prototype._coreSize=function(){var a=this._isHorizontal()?this.height():this.width(),b=this._isHorizontal()?this.requestedSpace(this.width(),this.height()).minHeight:this.requestedSpace(this.width(),this.height()).minWidth,c=this.margin()+this._annotationTierHeight(),d=b-c;return Math.min(d,a)},c.prototype._getTickValues=function(){return this._scale.domain()},c.prototype.tickLabelAngle=function(a){if(null==a)return this._tickLabelAngle;if(0!==a&&90!==a&&-90!==a)throw new Error("Angle "+a+" not supported; only 0, 90, and -90 are valid values");return this._tickLabelAngle=a,this.redraw(),this},c.prototype._drawTicks=function(a,b,c,d){var e,f,g=this;switch(this.tickLabelAngle()){case 0:e={left:"right",right:"left",top:"center",bottom:"center"},f={left:"center",right:"center",top:"bottom",bottom:"top"};break;case 90:e={left:"center",right:"center",top:"right",bottom:"left"},f={left:"top",right:"bottom",top:"center",bottom:"center"};break;case-90:e={left:"center",right:"center",top:"left",bottom:"right"},f={left:"bottom",right:"top",top:"center",bottom:"center"}}d.each(function(d){var h=c.stepWidth(),i=g._isHorizontal()?h:a-g._maxLabelTickLength()-g.tickLabelPadding(),j=g._isHorizontal()?b-g._maxLabelTickLength()-g.tickLabelPadding():h,k={selection:d3.select(this),xAlign:e[g.orientation()],yAlign:f[g.orientation()],textRotation:g.tickLabelAngle()};g._writer.write(g.formatter()(d),i,j,k)})},c.prototype._measureTicks=function(b,c,d,e){var g=this,h=this._isHorizontal()?b:c,i=2*d.outerPadding(),j=(e.length-1)*d.innerPadding(),k=h/(i+j+e.length),l=k*(1+d.innerPadding()),m=e.map(function(a){var d=b-g._maxLabelTickLength()-g.tickLabelPadding();g._isHorizontal()&&(d=l,0!==g._tickLabelAngle&&(d=c-g._maxLabelTickLength()-g.tickLabelPadding()),d=Math.max(d,0));var e=l;return g._isHorizontal()&&(e=c-g._maxLabelTickLength()-g.tickLabelPadding(),0!==g._tickLabelAngle&&(e=b-g._maxLabelTickLength()-g.tickLabelPadding()),e=Math.max(e,0)),g._wrapper.wrap(g.formatter()(a),g._measurer,d,e)}),n=this._isHorizontal()&&0===this._tickLabelAngle?d3.sum:a.Utils.Math.max,o=this._isHorizontal()&&0===this._tickLabelAngle?a.Utils.Math.max:d3.sum,p=m.every(function(a){return!f.Utils.StringMethods.isNotEmptyString(a.truncatedText)&&1===a.noLines}),q=n(m,function(a){return g._measurer.measure(a.wrappedText).width},0),r=o(m,function(a){return g._measurer.measure(a.wrappedText).height},0);if(0!==this._tickLabelAngle){var s=r;r=q,q=s}return{textFits:p,usedWidth:q,usedHeight:r}},c.prototype.renderImmediately=function(){var c=this;b.prototype.renderImmediately.call(this);var d=this._scale,e=this._tickLabelContainer.selectAll("."+a.Axis.TICK_LABEL_CLASS).data(this._scale.domain(),function(a){return a}),f=function(a,b){var e=d.stepWidth()-d.rangeBand(),f=d.scale(a)-d.rangeBand()/2-e/2,g=c._isHorizontal()?f:0,h=c._isHorizontal()?0:f;return"translate("+g+","+h+")"};e.enter().append("g").classed(a.Axis.TICK_LABEL_CLASS,!0),e.exit().remove(),e.attr("transform",f),e.text(""),this._drawTicks(this.width(),this.height(),d,e);var g="right"===this.orientation()?this._maxLabelTickLength()+this.tickLabelPadding():0,h="bottom"===this.orientation()?this._maxLabelTickLength()+this.tickLabelPadding():0;return a.Utils.DOM.translate(this._tickLabelContainer,g,h),this},c.prototype.computeLayout=function(a,c,d){return this._measurer.reset(),b.prototype.computeLayout.call(this,a,c,d)},c}(a.Axis);b.Category=c}(b=a.Axes||(a.Axes={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b,c){void 0===b&&(b=""),void 0===c&&(c=0),a.call(this),this.addClass("label"),this.text(b),this.angle(c),this.xAlignment("center").yAlignment("center"),this._padding=0}return e(b,a),b.prototype.requestedSpace=function(a,b){var c=this._measurer.measure(this._text),d=(0===this.angle()?c.width:c.height)+2*this.padding(),e=(0===this.angle()?c.height:c.width)+2*this.padding();return{minWidth:d,minHeight:e}},b.prototype._setup=function(){a.prototype._setup.call(this),this._textContainer=this.content().append("g"),this._measurer=new f.Measurers.Measurer(this._textContainer),this._wrapper=new f.Wrappers.Wrapper,this._writer=new f.Writers.Writer(this._measurer,this._wrapper),this.text(this._text)},b.prototype.text=function(a){if(null==a)return this._text;if("string"!=typeof a)throw new Error("Label.text() only takes strings as input");return this._text=a,this.redraw(),this},b.prototype.angle=function(a){if(null==a)return this._angle;if(a%=360,a>180?a-=360:-180>a&&(a+=360),-90!==a&&0!==a&&90!==a)throw new Error(a+" is not a valid angle for Label");return this._angle=a,this.redraw(),this},b.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.redraw(),this},b.prototype.fixedWidth=function(){return!0},b.prototype.fixedHeight=function(){return!0},b.prototype.renderImmediately=function(){a.prototype.renderImmediately.call(this),this._textContainer.selectAll("g").remove();var b=this._measurer.measure(this._text),c=Math.max(Math.min((this.height()-b.height)/2,this.padding()),0),d=Math.max(Math.min((this.width()-b.width)/2,this.padding()),0);this._textContainer.attr("transform","translate("+d+","+c+")");var e=this.width()-2*d,f=this.height()-2*c,g={selection:this._textContainer,xAlign:this.xAlignment(),yAlign:this.yAlignment(),textRotation:this.angle()};return this._writer.write(this._text,e,f,g),this},b}(a.Component);b.Label=c;var d=function(a){function b(c,d){a.call(this,c,d),this.addClass(b.TITLE_LABEL_CLASS)}return e(b,a),b.TITLE_LABEL_CLASS="title-label",b}(c);b.TitleLabel=d;var g=function(a){function b(c,d){a.call(this,c,d),this.addClass(b.AXIS_LABEL_CLASS)}return e(b,a),b.AXIS_LABEL_CLASS="axis-label",b}(c);b.AxisLabel=g}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;if(b.call(this),this._padding=5,this.addClass("legend"),this.maxEntriesPerRow(1),null==c)throw new Error("Legend requires a colorScale");this._colorScale=c,this._redrawCallback=function(a){return d.redraw()},this._colorScale.onUpdate(this._redrawCallback),this._formatter=a.Formatters.identity(),this.xAlignment("right").yAlignment("top"),this.comparator(function(a,b){return 0}),this._symbolFactoryAccessor=function(){return a.SymbolFactories.circle()},this._symbolOpacityAccessor=function(){return 1}}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this);var d=this.content().append("g").classed(c.LEGEND_ROW_CLASS,!0),e=d.append("g").classed(c.LEGEND_ENTRY_CLASS,!0);e.append("text"),this._measurer=new f.Measurers.Measurer(d),this._wrapper=(new f.Wrappers.Wrapper).maxLines(1),this._writer=new f.Writers.Writer(this._measurer,this._wrapper).addTitleElement(a.Configs.ADD_TITLE_ELEMENTS)},c.prototype.formatter=function(a){return null==a?this._formatter:(this._formatter=a,this.redraw(),this)},c.prototype.maxEntriesPerRow=function(a){return null==a?this._maxEntriesPerRow:(this._maxEntriesPerRow=a,this.redraw(),this)},c.prototype.comparator=function(a){return null==a?this._comparator:(this._comparator=a,this.redraw(),this)},c.prototype.colorScale=function(a){return null!=a?(this._colorScale.offUpdate(this._redrawCallback),this._colorScale=a,this._colorScale.onUpdate(this._redrawCallback),this.redraw(),this):this._colorScale},c.prototype.destroy=function(){b.prototype.destroy.call(this),this._colorScale.offUpdate(this._redrawCallback)},c.prototype._calculateLayoutInfo=function(a,b){var c=this,d=this._measurer.measure().height,e=Math.max(0,a-this._padding),f=this._colorScale.domain().slice().sort(function(a,b){return c._comparator(c._formatter(a),c._formatter(b))}),g=d3.map(),h=d3.map();f.forEach(function(a){var b=d+c._measurer.measure(c._formatter(a)).width+c._padding,f=Math.min(b,e);g.set(a,f),h.set(a,b)});var i=this._packRows(e,f,g),j=Math.floor((b-2*this._padding)/d);return j!==j&&(j=0),{textHeight:d,entryLengths:g,untruncatedEntryLengths:h,rows:i,numRowsToDraw:Math.max(Math.min(j,i.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.untruncatedEntryLengths.get(a)})}),f=a.Utils.Math.max(e,0);return{minWidth:this._padding+f,minHeight:d.rows.length*d.textHeight+2*this._padding}},c.prototype._packRows=function(a,b,c){var d=this,e=[],f=[],g=a;return b.forEach(function(b){var h=c.get(b);(h>g||f.length===d._maxEntriesPerRow)&&(e.push(f),f=[],g=a),f.push(b),g-=h}),0!==f.length&&e.push(f),e},c.prototype.entitiesAt=function(a){if(!this._isSetup)return[];var b=[],d=this._calculateLayoutInfo(this.width(),this.height()),e=this._padding,f=this;return this.content().selectAll("g."+c.LEGEND_ROW_CLASS).each(function(g,h){var i=h*d.textHeight+e,j=(h+1)*d.textHeight+e,k=(i+j)/2,l=e,m=e;d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS).each(function(c){m+=d.entryLengths.get(c);var e=l+d.textHeight/2;if(m>=a.x&&l<=a.x&&j>=a.y&&i<=a.y){var g=d3.select(this),h=g.datum();b.push({datum:h,position:{x:e,y:k},selection:g,component:f})}l+=d.entryLengths.get(c)})}),b},c.prototype.renderImmediately=function(){var a=this;b.prototype.renderImmediately.call(this);var d=this._calculateLayoutInfo(this.width(),this.height()),e=d.rows.slice(0,d.numRowsToDraw),f=this.content().selectAll("g."+c.LEGEND_ROW_CLASS).data(e);f.enter().append("g").classed(c.LEGEND_ROW_CLASS,!0),f.exit().remove(),f.attr("transform",function(b,c){return"translate(0, "+(c*d.textHeight+a._padding)+")"});var g=f.selectAll("g."+c.LEGEND_ENTRY_CLASS).data(function(a){return a}),h=g.enter().append("g").classed(c.LEGEND_ENTRY_CLASS,!0);h.append("path"),h.append("g").classed("text-container",!0),g.exit().remove();var i=this._padding;f.each(function(a){var b=i,e=d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS);e.attr("transform",function(a,c){var e="translate("+b+", 0)";return b+=d.entryLengths.get(a),e})}),g.select("path").attr("d",function(b,c,e){return a.symbol()(b,e)(.6*d.textHeight)}).attr("transform","translate("+d.textHeight/2+","+d.textHeight/2+")").attr("fill",function(b){return a._colorScale.scale(b)}).attr("opacity",function(b,c,d){return a.symbolOpacity()(b,d)}).classed(c.LEGEND_SYMBOL_CLASS,!0);var j=this._padding,k=g.select("g.text-container");k.text("");var l=this;return k.attr("transform","translate("+d.textHeight+", 0)").each(function(a){var b=d3.select(this),c=d.entryLengths.get(a)-d.textHeight-j,e={selection:b,xAlign:"left",yAlign:"top",textRotation:0};l._writer.write(l._formatter(a),c,l.height(),e)}),this},c.prototype.symbol=function(a){return null==a?this._symbolFactoryAccessor:(this._symbolFactoryAccessor=a,this.render(),this)},c.prototype.symbolOpacity=function(a){return null==a?this._symbolOpacityAccessor:("number"==typeof a?this._symbolOpacityAccessor=function(){return a}:this._symbolOpacityAccessor=a,this.render(),this)},c.prototype.fixedWidth=function(){return!0},c.prototype.fixedHeight=function(){return!0},c.LEGEND_ROW_CLASS="legend-row",c.LEGEND_ENTRY_CLASS="legend-entry",c.LEGEND_SYMBOL_CLASS="legend-symbol",c}(a.Component);b.Legend=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;if(b.call(this),this._padding=5,null==c)throw new Error("InterpolatedColorLegend requires a interpolatedColorScale");this._scale=c,this._redrawCallback=function(a){return d.redraw()},this._scale.onUpdate(this._redrawCallback),this._formatter=a.Formatters.general(),this._orientation="horizontal",this._expands=!1,this.addClass("legend"),this.addClass("interpolated-color-legend")}return e(c,b),c.prototype.destroy=function(){b.prototype.destroy.call(this),this._scale.offUpdate(this._redrawCallback)},c.prototype.formatter=function(a){return void 0===a?this._formatter:(this._formatter=a,this.redraw(),this)},c.prototype.expands=function(a){return null==a?this._expands:(this._expands=a,this.redraw(),this)},c._ensureOrientation=function(a){if(a=a.toLowerCase(),"horizontal"===a||"left"===a||"right"===a)return a;throw new Error('"'+a+'" is not a valid orientation for InterpolatedColorLegend')},c.prototype.orientation=function(a){return null==a?this._orientation:(this._orientation=c._ensureOrientation(a),this.redraw(),this)},c.prototype.fixedWidth=function(){return!this.expands()||this._isVertical()},c.prototype.fixedHeight=function(){return!this.expands()||!this._isVertical()},c.prototype._generateTicks=function(a){void 0===a&&(a=c._DEFAULT_NUM_SWATCHES);for(var b=this._scale.domain(),d=(b[1]-b[0])/(a-1),e=[],f=0;a>f;f++)e.push(b[0]+d*f);return e},c.prototype._setup=function(){b.prototype._setup.call(this),this._swatchContainer=this.content().append("g").classed("swatch-container",!0),this._swatchBoundingBox=this.content().append("rect").classed("swatch-bounding-box",!0),this._lowerLabel=this.content().append("g").classed(c.LEGEND_LABEL_CLASS,!0),this._upperLabel=this.content().append("g").classed(c.LEGEND_LABEL_CLASS,!0),this._measurer=new f.Measurers.Measurer(this.content()),this._wrapper=new f.Wrappers.Wrapper,this._writer=new f.Writers.Writer(this._measurer,this._wrapper)},c.prototype.requestedSpace=function(b,d){var e,f,g=this,h=this._measurer.measure().height,i=this._scale.domain(),j=i.map(function(a){return g._measurer.measure(g._formatter(a)).width}),k=c._DEFAULT_NUM_SWATCHES;if(this._isVertical()){var l=a.Utils.Math.max(j,0);f=this._padding+h+this._padding+l+this._padding,e=this._padding+k*h+this._padding}else e=this._padding+h+this._padding,f=this._padding+j[0]+this._padding+k*h+this._padding+j[1]+this._padding;return{minWidth:f,minHeight:e}},c.prototype._isVertical=function(){return"horizontal"!==this._orientation},c.prototype.renderImmediately=function(){var a=this;b.prototype.renderImmediately.call(this);var d,e,f,g,h=this._scale.domain(),i=this._formatter(h[0]),j=this._measurer.measure(i).width,k=this._formatter(h[1]),l=this._measurer.measure(k).width,m=this._padding,n={ -x:0,y:0},o={x:0,y:0},p={selection:this._lowerLabel,xAlign:"center",yAlign:"center",textRotation:0},q={selection:this._upperLabel,xAlign:"center",yAlign:"center",textRotation:0},r={x:0,y:m,width:0,height:0},s=c._DEFAULT_NUM_SWATCHES,t=this._measurer.measure().height;if(this.expands()&&t>0){var u=this._isVertical()?2*m:4*m-j-l,v=this._isVertical()?this.height():this.width();s=Math.max(Math.floor((v-u)/t),s)}if(this._isVertical()){var w=Math.max(j,l);d=Math.max(this.width()-3*m-w,0),e=Math.max((this.height()-2*m)/s,0),g=function(a,b){return m+(s-(b+1))*e},q.yAlign="top",n.y=m,p.yAlign="bottom",o.y=-m,"left"===this._orientation?(f=function(a,b){return m+w+m},q.xAlign="right",n.x=-(m+d+m),p.xAlign="right",o.x=-(m+d+m)):(f=function(a,b){return m},q.xAlign="left",n.x=m+d+m,p.xAlign="left",o.x=m+d+m),r.width=d,r.height=s*e}else d=Math.max((this.width()-4*m-j-l)/s,0),e=Math.max(this.height()-2*m,0),f=function(a,b){return m+j+m+b*d},g=function(a,b){return m},q.xAlign="right",n.x=-m,p.xAlign="left",o.x=m,r.width=s*d,r.height=e;r.x=f(null,0),this._upperLabel.text(""),this._writer.write(k,this.width(),this.height(),q);var x="translate("+n.x+", "+n.y+")";this._upperLabel.attr("transform",x),this._lowerLabel.text(""),this._writer.write(i,this.width(),this.height(),p);var y="translate("+o.x+", "+o.y+")";this._lowerLabel.attr("transform",y),this._swatchBoundingBox.attr(r);var z=this._generateTicks(s),A=this._swatchContainer.selectAll("rect.swatch").data(z);return A.enter().append("rect").classed("swatch",!0),A.exit().remove(),A.attr({fill:function(b,c){return a._scale.scale(b)},width:d,height:e,x:f,y:g}),this},c._DEFAULT_NUM_SWATCHES=11,c.LEGEND_LABEL_CLASS="legend-label",c}(a.Component);b.InterpolatedColorLegend=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c,d){var e=this;if(null!=c&&!a.QuantitativeScale.prototype.isPrototypeOf(c))throw new Error("xScale needs to inherit from Scale.QuantitativeScale");if(null!=d&&!a.QuantitativeScale.prototype.isPrototypeOf(d))throw new Error("yScale needs to inherit from Scale.QuantitativeScale");b.call(this),this.addClass("gridlines"),this._xScale=c,this._yScale=d,this._renderCallback=function(a){return e.render()},this._xScale&&this._xScale.onUpdate(this._renderCallback),this._yScale&&this._yScale.onUpdate(this._renderCallback)}return e(c,b),c.prototype.destroy=function(){return b.prototype.destroy.call(this),this._xScale&&this._xScale.offUpdate(this._renderCallback),this._yScale&&this._yScale.offUpdate(this._renderCallback),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.renderImmediately=function(){return b.prototype.renderImmediately.call(this),this._redrawXLines(),this._redrawYLines(),this},c.prototype.computeLayout=function(a,c,d){return b.prototype.computeLayout.call(this,a,c,d),null!=this._xScale&&this._xScale.range([0,this.width()]),null!=this._yScale&&this._yScale.range([this.height(),0]),this},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}(a.Component);b.Gridlines=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this._rowPadding=0,this._columnPadding=0,this._rows=[],this._rowWeights=[],this._columnWeights=[],this._nRows=0,this._nCols=0,this._calculatedLayout=null,this.addClass("table"),a.forEach(function(a,b){a.forEach(function(a,d){null!=a&&c.add(a,b,d)})})}return e(c,b),c.prototype._forEach=function(a){for(var b=0;b0&&f!==z,E=g>0&&g!==A;if(!D&&!E)break;if(w>5)break}return f=m-d3.sum(h.guaranteedWidths),g=n-d3.sum(h.guaranteedHeights),s=c._calcProportionalSpace(p,f),t=c._calcProportionalSpace(o,g),{colProportionalSpace:s,rowProportionalSpace:t,guaranteedWidths:h.guaranteedWidths,guaranteedHeights:h.guaranteedHeights,wantsWidth:i,wantsHeight:j}},c.prototype._determineGuarantees=function(b,c,d){void 0===d&&(d=!1);var e=a.Utils.Array.createFilledArray(0,this._nCols),f=a.Utils.Array.createFilledArray(0,this._nRows),g=a.Utils.Array.createFilledArray(!1,this._nCols),h=a.Utils.Array.createFilledArray(!1,this._nRows);return this._rows.forEach(function(a,i){a.forEach(function(a,j){var k;k=null!=a?a.requestedSpace(b[j],c[i]):{minWidth:0,minHeight:0};var l=d?Math.min(k.minWidth,b[j]):k.minWidth;e[j]=Math.max(e[j],l);var m=d?Math.min(k.minHeight,c[i]):k.minHeight;f[i]=Math.max(f[i],m);var n=k.minWidth>b[j];g[j]=g[j]||n;var o=k.minHeight>c[i];h[i]=h[i]||o})}),{guaranteedWidths:e,guaranteedHeights:f,wantsWidthArr:g,wantsHeightArr:h}},c.prototype.requestedSpace=function(a,b){return this._calculatedLayout=this._iterateLayout(a,b),{minWidth:d3.sum(this._calculatedLayout.guaranteedWidths),minHeight:d3.sum(this._calculatedLayout.guaranteedHeights)}},c.prototype.computeLayout=function(c,d,e){var f=this;b.prototype.computeLayout.call(this,c,d,e);var g=d3.sum(this._calculatedLayout.guaranteedWidths),h=d3.sum(this._calculatedLayout.guaranteedHeights),i=this._calculatedLayout;(g>this.width()||h>this.height())&&(i=this._iterateLayout(this.width(),this.height(),!0));var j=0,k=a.Utils.Array.add(i.rowProportionalSpace,i.guaranteedHeights),l=a.Utils.Array.add(i.colProportionalSpace,i.guaranteedWidths);return this._rows.forEach(function(a,b){var c=0;a.forEach(function(a,d){null!=a&&a.computeLayout({x:c,y:j},l[d],k[b]),c+=l[d]+f._columnPadding}),j+=k[b]+f._rowPadding}),this},c.prototype.rowPadding=function(a){return null==a?this._rowPadding:(this._rowPadding=a,this.redraw(),this)},c.prototype.columnPadding=function(a){return null==a?this._columnPadding:(this._columnPadding=a,this.redraw(),this)},c.prototype.rowWeight=function(a,b){return null==b?this._rowWeights[a]:(this._rowWeights[a]=b,this.redraw(),this)},c.prototype.columnWeight=function(a,b){return null==b?this._columnWeights[a]:(this._columnWeights[a]=b,this.redraw(),this)},c.prototype.fixedWidth=function(){var a=d3.transpose(this._rows);return c._fixedSpace(a,function(a){return null==a||a.fixedWidth()})},c.prototype.fixedHeight=function(){return c._fixedSpace(this._rows,function(a){return null==a||a.fixedHeight()})},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(var d=0;b>d;d++)void 0===this._columnWeights[d]&&(this._columnWeights[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.Utils.Array.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}(a.ComponentContainer);b.Table=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){!function(a){a[a.VALUE=0]="VALUE",a[a.PIXEL=1]="PIXEL"}(b.PropertyMode||(b.PropertyMode={}));var c=b.PropertyMode,d=function(b){function d(){var a=this;b.call(this),this._boxVisible=!1,this._boxBounds={topLeft:{x:0,y:0},bottomRight:{x:0,y:0}},this._xBoundsMode=c.PIXEL,this._yBoundsMode=c.PIXEL,this.addClass("selection-box-layer"),this._adjustBoundsCallback=function(){a.render()},this._clipPathEnabled=!0,this._xExtent=[void 0,void 0],this._yExtent=[void 0,void 0]}return e(d,b),d.prototype._setup=function(){b.prototype._setup.call(this),this._box=this.content().append("g").classed("selection-box",!0).remove(),this._boxArea=this._box.append("rect").classed("selection-area",!0)},d.prototype._sizeFromOffer=function(a,b){return{width:a,height:b}},d.prototype.bounds=function(a){return null==a?this._getBounds():(this._setBounds(a),this._xBoundsMode=c.PIXEL,this._yBoundsMode=c.PIXEL,this.render(),this)},d.prototype._setBounds=function(a){var b={x:Math.min(a.topLeft.x,a.bottomRight.x),y:Math.min(a.topLeft.y,a.bottomRight.y)},c={x:Math.max(a.topLeft.x,a.bottomRight.x),y:Math.max(a.topLeft.y,a.bottomRight.y)};this._boxBounds={topLeft:b,bottomRight:c}},d.prototype._getBounds=function(){return{topLeft:{x:this._xBoundsMode===c.PIXEL?this._boxBounds.topLeft.x:null==this._xScale?0:Math.min(this.xScale().scale(this.xExtent()[0]),this.xScale().scale(this.xExtent()[1])),y:this._yBoundsMode===c.PIXEL?this._boxBounds.topLeft.y:null==this._yScale?0:Math.min(this.yScale().scale(this.yExtent()[0]),this.yScale().scale(this.yExtent()[1]))},bottomRight:{x:this._xBoundsMode===c.PIXEL?this._boxBounds.bottomRight.x:null==this._xScale?0:Math.max(this.xScale().scale(this.xExtent()[0]),this.xScale().scale(this.xExtent()[1])),y:this._yBoundsMode===c.PIXEL?this._boxBounds.bottomRight.y:null==this._yScale?0:Math.max(this.yScale().scale(this.yExtent()[0]),this.yScale().scale(this.yExtent()[1]))}}},d.prototype.renderImmediately=function(){if(b.prototype.renderImmediately.call(this),this._boxVisible){var c=this.bounds(),d=c.topLeft.y,e=c.bottomRight.y,f=c.topLeft.x,g=c.bottomRight.x;if(!(a.Utils.Math.isValidNumber(d)&&a.Utils.Math.isValidNumber(e)&&a.Utils.Math.isValidNumber(f)&&a.Utils.Math.isValidNumber(g)))throw new Error("bounds have not been properly set");this._boxArea.attr({x:f,y:d,width:g-f,height:e-d}),this.content().node().appendChild(this._box.node())}else this._box.remove();return this},d.prototype.boxVisible=function(a){return null==a?this._boxVisible:(this._boxVisible=a,this.render(),this)},d.prototype.fixedWidth=function(){return!0},d.prototype.fixedHeight=function(){return!0},d.prototype.xScale=function(a){return null==a?this._xScale:(null!=this._xScale&&this._xScale.offUpdate(this._adjustBoundsCallback),this._xScale=a,this._xBoundsMode=c.VALUE,this._xScale.onUpdate(this._adjustBoundsCallback),this.render(),this)},d.prototype.yScale=function(a){return null==a?this._yScale:(null!=this._yScale&&this._yScale.offUpdate(this._adjustBoundsCallback),this._yScale=a,this._yBoundsMode=c.VALUE,this._yScale.onUpdate(this._adjustBoundsCallback),this.render(),this)},d.prototype.xExtent=function(a){return null==a?this._getXExtent():(this._setXExtent(a),this._xBoundsMode=c.VALUE,this.render(),this)},d.prototype._getXExtent=function(){return this._xBoundsMode===c.VALUE?this._xExtent:null==this._xScale?[void 0,void 0]:[this._xScale.invert(this._boxBounds.topLeft.x),this._xScale.invert(this._boxBounds.bottomRight.x)]},d.prototype._setXExtent=function(a){this._xExtent=a},d.prototype.yExtent=function(a){return null==a?this._getYExtent():(this._setYExtent(a),this._yBoundsMode=c.VALUE,this.render(),this)},d.prototype._getYExtent=function(){return this._yBoundsMode===c.VALUE?this._yExtent:null==this._yScale?[void 0,void 0]:[this._yScale.invert(this._boxBounds.topLeft.y),this._yScale.invert(this._boxBounds.bottomRight.y)]},d.prototype._setYExtent=function(a){this._yExtent=a},d.prototype.destroy=function(){b.prototype.destroy.call(this),null!=this._xScale&&this.xScale().offUpdate(this._adjustBoundsCallback),null!=this._yScale&&this.yScale().offUpdate(this._adjustBoundsCallback)},d}(a.Component);b.SelectionBoxLayer=d}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c;!function(a){a[a.VALUE=0]="VALUE",a[a.PIXEL=1]="PIXEL"}(c||(c={}));var d=function(b){function d(a){var e=this;if(b.call(this),this._mode=c.VALUE,a!==d.ORIENTATION_VERTICAL&&a!==d.ORIENTATION_HORIZONTAL)throw new Error(a+" is not a valid orientation for GuideLineLayer");this._orientation=a,this._clipPathEnabled=!0,this.addClass("guide-line-layer"),this._isVertical()?this.addClass("vertical"):this.addClass("horizontal"),this._scaleUpdateCallback=function(){e._syncPixelPositionAndValue(),e.render()}}return e(d,b),d.prototype._setup=function(){b.prototype._setup.call(this),this._guideLine=this.content().append("line").classed("guide-line",!0)},d.prototype._sizeFromOffer=function(a,b){return{width:a,height:b}},d.prototype._isVertical=function(){return this._orientation===d.ORIENTATION_VERTICAL},d.prototype.fixedWidth=function(){return!0},d.prototype.fixedHeight=function(){return!0},d.prototype.computeLayout=function(a,c,d){return b.prototype.computeLayout.call(this,a,c,d),null!=this.scale()&&(this._isVertical()?this.scale().range([0,this.width()]):this.scale().range([this.height(),0])),this},d.prototype.renderImmediately=function(){return b.prototype.renderImmediately.call(this),this._syncPixelPositionAndValue(),this._guideLine.attr({x1:this._isVertical()?this.pixelPosition():0,y1:this._isVertical()?0:this.pixelPosition(),x2:this._isVertical()?this.pixelPosition():this.width(),y2:this._isVertical()?this.height():this.pixelPosition()}),this},d.prototype._syncPixelPositionAndValue=function(){null!=this.scale()&&(this._mode===c.VALUE&&null!=this.value()?this._pixelPosition=this.scale().scale(this.value()):this._mode===c.PIXEL&&null!=this.pixelPosition()&&(this._value=this.scale().invert(this.pixelPosition())))},d.prototype._setPixelPositionWithoutChangingMode=function(a){this._pixelPosition=a,null!=this.scale()&&(this._value=this.scale().invert(this.pixelPosition())),this.render()},d.prototype.scale=function(a){if(null==a)return this._scale;var b=this._scale;return null!=b&&b.offUpdate(this._scaleUpdateCallback),this._scale=a,this._scale.onUpdate(this._scaleUpdateCallback),this._syncPixelPositionAndValue(),this.redraw(),this},d.prototype.value=function(a){return null==a?this._value:(this._value=a,this._mode=c.VALUE,this._syncPixelPositionAndValue(),this.render(),this)},d.prototype.pixelPosition=function(b){if(null==b)return this._pixelPosition;if(!a.Utils.Math.isValidNumber(b))throw new Error("pixelPosition must be a finite number");return this._pixelPosition=b,this._mode=c.PIXEL,this._syncPixelPositionAndValue(),this.render(),this},d.prototype.destroy=function(){b.prototype.destroy.call(this),null!=this.scale()&&this.scale().offUpdate(this._scaleUpdateCallback)},d.ORIENTATION_VERTICAL="vertical",d.ORIENTATION_HORIZONTAL="horizontal",d}(a.Component);b.GuideLineLayer=d}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b;!function(a){a.MAIN="main",a.RESET="reset"}(b=a.Animator||(a.Animator={}))}(b=a.Plots||(a.Plots={}));var c=function(c){function d(){var e=this;c.call(this),this._dataChanged=!1,this._animate=!1,this._animators={},this._clipPathEnabled=!0,this.addClass("plot"),this._datasetToDrawer=new a.Utils.Map,this._attrBindings=d3.map(),this._attrExtents=d3.map(),this._includedValuesProvider=function(a){return e._includedValuesForScale(a)},this._renderCallback=function(a){return e.render()},this._onDatasetUpdateCallback=function(){return e._onDatasetUpdate()},this._propertyBindings=d3.map(),this._propertyExtents=d3.map();var f=(new a.Animators.Easing).maxTotalDuration(d._ANIMATION_MAX_DURATION);this.animator(b.Animator.MAIN,f),this.animator(b.Animator.RESET,new a.Animators.Null)}return e(d,c),d.prototype.anchor=function(a){return c.prototype.anchor.call(this,a),this._dataChanged=!0,this._updateExtents(),this},d.prototype._setup=function(){var a=this;c.prototype._setup.call(this),this._renderArea=this.content().append("g").classed("render-area",!0),this.datasets().forEach(function(b){return a._createNodesForDataset(b)})},d.prototype.destroy=function(){var a=this;c.prototype.destroy.call(this),this._scales().forEach(function(b){return b.offUpdate(a._renderCallback)}),this.datasets([])},d.prototype._createNodesForDataset=function(a){var b=this._datasetToDrawer.get(a);return b.renderArea(this._renderArea.append("g")),b},d.prototype._createDrawer=function(b){return new a.Drawer(b)},d.prototype._getAnimator=function(b){return this._animateOnNextRender()?this._animators[b]||new a.Animators.Null:new a.Animators.Null},d.prototype._onDatasetUpdate=function(){this._updateExtents(),this._dataChanged=!0,this.render()},d.prototype.attr=function(a,b,c){return null==b?this._attrBindings.get(a):(this._bindAttr(a,b,c),this.render(),this)},d.prototype._bindProperty=function(a,b,c){var d=this._propertyBindings.get(a),e=null!=d?d.scale:null;this._propertyBindings.set(a,{accessor:d3.functor(b),scale:c}),this._updateExtentsForProperty(a),null!=e&&this._uninstallScaleForKey(e,a),null!=c&&this._installScaleForKey(c,a)},d.prototype._bindAttr=function(a,b,c){var d=this._attrBindings.get(a),e=null!=d?d.scale:null;this._attrBindings.set(a,{accessor:d3.functor(b),scale:c}),this._updateExtentsForAttr(a),null!=e&&this._uninstallScaleForKey(e,a),null!=c&&this._installScaleForKey(c,a)},d.prototype._generateAttrToProjector=function(){var a={};this._attrBindings.forEach(function(b,c){var d=c.accessor,e=c.scale,f=e?function(a,b,c){return e.scale(d(a,b,c))}:d;a[b]=f});var b=this._propertyProjectors();return Object.keys(b).forEach(function(c){null==a[c]&&(a[c]=b[c])}),a},d.prototype.renderImmediately=function(){return c.prototype.renderImmediately.call(this),this._isAnchored&&(this._paint(),this._dataChanged=!1),this},d.prototype.animated=function(a){return null==a?this._animate:(this._animate=a,this)},d.prototype.detach=function(){return c.prototype.detach.call(this),this._updateExtents(),this},d.prototype._scales=function(){var a=[];return this._attrBindings.forEach(function(b,c){var d=c.scale;null!=d&&-1===a.indexOf(d)&&a.push(d)}),this._propertyBindings.forEach(function(b,c){var d=c.scale;null!=d&&-1===a.indexOf(d)&&a.push(d)}),a},d.prototype._updateExtents=function(){var a=this;this._attrBindings.forEach(function(b){return a._updateExtentsForAttr(b)}),this._propertyExtents.forEach(function(b){return a._updateExtentsForProperty(b)}),this._scales().forEach(function(b){return b.addIncludedValuesProvider(a._includedValuesProvider)})},d.prototype._updateExtentsForAttr=function(a){this._updateExtentsForKey(a,this._attrBindings,this._attrExtents,null)},d.prototype._updateExtentsForProperty=function(a){this._updateExtentsForKey(a,this._propertyBindings,this._propertyExtents,this._filterForProperty(a))},d.prototype._filterForProperty=function(a){return null},d.prototype._updateExtentsForKey=function(a,b,c,d){var e=this,f=b.get(a);null!=f&&null!=f.accessor&&c.set(a,this.datasets().map(function(a){return e._computeExtent(a,f,d)}))},d.prototype._computeExtent=function(a,b,c){var d=b.accessor,e=b.scale;if(null==e)return[];var f=a.data();null!=c&&(f=f.filter(function(b,d){return c(b,d,a)}));var g=function(b,c){return d(b,c,a)},h=f.map(g);return e.extentOfValues(h)},d.prototype._extentsForProperty=function(a){return this._propertyExtents.get(a)},d.prototype._includedValuesForScale=function(a){var b=this;if(!this._isAnchored)return[];var c=[];return this._attrBindings.forEach(function(d,e){if(e.scale===a){var f=b._attrExtents.get(d);null!=f&&(c=c.concat(d3.merge(f)))}}),this._propertyBindings.forEach(function(d,e){if(e.scale===a){var f=b._extentsForProperty(d);null!=f&&(c=c.concat(d3.merge(f)))}}),c},d.prototype.animator=function(a,b){return void 0===b?this._animators[a]:(this._animators[a]=b,this)},d.prototype.addDataset=function(a){return this._addDataset(a),this._onDatasetUpdate(),this},d.prototype._addDataset=function(a){this._removeDataset(a);var b=this._createDrawer(a);return this._datasetToDrawer.set(a,b),this._isSetup&&this._createNodesForDataset(a),a.onUpdate(this._onDatasetUpdateCallback),this},d.prototype.removeDataset=function(a){return this._removeDataset(a),this._onDatasetUpdate(),this},d.prototype._removeDataset=function(a){return-1===this.datasets().indexOf(a)?this:(this._removeDatasetNodes(a),a.offUpdate(this._onDatasetUpdateCallback),this._datasetToDrawer["delete"](a),this)},d.prototype._removeDatasetNodes=function(a){var b=this._datasetToDrawer.get(a);b.remove()},d.prototype.datasets=function(a){var b=this,c=[];return this._datasetToDrawer.forEach(function(a,b){return c.push(b)}),null==a?c:(c.forEach(function(a){return b._removeDataset(a)}),a.forEach(function(a){return b._addDataset(a)}),this._onDatasetUpdate(),this)},d.prototype._getDrawersInOrder=function(){var a=this;return this.datasets().map(function(b){return a._datasetToDrawer.get(b)})},d.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animators.Null}]},d.prototype._additionalPaint=function(a){},d.prototype._getDataToDraw=function(){var b=new a.Utils.Map;return this.datasets().forEach(function(a){return b.set(a,a.data())}),b},d.prototype._paint=function(){var b=this._generateDrawSteps(),c=this._getDataToDraw(),d=this._getDrawersInOrder();this.datasets().forEach(function(a,e){return d[e].draw(c.get(a),b)});var e=this.datasets().map(function(a,e){return d[e].totalDrawTime(c.get(a),b)}),f=a.Utils.Math.max(e,0);this._additionalPaint(f)},d.prototype.selections=function(a){var b=this;void 0===a&&(a=this.datasets());var c=[];return a.forEach(function(a){var d=b._datasetToDrawer.get(a);null!=d&&d.renderArea().selectAll(d.selector()).each(function(){c.push(this)})}),d3.selectAll(c)},d.prototype.entities=function(a){var b=this;return void 0===a&&(a=this.datasets()),this._lightweightEntities(a).map(function(a){return b._lightweightPlotEntityToPlotEntity(a)})},d.prototype._lightweightEntities=function(b){var c=this;void 0===b&&(b=this.datasets());var d=[];return b.forEach(function(b){var e=c._datasetToDrawer.get(b),f=0;b.data().forEach(function(g,h){var i=c._pixelPoint(g,h,b);a.Utils.Math.isNaN(i.x)||a.Utils.Math.isNaN(i.y)||(d.push({datum:g,index:h,dataset:b,position:i,component:c,drawer:e,validDatumIndex:f}),f++)})}),d},d.prototype._lightweightPlotEntityToPlotEntity=function(a){var b={datum:a.datum,position:a.position,dataset:a.dataset,index:a.index,component:a.component,selection:a.drawer.selectionForIndex(a.validDatumIndex)};return b},d.prototype.entityNearest=function(b){var c,d=this,e=1/0,f=this._lightweightEntities();return f.forEach(function(f){if(d._entityVisibleOnPlot(f.position,f.datum,f.index,f.dataset)){var g=a.Utils.Math.distanceSquared(f.position,b);e>g&&(e=g,c=f)}}),this._lightweightPlotEntityToPlotEntity(c)},d.prototype._visibleOnPlot=function(b,c,d){return a.Utils.Window.deprecated("Plot._visibleOnPlot()","v1.1.0","replaced by _entityVisibleOnPlot()"),!(c.x<0||c.y<0||c.x>this.width()||c.y>this.height())},d.prototype._entityVisibleOnPlot=function(a,b,c,d){return!(a.x<0||a.y<0||a.x>this.width()||a.y>this.height())},d.prototype._uninstallScaleForKey=function(a,b){a.offUpdate(this._renderCallback),a.removeIncludedValuesProvider(this._includedValuesProvider)},d.prototype._installScaleForKey=function(a,b){a.onUpdate(this._renderCallback),a.addIncludedValuesProvider(this._includedValuesProvider)},d.prototype._propertyProjectors=function(){return{}},d._scaledAccessor=function(a){return null==a.scale?a.accessor:function(b,c,d){return a.scale.scale(a.accessor(b,c,d))}},d.prototype._pixelPoint=function(a,b,c){return{x:0,y:0}},d.prototype._animateOnNextRender=function(){return this._animate&&this._dataChanged},d._ANIMATION_MAX_DURATION=600,d}(a.Component);a.Plot=c}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.call(this),this._labelFormatter=a.Formatters.identity(),this._labelsEnabled=!1,this.innerRadius(0),this.outerRadius(function(){return Math.min(c.width(),c.height())/2}),this.addClass("pie-plot"),this.attr("fill",function(a,b){return String(b)},new a.Scales.Color),this._strokeDrawers=new a.Utils.Map}return e(c,b),c.prototype._setup=function(){var a=this;b.prototype._setup.call(this),this._strokeDrawers.forEach(function(b){return b.renderArea(a._renderArea.append("g"))})},c.prototype.computeLayout=function(a,c,d){b.prototype.computeLayout.call(this,a,c,d),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")");var e=Math.min(this.width(),this.height())/2;return null!=this.innerRadius().scale&&this.innerRadius().scale.range([0,e]),null!=this.outerRadius().scale&&this.outerRadius().scale.range([0,e]),this},c.prototype.addDataset=function(a){return b.prototype.addDataset.call(this,a),this},c.prototype._addDataset=function(c){if(1===this.datasets().length)return a.Utils.Window.warn("Only one dataset is supported in Pie plots"),this;this._updatePieAngles();var d=new a.Drawers.ArcOutline(c);return this._isSetup&&d.renderArea(this._renderArea.append("g")),this._strokeDrawers.set(c,d),b.prototype._addDataset.call(this,c),this},c.prototype.removeDataset=function(a){return b.prototype.removeDataset.call(this,a),this},c.prototype._removeDatasetNodes=function(a){b.prototype._removeDatasetNodes.call(this,a),this._strokeDrawers.get(a).remove()},c.prototype._removeDataset=function(a){return b.prototype._removeDataset.call(this,a),this._startAngles=[],this._endAngles=[],this},c.prototype.selections=function(a){var c=this;void 0===a&&(a=this.datasets());var d=b.prototype.selections.call(this,a)[0];return a.forEach(function(a){var b=c._strokeDrawers.get(a);null!=b&&b.renderArea().selectAll(b.selector()).each(function(){d.push(this)})}),d3.selectAll(d)},c.prototype._onDatasetUpdate=function(){this._updatePieAngles(),b.prototype._onDatasetUpdate.call(this)},c.prototype._createDrawer=function(b){return new a.Drawers.Arc(b)},c.prototype.entities=function(a){var c=this;void 0===a&&(a=this.datasets());var d=b.prototype.entities.call(this,a);return d.forEach(function(a){a.position.x+=c.width()/2,a.position.y+=c.height()/2;var b=c._strokeDrawers.get(a.dataset).selectionForIndex(a.index);a.selection[0].push(b[0][0])}),d},c.prototype.sectorValue=function(a,b){return null==a?this._propertyBindings.get(c._SECTOR_VALUE_KEY):(this._bindProperty(c._SECTOR_VALUE_KEY,a,b),this._updatePieAngles(),this.render(),this)},c.prototype.innerRadius=function(a,b){return null==a?this._propertyBindings.get(c._INNER_RADIUS_KEY):(this._bindProperty(c._INNER_RADIUS_KEY,a,b),this.render(),this)},c.prototype.outerRadius=function(a,b){return null==a?this._propertyBindings.get(c._OUTER_RADIUS_KEY):(this._bindProperty(c._OUTER_RADIUS_KEY,a,b),this.render(),this)},c.prototype.labelsEnabled=function(a){return null==a?this._labelsEnabled:(this._labelsEnabled=a,this.render(),this)},c.prototype.labelFormatter=function(a){return null==a?this._labelFormatter:(this._labelFormatter=a,this.render(),this)},c.prototype.entitiesAt=function(a){var b={x:this.width()/2,y:this.height()/2},c={x:a.x-b.x,y:a.y-b.y},d=this._sliceIndexForPoint(c);return null==d?[]:[this.entities()[d]]},c.prototype._propertyProjectors=function(){var c=this,d=b.prototype._propertyProjectors.call(this),e=a.Plot._scaledAccessor(this.innerRadius()),f=a.Plot._scaledAccessor(this.outerRadius());return d.d=function(a,b,d){return d3.svg.arc().innerRadius(e(a,b,d)).outerRadius(f(a,b,d)).startAngle(c._startAngles[b]).endAngle(c._endAngles[b])(a,b)},d},c.prototype._updatePieAngles=function(){if(null!=this.sectorValue()&&0!==this.datasets().length){var b=a.Plot._scaledAccessor(this.sectorValue()),c=this.datasets()[0],d=this._getDataToDraw().get(c),e=d3.layout.pie().sort(null).value(function(a,d){return b(a,d,c)})(d);this._startAngles=e.map(function(a){return a.startAngle}),this._endAngles=e.map(function(a){return a.endAngle})}},c.prototype._getDataToDraw=function(){var d=b.prototype._getDataToDraw.call(this);if(0===this.datasets().length)return d;var e=a.Plot._scaledAccessor(this.sectorValue()),f=this.datasets()[0],g=d.get(f),h=g.filter(function(a,b){return c._isValidData(e(a,b,f))});return d.set(f,h),d},c._isValidData=function(b){return a.Utils.Math.isValidNumber(b)&&b>=0},c.prototype._pixelPoint=function(b,d,e){var f=a.Plot._scaledAccessor(this.sectorValue());if(!c._isValidData(f(b,d,e)))return{x:NaN,y:NaN};var g=a.Plot._scaledAccessor(this.innerRadius())(b,d,e),h=a.Plot._scaledAccessor(this.outerRadius())(b,d,e),i=(g+h)/2,j=d3.layout.pie().sort(null).value(function(a,b){var d=f(a,b,e);return c._isValidData(d)?d:0})(e.data()),k=j[d].startAngle,l=j[d].endAngle,m=(k+l)/2;return{x:i*Math.sin(m),y:-i*Math.cos(m)}},c.prototype._additionalPaint=function(b){var c=this;this._renderArea.select(".label-area").remove(),this._labelsEnabled&&a.Utils.Window.setTimeout(function(){return c._drawLabels()},b);var d=this._generateStrokeDrawSteps(),e=this._getDataToDraw();this.datasets().forEach(function(a){ -return c._strokeDrawers.get(a).draw(e.get(a),d)})},c.prototype._generateStrokeDrawSteps=function(){var b=this._generateAttrToProjector();return[{attrToProjector:b,animator:new a.Animators.Null}]},c.prototype._sliceIndexForPoint=function(a){var b=Math.sqrt(Math.pow(a.x,2)+Math.pow(a.y,2)),c=Math.acos(-a.y/b);a.x<0&&(c=2*Math.PI-c);for(var d,e=0;ec){d=e;break}if(void 0!==d){var f=this.datasets()[0],g=f.data()[d],h=this.innerRadius().accessor(g,d,f),i=this.outerRadius().accessor(g,d,f);if(b>h&&i>b)return d}return null},c.prototype._drawLabels=function(){var b=this,c=this._generateAttrToProjector(),d=this._renderArea.append("g").classed("label-area",!0),e=new f.Measurers.Measurer(d),g=new f.Writers.Writer(e),h=this.datasets()[0],i=this._getDataToDraw().get(h);i.forEach(function(f,i){var j=b.sectorValue().accessor(f,i,h);if(a.Utils.Math.isValidNumber(j)){j=b._labelFormatter(j);var k=e.measure(j),l=(b._endAngles[i]+b._startAngles[i])/2,m=b.outerRadius().accessor(f,i,h);b.outerRadius().scale&&(m=b.outerRadius().scale.scale(m));var n=b.innerRadius().accessor(f,i,h);b.innerRadius().scale&&(n=b.innerRadius().scale.scale(n));var o=(m+n)/2,p=Math.sin(l)*o-k.width/2,q=-Math.cos(l)*o-k.height/2,r=[{x:p,y:q},{x:p,y:q+k.height},{x:p+k.width,y:q},{x:p+k.width,y:q+k.height}],s=r.every(function(a){return Math.abs(a.x)<=b.width()/2&&Math.abs(a.y)<=b.height()/2});if(s){var t=r.map(function(a){return b._sliceIndexForPoint(a)});s=t.every(function(a){return a===i})}var u=c.fill(f,i,h),v=1.6*a.Utils.Color.contrast("white",u)n||y.minp)return;if(e._overlayLabel(x,y,k,d,b))return;var z=g.fill(f,k,c),A=1.6*a.Utils.Color.contrast("white",z)=p-i&&q+i>=h)l=0;else{var r=d._isVertical?m.y:m.x;l=Math.abs(h-r)}}(e>k||k===e&&f>l)&&(c=j,e=k,f=l)}}),c},d.prototype._visibleOnPlot=function(b,c,d){a.Utils.Window.deprecated("Bar._visibleOnPlot()","v1.1.0","replaced by _entityVisibleOnPlot()");var e={min:0,max:this.width()},f={min:0,max:this.height()},g=a.Utils.DOM.elementBBox(d);return a.Utils.DOM.intersectsBBox(e,f,g)},d.prototype._entityVisibleOnPlot=function(b,c,d,e){var f={min:0,max:this.width()},g={min:0,max:this.height()},h=this._generateAttrToProjector(),i={x:h.x(c,d,e),y:h.y(c,d,e),width:h.width(c,d,e),height:h.height(c,d,e)};return a.Utils.DOM.intersectsBBox(f,g,i)},d.prototype.entitiesAt=function(a){return this._entitiesIntersecting(a.x,a.y)},d.prototype.entitiesIn=function(a,b){var c,d;if(null==b){var e=a;c={min:e.topLeft.x,max:e.bottomRight.x},d={min:e.topLeft.y,max:e.bottomRight.y}}else c=a,d=b;return this._entitiesIntersecting(c,d)},d.prototype._entitiesIntersecting=function(b,c){var d=[];return this.entities().forEach(function(e){a.Utils.DOM.intersectsBBox(b,c,a.Utils.DOM.elementBBox(e.selection))&&d.push(e)}),d},d.prototype._updateValueScale=function(){if(this._projectorsReady()){var b=this._isVertical?this.y().scale:this.x().scale;if(b instanceof a.QuantitativeScale){var c=b;c.addPaddingExceptionsProvider(this._baselineValueProvider),c.addIncludedValuesProvider(this._baselineValueProvider)}}},d.prototype._additionalPaint=function(b){var c=this,d=this._isVertical?this.y().scale:this.x().scale,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),this.datasets().forEach(function(a){return c._labelConfig.get(a).labelArea.selectAll("g").remove()}),this._labelsEnabled&&a.Utils.Window.setTimeout(function(){return c._drawLabels()},b)},d.prototype._extentsForProperty=function(b){var d,e=this,f=c.prototype._extentsForProperty.call(this,b);if("x"===b&&this._isVertical)d=this.x();else{if("y"!==b||this._isVertical)return f;d=this.y()}if(!(d&&d.scale&&d.scale instanceof a.QuantitativeScale))return f;var g=d.scale;return f=f.map(function(a){return d3.extent([g.invert(g.scale(a[0])-e._barPixelWidth/2),g.invert(g.scale(a[0])+e._barPixelWidth/2),g.invert(g.scale(a[1])-e._barPixelWidth/2),g.invert(g.scale(a[1])+e._barPixelWidth/2)])})},d.prototype._drawLabels=function(){var a=this,b=this._getDataToDraw(),c=!1;this.datasets().forEach(function(d){return c=c||a._drawLabel(b.get(d),d)}),this._hideBarsIfAnyAreTooWide&&c&&this.datasets().forEach(function(b){return a._labelConfig.get(b).labelArea.selectAll("g").remove()})},d.prototype._drawLabel=function(b,c){var e=this,f=this._generateAttrToProjector(),g=this._labelConfig.get(c),h=g.labelArea,i=g.measurer,j=g.writer,k=function(b,g){var k,l=e._isVertical?e.y().accessor:e.x().accessor,m=l(b,g,c),n=e._isVertical?e.y().scale:e.x().scale,o=null!=n?n.scale(m):m,p=null!=n?n.scale(e.baselineValue()):e.baselineValue(),q=f.width(b,g,c),r=f.height(b,g,c),s=e._labelFormatter(l(b,g,c)),t=i.measure(s),u="center",v="center",w={x:f.x(b,g,c),y:f.y(b,g,c)},x=q,y=r,z={x:w.x,y:w.y};if(e._isVertical){z.x+=x/2-t.width/2;var A=f.y(b,g,c),B=r;A+r>e.height()?B=e.height()-A:0>A&&(B=A+r);var C=d._LABEL_VERTICAL_PADDING;k=t.height+2*C<=B,k?p>o?(w.y+=C,v="top",z.y+=C):(w.y-=C,v="bottom",z.y+=y-C-t.height):(y=r+C+t.height,p>=o?(w.y-=C+t.height,v="top",z.y-=C+t.height):(v="bottom",z.y+=r+C))}else{z.y+=y/2-t.height/2;var D=f.x(b,g,c),E=q;D+q>e.width()?E=e.width()-D:0>D&&(E=D+q);var C=d._LABEL_HORIZONTAL_PADDING;k=t.width+2*C<=E,k?p>o?(w.x+=C,u="left",z.x+=C):(w.x-=C,u="right",z.x+=x-C-t.width):(x=q+C+t.width,p>o?(w.x-=C+t.width,u="left",z.x-=C+t.width):(u="right",z.x+=q+C))}var F=h.append("g").attr("transform","translate("+w.x+", "+w.y+")");if(k){F.classed("on-bar-label",!0);var G=f.fill(b,g,c),H=1.6*a.Utils.Color.contrast("white",G)e.width()||z.y+t.height>e.height();F.style("visibility",I?"hidden":"inherit");var J={selection:F,xAlign:u,yAlign:v,textRotation:0};j.write(s,x,y,J);var K=e._isVertical?qg?g:d},b},d.prototype._getBarPixelWidth=function(){if(!this._projectorsReady())return 0;var b,c=this._isVertical?this.x().scale:this.y().scale;if(c instanceof a.Scales.Category)b=c.rangeBand();else{var e=this._isVertical?this.x().accessor:this.y().accessor,f=d3.set(a.Utils.Array.flatten(this.datasets().map(function(a){return a.data().map(function(b,c){return e(b,c,a)}).filter(function(a){return null!=a}).map(function(a){return a.valueOf()})}))).values().map(function(a){return+a});f.sort(function(a,b){return a-b});var g=f.map(function(a){return c.scale(a)}),h=d3.pairs(g),i=this._isVertical?this.width():this.height();b=a.Utils.Math.min(h,function(a,b){return Math.abs(a[1]-a[0])},i*d._SINGLE_BAR_DIMENSION_RATIO),b*=d._BAR_WIDTH_RATIO}return b},d.prototype._updateBarPixelWidth=function(){this._barPixelWidth=this._getBarPixelWidth()},d.prototype.entities=function(a){if(void 0===a&&(a=this.datasets()),!this._projectorsReady())return[];var b=c.prototype.entities.call(this,a);return b},d.prototype._pixelPoint=function(b,c,d){var e,f,g=this._generateAttrToProjector(),h=g.x(b,c,d),i=g.y(b,c,d),j=g.width(b,c,d),k=g.height(b,c,d),l=(this._isVertical?a.Plot._scaledAccessor(this.y()):a.Plot._scaledAccessor(this.x()))(b,c,d),m=(this._isVertical?this.y().scale:this.x().scale).scale(this.baselineValue());return this._isVertical?(e=h+j/2,f=m>=l?i:i+k):(e=l>=m?h+j:h,f=i+k/2),{x:e,y:f}},d.prototype._uninstallScaleForKey=function(a,b){a.offUpdate(this._updateBarPixelWidthCallback),c.prototype._uninstallScaleForKey.call(this,a,b)},d.prototype._getDataToDraw=function(){var b=new a.Utils.Map,c=this._generateAttrToProjector();return this.datasets().forEach(function(d){var e=d.data().filter(function(b,e){return a.Utils.Math.isValidNumber(c.x(b,e,d))&&a.Utils.Math.isValidNumber(c.y(b,e,d))&&a.Utils.Math.isValidNumber(c.width(b,e,d))&&a.Utils.Math.isValidNumber(c.height(b,e,d))});b.set(d,e)}),b},d.ORIENTATION_VERTICAL="vertical",d.ORIENTATION_HORIZONTAL="horizontal",d._BAR_WIDTH_RATIO=.95,d._SINGLE_BAR_DIMENSION_RATIO=.4,d._BAR_AREA_CLASS="bar-area",d._LABEL_AREA_CLASS="bar-label-text-area",d._LABEL_VERTICAL_PADDING=5,d._LABEL_HORIZONTAL_PADDING=5,d}(a.XYPlot);b.Bar=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(){c.call(this),this._interpolator="linear",this._autorangeSmooth=!1,this._croppedRenderingEnabled=!0,this.addClass("line-plot");var d=new a.Animators.Easing;d.stepDuration(a.Plot._ANIMATION_MAX_DURATION),d.easingMode("exp-in-out"),d.maxTotalDuration(a.Plot._ANIMATION_MAX_DURATION),this.animator(b.Animator.MAIN,d),this.attr("stroke",(new a.Scales.Color).range()[0]),this.attr("stroke-width","2px")}return e(d,c),d.prototype.x=function(a,b){return null==a?c.prototype.x.call(this):(null==b?c.prototype.x.call(this,a):c.prototype.x.call(this,a,b),this._setScaleSnapping(),this)},d.prototype.y=function(a,b){return null==a?c.prototype.y.call(this):(c.prototype.y.call(this,a,b),this._setScaleSnapping(),this)},d.prototype.autorangeMode=function(a){return null==a?c.prototype.autorangeMode.call(this):(c.prototype.autorangeMode.call(this,a),this._setScaleSnapping(),this)},d.prototype.autorangeSmooth=function(a){return null==a?this._autorangeSmooth:(this._autorangeSmooth=a,this._setScaleSnapping(),this)},d.prototype._setScaleSnapping=function(){"x"===this.autorangeMode()&&this.x()&&this.x().scale&&this.x().scale instanceof a.QuantitativeScale&&this.x().scale.snappingDomainEnabled(!this.autorangeSmooth()),"y"===this.autorangeMode()&&this.y()&&this.y().scale&&this.y().scale instanceof a.QuantitativeScale&&this.y().scale.snappingDomainEnabled(!this.autorangeSmooth())},d.prototype.interpolator=function(a){return null==a?this._interpolator:(this._interpolator=a,this.render(),this)},d.prototype.croppedRenderingEnabled=function(a){return null==a?this._croppedRenderingEnabled:(this._croppedRenderingEnabled=a,this.render(),this)},d.prototype._createDrawer=function(b){return new a.Drawers.Line(b)},d.prototype._extentsForProperty=function(a){var b=c.prototype._extentsForProperty.call(this,a);if(!this._autorangeSmooth)return b;if(this.autorangeMode()!==a)return b;if("x"!==this.autorangeMode()&&"y"!==this.autorangeMode())return b;var d,e=this._getEdgeIntersectionPoints();return d="y"===this.autorangeMode()?e.left.concat(e.right).map(function(a){return a.y}):e.top.concat(e.bottom).map(function(a){return a.x}),b.map(function(a){return d3.extent(d3.merge([a,d]))})},d.prototype._getEdgeIntersectionPoints=function(){var b=this;if(!(this.y().scale instanceof a.QuantitativeScale&&this.x().scale instanceof a.QuantitativeScale))return{left:[],right:[],top:[],bottom:[]};var c=this.y().scale,d=this.x().scale,e={left:[],right:[],top:[],bottom:[]},f=d.scale(d.domain()[0]),g=d.scale(d.domain()[1]),h=c.scale(c.domain()[0]),i=c.scale(c.domain()[1]); -return this.datasets().forEach(function(a){for(var j,k,l,m,n,o,p,q,r=a.data(),s=1;sn==p>=f&&(j=f-n,k=p-n,m=q-o,l=j*m/k,e.left.push({x:f,y:c.invert(o+l)})),g>n==p>=g&&(j=g-n,k=p-n,m=q-o,l=j*m/k,e.right.push({x:g,y:c.invert(o+l)})),i>o==q>=i&&(k=p-n,l=i-o,m=q-o,j=l*k/m,e.top.push({x:d.invert(n+j),y:i})),h>o==q>=h&&(k=p-n,l=h-o,m=q-o,j=l*k/m,e.bottom.push({x:d.invert(n+j),y:h}))}),e},d.prototype._getResetYFunction=function(){var a=this.y().scale.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.y().scale.scale(d);return function(a,b,c){return e}},d.prototype._generateDrawSteps=function(){var c=[];if(this._animateOnNextRender()){var d=this._generateAttrToProjector();d.d=this._constructLineProjector(a.Plot._scaledAccessor(this.x()),this._getResetYFunction()),c.push({attrToProjector:d,animator:this._getAnimator(b.Animator.RESET)})}return c.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator(b.Animator.MAIN)}),c},d.prototype._generateAttrToProjector=function(){var a=c.prototype._generateAttrToProjector.call(this);return Object.keys(a).forEach(function(b){if("d"!==b){var c=a[b];a[b]=function(a,b,d){return a.length>0?c(a[0],b,d):null}}}),a},d.prototype.entityNearest=function(a){var b,c=this,d=1/0,e=1/0;return this.entities().forEach(function(f){if(c._entityVisibleOnPlot(f.position,f.datum,f.index,f.dataset)){var g=Math.abs(a.x-f.position.x),h=Math.abs(a.y-f.position.y);(d>g||g===d&&e>h)&&(b=f,d=g,e=h)}}),b},d.prototype._propertyProjectors=function(){var b=c.prototype._propertyProjectors.call(this);return b.d=this._constructLineProjector(a.Plot._scaledAccessor(this.x()),a.Plot._scaledAccessor(this.y())),b},d.prototype._constructLineProjector=function(b,c){var d=this,e=function(b,c,e){var f=a.Plot._scaledAccessor(d.x())(b,c,e),g=a.Plot._scaledAccessor(d.y())(b,c,e);return null!=f&&!a.Utils.Math.isNaN(f)&&null!=g&&!a.Utils.Math.isNaN(g)};return function(a,f,g){return d3.svg.line().x(function(a,c){return b(a,c,g)}).y(function(a,b){return c(a,b,g)}).interpolate(d.interpolator()).defined(function(a,b){return e(a,b,g)})(a)}},d.prototype._getDataToDraw=function(){var b=this,c=new a.Utils.Map;return this.datasets().forEach(function(a){var d=a.data();if(!b._croppedRenderingEnabled)return void c.set(a,[d]);var e=d.map(function(a,b){return b});e=b._filterCroppedRendering(a,e),c.set(a,[e.map(function(a,b){return d[a]})])}),c},d.prototype._filterCroppedRendering=function(b,c){for(var d=this,e=a.Plot._scaledAccessor(this.x()),f=a.Plot._scaledAccessor(this.y()),g=b.data(),h=[],i=function(b,c){return a.Utils.Math.inRange(b,0,d.width())&&a.Utils.Math.inRange(c,0,d.height())},j=0;j0},c.prototype._lineIntersectsSegment=function(a,b,c,d){var e=function(a,b,c){return(b.x-a.x)*(c.y-b.y)-(b.y-a.y)*(c.x-b.x)};return e(a,b,c)*e(a,b,d)<0},c._X2_KEY="x2",c._Y2_KEY="y2",c}(a.XYPlot);b.Segment=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this._connectorsEnabled=!1,this.addClass("waterfall-plot")}return e(c,b),c.prototype.connectorsEnabled=function(a){return null==a?this._connectorsEnabled:(this._connectorsEnabled=a,this)},c.prototype.total=function(a){return null==a?this._propertyBindings.get(c._TOTAL_KEY):(this._bindProperty(c._TOTAL_KEY,a,null),this)},c.prototype._additionalPaint=function(b){var c=this;this._connectorArea.selectAll("line").remove(),this._connectorsEnabled&&a.Utils.Window.setTimeout(function(){return c._drawConnectors()},b)},c.prototype._createNodesForDataset=function(a){var d=b.prototype._createNodesForDataset.call(this,a);return this._connectorArea=this._renderArea.append("g").classed(c._CONNECTOR_AREA_CLASS,!0),d},c.prototype._extentsForProperty=function(a){var c="y";return a===c?[this._extent]:b.prototype._extentsForProperty.call(this,a)},c.prototype._generateAttrToProjector=function(){var d=this,e=b.prototype._generateAttrToProjector.call(this),f=this.y().scale,g=a.Plot._scaledAccessor(this.total()),h=this.attr("y");null==h&&(e.y=function(a,b,c){var e=d.y().accessor(a,b,c),h=g(a,b,c);if(h)return Math.min(f.scale(e),f.scale(0));var i=d._subtotals[b];if(0===b)return 0>e?f.scale(i-e):f.scale(i);var j=d._subtotals[b-1];return i>j?f.scale(i):f.scale(j)});var i=this.attr("height");return null==i&&(e.height=function(a,b,c){var e=g(a,b,c),h=d.y().accessor(a,b,c);if(e)return Math.abs(f.scale(h)-f.scale(0));var i=d._subtotals[b];if(0===b)return Math.abs(f.scale(i)-f.scale(i-h));var j=d._subtotals[b-1];return Math.abs(f.scale(i)-f.scale(j))}),e["class"]=function(a,b,e){var f="";null!=d.attr("class")&&(f=d.attr("class").accessor(a,b,e)+" ");var h=g(a,b,e);if(h)return f+c._BAR_TOTAL_CLASS;var i=d.y().accessor(a,b,e);return f+(i>0?c._BAR_GROWTH_CLASS:c._BAR_DECLINE_CLASS)},e},c.prototype._onDatasetUpdate=function(){return this._updateSubtotals(),b.prototype._onDatasetUpdate.call(this),this},c.prototype._calculateSubtotalsAndExtent=function(a){var b=this,c=Number.MAX_VALUE,d=Number.MIN_VALUE,e=0,f=!1;a.data().forEach(function(g,h){var i=b.y().accessor(g,h,a),j=b.total().accessor(g,h,a);if(j&&0!==h||(e+=i),b._subtotals.push(e),c>e&&(c=e),e>d&&(d=e),j&&(c>i&&(c=i),i>d&&(d=i)),!f&&j){for(var k=i-e,l=0;l0&&this._subtotals[d]>this._subtotals[e]||this._subtotals[d]<0&&this._subtotals[d]>=this._subtotals[e])&&(j=a.y(f,d,b)+a.height(f,d,b)),this._connectorArea.append("line").classed(c._CONNECTOR_CLASS,!0).attr("x1",h).attr("x2",i).attr("y1",j).attr("y2",j)}},c.prototype._updateSubtotals=function(){var a=this.datasets();if(a.length>0){var b=a[a.length-1];this._subtotals=new Array,this._calculateSubtotalsAndExtent(b)}},c._BAR_DECLINE_CLASS="waterfall-decline",c._BAR_GROWTH_CLASS="waterfall-growth",c._BAR_TOTAL_CLASS="waterfall-total",c._CONNECTOR_CLASS="connector",c._CONNECTOR_AREA_CLASS="connector-area",c._TOTAL_KEY="total",c}(b.Bar);b.Waterfall=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this.addClass("wheel-plot"),this.attr("fill",(new a.Scales.Color).range()[0])}return e(c,b),c.prototype.computeLayout=function(a,c,d){b.prototype.computeLayout.call(this,a,c,d),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")");var e=Math.min(this.width(),this.height())/2;return null!=this.r()&&null!=this.r().scale&&this.r().scale.range([0,e]),null!=this.r2()&&null!=this.r2().scale&&this.r2().scale.range([0,e]),this},c.prototype._createDrawer=function(b){return new a.Drawers.Arc(b)},c.prototype.entities=function(a){var c=this;void 0===a&&(a=this.datasets());var d=b.prototype.entities.call(this,a);return d.forEach(function(a){a.position.x+=c.width()/2,a.position.y+=c.height()/2}),d},c.prototype._getDataToDraw=function(){var c=b.prototype._getDataToDraw.call(this);if(0===this.datasets().length)return c;var d=a.Plot._scaledAccessor(this.t()),e=a.Plot._scaledAccessor(this.t2()),f=a.Plot._scaledAccessor(this.r()),g=a.Plot._scaledAccessor(this.r2()),h=this.datasets()[0],i=c.get(h),j=i.filter(function(b,c){return a.Utils.Math.isValidNumber(d(b,c,h))&&a.Utils.Math.isValidNumber(e(b,c,h))&&a.Utils.Math.isValidNumber(f(b,c,h))&&a.Utils.Math.isValidNumber(g(b,c,h))&&f(b,c,h)>=0&&g(b,c,h)>=0});return c.set(h,j),c},c.prototype._propertyProjectors=function(){var c=b.prototype._propertyProjectors.call(this),d=a.Plot._scaledAccessor(this.r()),e=a.Plot._scaledAccessor(this.r2()),f=a.Plot._scaledAccessor(this.t()),g=a.Plot._scaledAccessor(this.t2());return c.d=function(b,c,h){var i=f(b,c,h),j=g(b,c,h);return i>j&&(j+=360*(Math.floor((i-j)/360)+1)),d3.svg.arc().innerRadius(d(b,c,h)).outerRadius(e(b,c,h)).startAngle(a.Utils.Math.degreesToRadians(i)).endAngle(a.Utils.Math.degreesToRadians(j))(b,c)},c},c.prototype.t=function(b,d){if(null==b)return this._propertyBindings.get(c._T_KEY);if(null!=d){if(!a.QuantitativeScale.prototype.isPrototypeOf(d))throw new Error("scale needs to inherit from Scale.QuantitativeScale");d.range([0,360]),d.padProportion(0)}var e=this.t2(),f=e&&e.accessor;return null!=f&&this._bindProperty(c._T2_KEY,f,d),this._bindProperty(c._T_KEY,b,d),this.render(),this},c.prototype.t2=function(a){if(null==a)return this._propertyBindings.get(c._T2_KEY);var b=this.t(),d=b&&b.scale;return this._bindProperty(c._T2_KEY,a,d),this.render(),this},c.prototype.r=function(b,d){if(null==b)return this._propertyBindings.get(c._R_KEY);if(null!=d&&!a.QuantitativeScale.prototype.isPrototypeOf(d))throw new Error("scale needs to inherit from Scale.QuantitativeScale");var e=this.r2(),f=e&&e.accessor;return null!=f&&this._bindProperty(c._R2_KEY,f,d),this._bindProperty(c._R_KEY,b,d),this.render(),this},c.prototype.r2=function(a){if(null==a)return this._propertyBindings.get(c._R2_KEY);var b=this.r(),d=b&&b.scale;return this._bindProperty(c._R2_KEY,a,d),this.render(),this},c.prototype._pixelPoint=function(b,c,d){var e=a.Plot._scaledAccessor(this.r())(b,c,d),f=a.Plot._scaledAccessor(this.r2())(b,c,d),g=e>=0&&f>=0?(e+f)/2:NaN,h=a.Plot._scaledAccessor(this.t())(b,c,d),i=a.Plot._scaledAccessor(this.t2())(b,c,d),j=a.Utils.Math.degreesToRadians((h+i)/2);return{x:g*Math.sin(j),y:-g*Math.cos(j)}},c._R_KEY="r",c._R2_KEY="r2",c._T_KEY="t",c._T2_KEY="t2",c}(a.Plot);b.Wheel=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.totalTime=function(a){return 0},a.prototype.animate=function(a,b){return a.attr(b)},a}();a.Null=b}(b=a.Animators||(a.Animators={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function a(){this._startDelay=a._DEFAULT_START_DELAY_MILLISECONDS,this._stepDuration=a._DEFAULT_STEP_DURATION_MILLISECONDS,this._stepDelay=a._DEFAULT_ITERATIVE_DELAY_MILLISECONDS,this._maxTotalDuration=a._DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS,this._easingMode=a._DEFAULT_EASING_MODE}return a.prototype.totalTime=function(a){var b=this._getAdjustedIterativeDelay(a);return this.startDelay()+b*Math.max(a-1,0)+this.stepDuration()},a.prototype.animate=function(a,b){var c=this,d=a[0].length,e=this._getAdjustedIterativeDelay(d);return a.transition().ease(this.easingMode()).duration(this.stepDuration()).delay(function(a,b){return c.startDelay()+e*b}).attr(b)},a.prototype.startDelay=function(a){return null==a?this._startDelay:(this._startDelay=a,this)},a.prototype.stepDuration=function(a){return null==a?Math.min(this._stepDuration,this._maxTotalDuration):(this._stepDuration=a,this)},a.prototype.stepDelay=function(a){return null==a?this._stepDelay:(this._stepDelay=a,this)},a.prototype.maxTotalDuration=function(a){return null==a?this._maxTotalDuration:(this._maxTotalDuration=a,this)},a.prototype.easingMode=function(a){return null==a?this._easingMode:(this._easingMode=a,this)},a.prototype._getAdjustedIterativeDelay=function(a){var b=this.maxTotalDuration()-this.stepDuration();b=Math.max(b,0);var c=b/Math.max(a-1,1);return Math.min(this.stepDelay(),c)},a._DEFAULT_START_DELAY_MILLISECONDS=0,a._DEFAULT_STEP_DURATION_MILLISECONDS=300,a._DEFAULT_ITERATIVE_DELAY_MILLISECONDS=15,a._DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS=1/0,a._DEFAULT_EASING_MODE="exp-out",a}();a.Easing=b}(b=a.Animators||(a.Animators={}))}(d||(d={}));var d;!function(a){var b=function(){function a(){this._eventToCallback={},this._callbacks=[],this._connected=!1}return a.prototype._hasNoListeners=function(){return this._callbacks.every(function(a){return 0===a.size})},a.prototype._connect=function(){var a=this;this._connected||(Object.keys(this._eventToCallback).forEach(function(b){var c=a._eventToCallback[b];document.addEventListener(b,c)}),this._connected=!0)},a.prototype._disconnect=function(){var a=this;this._connected&&this._hasNoListeners()&&(Object.keys(this._eventToCallback).forEach(function(b){var c=a._eventToCallback[b];document.removeEventListener(b,c)}),this._connected=!1)},a.prototype._setCallback=function(a,b){this._connect(),a.add(b)},a.prototype._unsetCallback=function(a,b){a["delete"](b),this._disconnect()},a}();a.Dispatcher=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;b.call(this),this._translator=a.Utils.ClientToSVGTranslator.getTranslator(c),this._lastMousePosition={x:-1,y:-1},this._moveCallbacks=new a.Utils.CallbackSet,this._downCallbacks=new a.Utils.CallbackSet,this._upCallbacks=new a.Utils.CallbackSet,this._wheelCallbacks=new a.Utils.CallbackSet,this._dblClickCallbacks=new a.Utils.CallbackSet,this._callbacks=[this._moveCallbacks,this._downCallbacks,this._upCallbacks,this._wheelCallbacks,this._dblClickCallbacks];var e=function(a){return d._measureAndDispatch(a,d._moveCallbacks,"page")};this._eventToCallback.mouseover=e,this._eventToCallback.mousemove=e,this._eventToCallback.mouseout=e,this._eventToCallback.mousedown=function(a){return d._measureAndDispatch(a,d._downCallbacks)},this._eventToCallback.mouseup=function(a){return d._measureAndDispatch(a,d._upCallbacks,"page")},this._eventToCallback.wheel=function(a){return d._measureAndDispatch(a,d._wheelCallbacks)},this._eventToCallback.dblclick=function(a){return d._measureAndDispatch(a,d._dblClickCallbacks)}}return e(c,b),c.getDispatcher=function(b){var d=a.Utils.DOM.boundingSVG(b),e=d[c._DISPATCHER_KEY];return null==e&&(e=new c(d),d[c._DISPATCHER_KEY]=e),e},c.prototype.onMouseMove=function(a){return this._setCallback(this._moveCallbacks,a),this},c.prototype.offMouseMove=function(a){return this._unsetCallback(this._moveCallbacks,a),this},c.prototype.onMouseDown=function(a){return this._setCallback(this._downCallbacks,a),this},c.prototype.offMouseDown=function(a){return this._unsetCallback(this._downCallbacks,a),this},c.prototype.onMouseUp=function(a){return this._setCallback(this._upCallbacks,a),this},c.prototype.offMouseUp=function(a){return this._unsetCallback(this._upCallbacks,a),this},c.prototype.onWheel=function(a){return this._setCallback(this._wheelCallbacks,a),this},c.prototype.offWheel=function(a){return this._unsetCallback(this._wheelCallbacks,a),this},c.prototype.onDblClick=function(a){return this._setCallback(this._dblClickCallbacks,a),this},c.prototype.offDblClick=function(a){return this._unsetCallback(this._dblClickCallbacks,a),this},c.prototype._measureAndDispatch=function(a,b,c){if(void 0===c&&(c="element"),"page"!==c&&"element"!==c)throw new Error("Invalid scope '"+c+"', must be 'element' or 'page'");if("page"===c||this.eventInsideSVG(a)){var d=this._translator.computePosition(a.clientX,a.clientY);null!=d&&(this._lastMousePosition=d,b.callCallbacks(this.lastMousePosition(),a))}},c.prototype.eventInsideSVG=function(a){return this._translator.insideSVG(a)},c.prototype.lastMousePosition=function(){return this._lastMousePosition},c._DISPATCHER_KEY="__Plottable_Dispatcher_Mouse",c}(a.Dispatcher);b.Mouse=c}(b=a.Dispatchers||(a.Dispatchers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;b.call(this),this._translator=a.Utils.ClientToSVGTranslator.getTranslator(c),this._startCallbacks=new a.Utils.CallbackSet,this._moveCallbacks=new a.Utils.CallbackSet,this._endCallbacks=new a.Utils.CallbackSet,this._cancelCallbacks=new a.Utils.CallbackSet,this._callbacks=[this._moveCallbacks,this._startCallbacks,this._endCallbacks,this._cancelCallbacks],this._eventToCallback.touchstart=function(a){return d._measureAndDispatch(a,d._startCallbacks,"page")},this._eventToCallback.touchmove=function(a){return d._measureAndDispatch(a,d._moveCallbacks,"page"); -},this._eventToCallback.touchend=function(a){return d._measureAndDispatch(a,d._endCallbacks,"page")},this._eventToCallback.touchcancel=function(a){return d._measureAndDispatch(a,d._cancelCallbacks,"page")}}return e(c,b),c.getDispatcher=function(b){var d=a.Utils.DOM.boundingSVG(b),e=d[c._DISPATCHER_KEY];return null==e&&(e=new c(d),d[c._DISPATCHER_KEY]=e),e},c.prototype.onTouchStart=function(a){return this._setCallback(this._startCallbacks,a),this},c.prototype.offTouchStart=function(a){return this._unsetCallback(this._startCallbacks,a),this},c.prototype.onTouchMove=function(a){return this._setCallback(this._moveCallbacks,a),this},c.prototype.offTouchMove=function(a){return this._unsetCallback(this._moveCallbacks,a),this},c.prototype.onTouchEnd=function(a){return this._setCallback(this._endCallbacks,a),this},c.prototype.offTouchEnd=function(a){return this._unsetCallback(this._endCallbacks,a),this},c.prototype.onTouchCancel=function(a){return this._setCallback(this._cancelCallbacks,a),this},c.prototype.offTouchCancel=function(a){return this._unsetCallback(this._cancelCallbacks,a),this},c.prototype._measureAndDispatch=function(a,b,c){if(void 0===c&&(c="element"),"page"!==c&&"element"!==c)throw new Error("Invalid scope '"+c+"', must be 'element' or 'page'");if("element"!==c||this.eventInsideSVG(a)){for(var d=a.changedTouches,e={},f=[],g=0;g0&&b.callCallbacks(f,e,a)}},c.prototype.eventInsideSVG=function(a){return this._translator.insideSVG(a)},c._DISPATCHER_KEY="__Plottable_Dispatcher_Touch",c}(a.Dispatcher);b.Touch=c}(b=a.Dispatchers||(a.Dispatchers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.call(this),this._eventToCallback.keydown=function(a){return c._processKeydown(a)},this._eventToCallback.keyup=function(a){return c._processKeyup(a)},this._keydownCallbacks=new a.Utils.CallbackSet,this._keyupCallbacks=new a.Utils.CallbackSet,this._callbacks=[this._keydownCallbacks,this._keyupCallbacks]}return e(c,b),c.getDispatcher=function(){var a=document[c._DISPATCHER_KEY];return null==a&&(a=new c,document[c._DISPATCHER_KEY]=a),a},c.prototype.onKeyDown=function(a){return this._setCallback(this._keydownCallbacks,a),this},c.prototype.offKeyDown=function(a){return this._unsetCallback(this._keydownCallbacks,a),this},c.prototype.onKeyUp=function(a){return this._setCallback(this._keyupCallbacks,a),this},c.prototype.offKeyUp=function(a){return this._unsetCallback(this._keyupCallbacks,a),this},c.prototype._processKeydown=function(a){this._keydownCallbacks.callCallbacks(a.keyCode,a)},c.prototype._processKeyup=function(a){this._keyupCallbacks.callCallbacks(a.keyCode,a)},c._DISPATCHER_KEY="__Plottable_Dispatcher_Key",c}(a.Dispatcher);b.Key=c}(b=a.Dispatchers||(a.Dispatchers={}))}(d||(d={}));var d;!function(a){var b=function(){function a(){var a=this;this._anchorCallback=function(b){return a._anchor(b)},this._enabled=!0}return a.prototype._anchor=function(a){this._isAnchored=!0},a.prototype._unanchor=function(){this._isAnchored=!1},a.prototype.attachTo=function(a){return this._disconnect(),this._componentAttachedTo=a,this._connect(),this},a.prototype._connect=function(){this.enabled()&&null!=this._componentAttachedTo&&!this._isAnchored&&this._componentAttachedTo.onAnchor(this._anchorCallback)},a.prototype.detachFrom=function(a){return this._disconnect(),this._componentAttachedTo=null,this},a.prototype._disconnect=function(){this._isAnchored&&this._unanchor(),null!=this._componentAttachedTo&&this._componentAttachedTo.offAnchor(this._anchorCallback)},a.prototype.enabled=function(a){return null==a?this._enabled:(this._enabled=a,this._enabled?this._connect():this._disconnect(),this)},a.prototype._translateToComponentSpace=function(a){var b=this._componentAttachedTo.originToSVG();return{x:a.x-b.x,y:a.y-b.y}},a.prototype._isInsideComponent=function(a){return 0<=a.x&&0<=a.y&&a.x<=this._componentAttachedTo.width()&&a.y<=this._componentAttachedTo.height()},a}();a.Interaction=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.apply(this,arguments),this._clickedDown=!1,this._onClickCallbacks=new a.Utils.CallbackSet,this._mouseDownCallback=function(a){return c._handleClickDown(a)},this._mouseUpCallback=function(a){return c._handleClickUp(a)},this._touchStartCallback=function(a,b){return c._handleClickDown(b[a[0]])},this._touchEndCallback=function(a,b){return c._handleClickUp(b[a[0]])},this._touchCancelCallback=function(a,b){return c._clickedDown=!1}}return e(c,b),c.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(c.content().node()),this._mouseDispatcher.onMouseDown(this._mouseDownCallback),this._mouseDispatcher.onMouseUp(this._mouseUpCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(c.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback),this._touchDispatcher.onTouchEnd(this._touchEndCallback),this._touchDispatcher.onTouchCancel(this._touchCancelCallback)},c.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._mouseDispatcher.offMouseDown(this._mouseDownCallback),this._mouseDispatcher.offMouseUp(this._mouseUpCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher.offTouchEnd(this._touchEndCallback),this._touchDispatcher.offTouchCancel(this._touchCancelCallback),this._touchDispatcher=null},c.prototype._handleClickDown=function(a){var b=this._translateToComponentSpace(a);this._isInsideComponent(b)&&(this._clickedDown=!0)},c.prototype._handleClickUp=function(a){var b=this._translateToComponentSpace(a);this._clickedDown&&this._isInsideComponent(b)&&this._onClickCallbacks.callCallbacks(b),this._clickedDown=!1},c.prototype.onClick=function(a){return this._onClickCallbacks.add(a),this},c.prototype.offClick=function(a){return this._onClickCallbacks["delete"](a),this},c}(a.Interaction);b.Click=c}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c;!function(a){a[a.NotClicked=0]="NotClicked",a[a.SingleClicked=1]="SingleClicked",a[a.DoubleClicked=2]="DoubleClicked"}(c||(c={}));var d=function(b){function d(){var d=this;b.apply(this,arguments),this._clickState=c.NotClicked,this._clickedDown=!1,this._onDoubleClickCallbacks=new a.Utils.CallbackSet,this._mouseDownCallback=function(a){return d._handleClickDown(a)},this._mouseUpCallback=function(a){return d._handleClickUp(a)},this._dblClickCallback=function(a){return d._handleDblClick()},this._touchStartCallback=function(a,b){return d._handleClickDown(b[a[0]])},this._touchEndCallback=function(a,b){return d._handleClickUp(b[a[0]])},this._touchCancelCallback=function(a,b){return d._handleClickCancel()}}return e(d,b),d.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(c.content().node()),this._mouseDispatcher.onMouseDown(this._mouseDownCallback),this._mouseDispatcher.onMouseUp(this._mouseUpCallback),this._mouseDispatcher.onDblClick(this._dblClickCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(c.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback),this._touchDispatcher.onTouchEnd(this._touchEndCallback),this._touchDispatcher.onTouchCancel(this._touchCancelCallback)},d.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._mouseDispatcher.offMouseDown(this._mouseDownCallback),this._mouseDispatcher.offMouseUp(this._mouseUpCallback),this._mouseDispatcher.offDblClick(this._dblClickCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher.offTouchEnd(this._touchEndCallback),this._touchDispatcher.offTouchCancel(this._touchCancelCallback),this._touchDispatcher=null},d.prototype._handleClickDown=function(a){var b=this._translateToComponentSpace(a);this._isInsideComponent(b)&&(this._clickState===c.SingleClicked&&d._pointsEqual(b,this._clickedPoint)||(this._clickState=c.NotClicked),this._clickedPoint=b,this._clickedDown=!0)},d.prototype._handleClickUp=function(a){var b=this._translateToComponentSpace(a);this._clickedDown&&d._pointsEqual(b,this._clickedPoint)?this._clickState=this._clickState===c.NotClicked?c.SingleClicked:c.DoubleClicked:this._clickState=c.NotClicked,this._clickedDown=!1},d.prototype._handleDblClick=function(){this._clickState===c.DoubleClicked&&(this._onDoubleClickCallbacks.callCallbacks(this._clickedPoint),this._clickState=c.NotClicked)},d.prototype._handleClickCancel=function(){this._clickState=c.NotClicked,this._clickedDown=!1},d._pointsEqual=function(a,b){return a.x===b.x&&a.y===b.y},d.prototype.onDoubleClick=function(a){return this._onDoubleClickCallbacks.add(a),this},d.prototype.offDoubleClick=function(a){return this._onDoubleClickCallbacks["delete"](a),this},d}(a.Interaction);b.DoubleClick=d}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.apply(this,arguments),this._keyPressCallbacks={},this._keyReleaseCallbacks={},this._mouseMoveCallback=function(a){return!1},this._downedKeys=new a.Utils.Set,this._keyDownCallback=function(a,b){return c._handleKeyDownEvent(a,b)},this._keyUpCallback=function(a){return c._handleKeyUpEvent(a)}}return e(c,b),c.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._positionDispatcher=a.Dispatchers.Mouse.getDispatcher(this._componentAttachedTo._element.node()),this._positionDispatcher.onMouseMove(this._mouseMoveCallback),this._keyDispatcher=a.Dispatchers.Key.getDispatcher(),this._keyDispatcher.onKeyDown(this._keyDownCallback),this._keyDispatcher.onKeyUp(this._keyUpCallback)},c.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._positionDispatcher.offMouseMove(this._mouseMoveCallback),this._positionDispatcher=null,this._keyDispatcher.offKeyDown(this._keyDownCallback),this._keyDispatcher.offKeyUp(this._keyUpCallback),this._keyDispatcher=null},c.prototype._handleKeyDownEvent=function(a,b){var c=this._translateToComponentSpace(this._positionDispatcher.lastMousePosition());this._isInsideComponent(c)&&!b.repeat&&(this._keyPressCallbacks[a]&&this._keyPressCallbacks[a].callCallbacks(a),this._downedKeys.add(a))},c.prototype._handleKeyUpEvent=function(a){this._downedKeys.has(a)&&this._keyReleaseCallbacks[a]&&this._keyReleaseCallbacks[a].callCallbacks(a),this._downedKeys["delete"](a)},c.prototype.onKeyPress=function(b,c){return this._keyPressCallbacks[b]||(this._keyPressCallbacks[b]=new a.Utils.CallbackSet),this._keyPressCallbacks[b].add(c),this},c.prototype.offKeyPress=function(a,b){return this._keyPressCallbacks[a]["delete"](b),0===this._keyPressCallbacks[a].size&&delete this._keyPressCallbacks[a],this},c.prototype.onKeyRelease=function(b,c){return this._keyReleaseCallbacks[b]||(this._keyReleaseCallbacks[b]=new a.Utils.CallbackSet),this._keyReleaseCallbacks[b].add(c),this},c.prototype.offKeyRelease=function(a,b){return this._keyReleaseCallbacks[a]["delete"](b),0===this._keyReleaseCallbacks[a].size&&delete this._keyReleaseCallbacks[a],this},c}(a.Interaction);b.Key=c}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.apply(this,arguments),this._insideComponent=!1,this._pointerEnterCallbacks=new a.Utils.CallbackSet,this._pointerMoveCallbacks=new a.Utils.CallbackSet,this._pointerExitCallbacks=new a.Utils.CallbackSet,this._mouseMoveCallback=function(a,b){return c._handleMouseEvent(a,b)},this._touchStartCallback=function(a,b,d){return c._handleTouchEvent(b[a[0]],d)}}return e(c,b),c.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(this._componentAttachedTo.content().node()),this._mouseDispatcher.onMouseMove(this._mouseMoveCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(this._componentAttachedTo.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback)},c.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._mouseDispatcher.offMouseMove(this._mouseMoveCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher=null},c.prototype._handleMouseEvent=function(a,b){var c=this._mouseDispatcher.eventInsideSVG(b);this._handlePointerEvent(a,c)},c.prototype._handleTouchEvent=function(a,b){var c=this._touchDispatcher.eventInsideSVG(b);this._handlePointerEvent(a,c)},c.prototype._handlePointerEvent=function(a,b){var c=this._translateToComponentSpace(a),d=this._isInsideComponent(c);d&&b?(this._insideComponent||this._pointerEnterCallbacks.callCallbacks(c),this._pointerMoveCallbacks.callCallbacks(c)):this._insideComponent&&this._pointerExitCallbacks.callCallbacks(c),this._insideComponent=d&&b},c.prototype.onPointerEnter=function(a){return this._pointerEnterCallbacks.add(a),this},c.prototype.offPointerEnter=function(a){return this._pointerEnterCallbacks["delete"](a),this},c.prototype.onPointerMove=function(a){return this._pointerMoveCallbacks.add(a),this},c.prototype.offPointerMove=function(a){return this._pointerMoveCallbacks["delete"](a),this},c.prototype.onPointerExit=function(a){return this._pointerExitCallbacks.add(a),this},c.prototype.offPointerExit=function(a){return this._pointerExitCallbacks["delete"](a),this},c}(a.Interaction);b.Pointer=c}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(d,e){var f=this;c.call(this),this._wheelCallback=function(a,b){return f._handleWheelEvent(a,b)},this._touchStartCallback=function(a,b,c){return f._handleTouchStart(a,b,c)},this._touchMoveCallback=function(a,b,c){return f._handlePinch(a,b,c)},this._touchEndCallback=function(a,b,c){return f._handleTouchEnd(a,b,c)},this._touchCancelCallback=function(a,b,c){return f._handleTouchEnd(a,b,c)},this._xScales=new a.Utils.Set,this._yScales=new a.Utils.Set,this._dragInteraction=new b.Drag,this._setupDragInteraction(),this._touchIds=d3.map(),this._minDomainExtents=new a.Utils.Map,this._maxDomainExtents=new a.Utils.Map,null!=d&&this.addXScale(d),null!=e&&this.addYScale(e)}return e(d,c),d.prototype._anchor=function(b){c.prototype._anchor.call(this,b),this._dragInteraction.attachTo(b),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(this._componentAttachedTo.content().node()),this._mouseDispatcher.onWheel(this._wheelCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(this._componentAttachedTo.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback),this._touchDispatcher.onTouchMove(this._touchMoveCallback),this._touchDispatcher.onTouchEnd(this._touchEndCallback),this._touchDispatcher.onTouchCancel(this._touchCancelCallback)},d.prototype._unanchor=function(){c.prototype._unanchor.call(this),this._mouseDispatcher.offWheel(this._wheelCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher.offTouchMove(this._touchMoveCallback),this._touchDispatcher.offTouchEnd(this._touchEndCallback),this._touchDispatcher.offTouchCancel(this._touchCancelCallback),this._touchDispatcher=null,this._dragInteraction.detachFrom(this._componentAttachedTo)},d.prototype._handleTouchStart=function(a,b,c){for(var d=0;d1,d=c?this.maxDomainExtent(a):this.minDomainExtent(a);if(null==d)return b;var e=a.domain(),f=Math.abs(e[1]-e[0]),g=c?Math.min:Math.max;return g(b,d/f)},d.prototype._setupDragInteraction=function(){var a=this;this._dragInteraction.constrainedToComponent(!1);var b;this._dragInteraction.onDragStart(function(){return b=null}),this._dragInteraction.onDrag(function(c,d){if(!(a._touchIds.size()>=2)){var e=(null==b?c.x:b.x)-d.x;a.xScales().forEach(function(b){a._translateScale(b,e)});var f=(null==b?c.y:b.y)-d.y;a.yScales().forEach(function(b){a._translateScale(b,f)}),b=d}})},d.prototype._nonLinearScaleWithExtents=function(b){return!(null==this.minDomainExtent(b)||null==this.maxDomainExtent(b)||b instanceof a.Scales.Linear||b instanceof a.Scales.Time)},d.prototype.xScales=function(b){var c=this;if(null==b){var d=[];return this._xScales.forEach(function(a){d.push(a)}),d}return this._xScales=new a.Utils.Set,b.forEach(function(a){c.addXScale(a)}),this},d.prototype.yScales=function(b){var c=this;if(null==b){var d=[];return this._yScales.forEach(function(a){d.push(a)}),d}return this._yScales=new a.Utils.Set,b.forEach(function(a){c.addYScale(a)}),this},d.prototype.addXScale=function(a){return this._xScales.add(a),this},d.prototype.removeXScale=function(a){return this._xScales["delete"](a),this._minDomainExtents["delete"](a),this._maxDomainExtents["delete"](a),this},d.prototype.addYScale=function(a){return this._yScales.add(a),this},d.prototype.removeYScale=function(a){return this._yScales["delete"](a),this._minDomainExtents["delete"](a),this._maxDomainExtents["delete"](a),this},d.prototype.minDomainExtent=function(b,c){if(null==c)return this._minDomainExtents.get(b);if(c.valueOf()<0)throw new Error("extent must be non-negative");var d=this.maxDomainExtent(b);if(null!=d&&d.valueOf()a)throw new Error("detection radius cannot be negative.");return this._detectionRadius=a,this.render(),this},d.prototype.resizable=function(a){return null==a?this._resizable:(this._resizable=a,this._setResizableClasses(a),this)},d.prototype._setResizableClasses=function(a){a&&this.enabled()?(this.addClass("x-resizable"),this.addClass("y-resizable")):(this.removeClass("x-resizable"),this.removeClass("y-resizable"))},d.prototype.movable=function(a){return null==a?this._movable:(this._movable=a,this._setMovableClass(),this)},d.prototype._setMovableClass=function(){this.movable()&&this.enabled()?this.addClass("movable"):this.removeClass("movable")},d.prototype.onDragStart=function(a){return this._dragStartCallbacks.add(a),this},d.prototype.offDragStart=function(a){return this._dragStartCallbacks["delete"](a),this},d.prototype.onDrag=function(a){return this._dragCallbacks.add(a),this},d.prototype.offDrag=function(a){return this._dragCallbacks["delete"](a),this},d.prototype.onDragEnd=function(a){return this._dragEndCallbacks.add(a),this},d.prototype.offDragEnd=function(a){return this._dragEndCallbacks["delete"](a),this},d.prototype.dragInteraction=function(){return this._dragInteraction},d.prototype.enabled=function(a){return null==a?this._dragInteraction.enabled():(this._dragInteraction.enabled(a),this._setResizableClasses(this.resizable()),this._setMovableClass(),this)},d.prototype.destroy=function(){var a=this;c.prototype.destroy.call(this),this._dragStartCallbacks.forEach(function(b){return a._dragCallbacks["delete"](b)}),this._dragCallbacks.forEach(function(b){return a._dragCallbacks["delete"](b)}),this._dragEndCallbacks.forEach(function(b){return a._dragEndCallbacks["delete"](b)}),this._disconnectInteraction()},d.prototype.detach=function(){return this._resetState(),this._dragInteraction.detachFrom(this),c.prototype.detach.call(this)},d.prototype.anchor=function(a){return this._dragInteraction.attachTo(this),c.prototype.anchor.call(this,a)},d.prototype._resetState=function(){this.bounds({topLeft:{x:0,y:0},bottomRight:{x:0,y:0}})},d}(b.SelectionBoxLayer);b.DragBoxLayer=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.addClass("x-drag-box-layer"), -this._hasCorners=!1}return e(b,a),b.prototype.computeLayout=function(b,c,d){return a.prototype.computeLayout.call(this,b,c,d),this._setBounds(this.bounds()),this},b.prototype._setBounds=function(b){a.prototype._setBounds.call(this,{topLeft:{x:b.topLeft.x,y:0},bottomRight:{x:b.bottomRight.x,y:this.height()}})},b.prototype._setResizableClasses=function(a){a&&this.enabled()?this.addClass("x-resizable"):this.removeClass("x-resizable")},b.prototype.yScale=function(b){if(null==b)return a.prototype.yScale.call(this);throw new Error("yScales cannot be set on an XDragBoxLayer")},b.prototype.yExtent=function(b){if(null==b)return a.prototype.yExtent.call(this);throw new Error("XDragBoxLayer has no yExtent")},b}(a.DragBoxLayer);a.XDragBoxLayer=b}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.addClass("y-drag-box-layer"),this._hasCorners=!1}return e(b,a),b.prototype.computeLayout=function(b,c,d){return a.prototype.computeLayout.call(this,b,c,d),this._setBounds(this.bounds()),this},b.prototype._setBounds=function(b){a.prototype._setBounds.call(this,{topLeft:{x:0,y:b.topLeft.y},bottomRight:{x:this.width(),y:b.bottomRight.y}})},b.prototype._setResizableClasses=function(a){a&&this.enabled()?this.addClass("y-resizable"):this.removeClass("y-resizable")},b.prototype.xScale=function(b){if(null==b)return a.prototype.xScale.call(this);throw new Error("xScales cannot be set on an YDragBoxLayer")},b.prototype.xExtent=function(b){if(null==b)return a.prototype.xExtent.call(this);throw new Error("YDragBoxLayer has no xExtent")},b}(a.DragBoxLayer);a.YDragBoxLayer=b}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;b.call(this,c),this._detectionRadius=3,this._enabled=!0,this.addClass("drag-line-layer"),this.addClass("enabled"),this._dragInteraction=new a.Interactions.Drag,this._dragInteraction.attachTo(this);var e=function(a){return d._isVertical()&&d.pixelPosition()-d.detectionRadius()<=a.x&&a.x<=d.pixelPosition()+d.detectionRadius()||!d._isVertical()&&d.pixelPosition()-d.detectionRadius()<=a.y&&a.y<=d.pixelPosition()+d.detectionRadius()},f=!1,g=function(a){e(a)&&(f=!0,d._dragStartCallbacks.callCallbacks(d))};this._dragInteraction.onDragStart(g);var h=function(a,b){f&&(d._setPixelPositionWithoutChangingMode(d._isVertical()?b.x:b.y),d._dragCallbacks.callCallbacks(d))};this._dragInteraction.onDrag(h);var i=function(a,b){f&&(f=!1,d._dragEndCallbacks.callCallbacks(d))};this._dragInteraction.onDragEnd(i),this._disconnectInteraction=function(){d._dragInteraction.offDragStart(g),d._dragInteraction.offDrag(h),d._dragInteraction.offDragEnd(i),d._dragInteraction.detachFrom(d)},this._dragStartCallbacks=new a.Utils.CallbackSet,this._dragCallbacks=new a.Utils.CallbackSet,this._dragEndCallbacks=new a.Utils.CallbackSet}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this._detectionEdge=this.content().append("line").style({opacity:0,stroke:"pink","pointer-events":"visibleStroke"}).classed("drag-edge",!0)},c.prototype.renderImmediately=function(){return b.prototype.renderImmediately.call(this),this._detectionEdge.attr({x1:this._isVertical()?this.pixelPosition():0,y1:this._isVertical()?0:this.pixelPosition(),x2:this._isVertical()?this.pixelPosition():this.width(),y2:this._isVertical()?this.height():this.pixelPosition(),"stroke-width":2*this._detectionRadius}),this},c.prototype.detectionRadius=function(a){if(null==a)return this._detectionRadius;if(0>a)throw new Error("detection radius cannot be negative.");return this._detectionRadius=a,this.render(),this},c.prototype.enabled=function(a){return null==a?this._enabled:(this._enabled=a,a?this.addClass("enabled"):this.removeClass("enabled"),this._dragInteraction.enabled(a),this)},c.prototype.onDragStart=function(a){return this._dragStartCallbacks.add(a),this},c.prototype.offDragStart=function(a){return this._dragStartCallbacks["delete"](a),this},c.prototype.onDrag=function(a){return this._dragCallbacks.add(a),this},c.prototype.offDrag=function(a){return this._dragCallbacks["delete"](a),this},c.prototype.onDragEnd=function(a){return this._dragEndCallbacks.add(a),this},c.prototype.offDragEnd=function(a){return this._dragEndCallbacks["delete"](a),this},c.prototype.destroy=function(){var a=this;b.prototype.destroy.call(this),this._dragStartCallbacks.forEach(function(b){return a._dragStartCallbacks["delete"](b)}),this._dragCallbacks.forEach(function(b){return a._dragCallbacks["delete"](b)}),this._dragEndCallbacks.forEach(function(b){return a._dragEndCallbacks["delete"](b)}),this._disconnectInteraction()},c}(b.GuideLineLayer);b.DragLineLayer=c}(b=a.Components||(a.Components={}))}(d||(d={}));var f;!function(a){var b;!function(a){var b;!function(a){function b(a,b){if(null==a||null==b)return a===b;if(a.length!==b.length)return!1;for(var c=0;c0&&"\n"===b[0]?"\n":"";if(g>=c){var i=g/3,j=Math.floor(c/i);return{wrappedToken:h+"...".substr(0,j),remainingToken:b}}for(;f+g>c;)e=a.Utils.StringMethods.trimEnd(e.substr(0,e.length-1)),f=d.measure(e).width;return{wrappedToken:h+e+"...",remainingToken:a.Utils.StringMethods.trimEnd(b.substring(e.length),"-").trim()}},b.prototype.wrapNextToken=function(b,c,d){if(!c.canFitText||c.availableLines===c.wrapping.noLines||!this.canFitToken(b,c.availableWidth,d))return this.finishWrapping(b,c,d);for(var e=b;e;){var f=this.breakTokenToFitInWidth(e,c.currentLine,c.availableWidth,d);if(c.currentLine=f.line,e=f.remainingToken,null!=e){if(c.wrapping.noBrokeWords+=+f.breakWord,++c.wrapping.noLines,c.availableLines===c.wrapping.noLines){var g=this.addEllipsis(c.currentLine,c.availableWidth,d);return c.wrapping.wrappedText+=g.wrappedToken,c.wrapping.truncatedText+=g.remainingToken+e,c.currentLine="\n",c}c.wrapping.wrappedText+=a.Utils.StringMethods.trimEnd(c.currentLine),c.currentLine="\n"}}return c},b.prototype.finishWrapping=function(a,b,c){if(b.canFitText&&b.availableLines!==b.wrapping.noLines&&this._allowBreakingWords&&"none"!==this._textTrimming){var d=this.addEllipsis(b.currentLine+a,b.availableWidth,c);b.wrapping.wrappedText+=d.wrappedToken,b.wrapping.truncatedText+=d.remainingToken,b.wrapping.noBrokeWords+=+(d.remainingToken.length0),b.currentLine=""}else b.wrapping.truncatedText+=a;return b.canFitText=!1,b},b.prototype.breakTokenToFitInWidth=function(a,b,c,d,e){if(void 0===e&&(e=this._breakingCharacter),d.measure(b+a).width<=c)return{remainingToken:null,line:b+a,breakWord:!1};if(""===a.trim())return{remainingToken:"",line:b,breakWord:!1};if(!this._allowBreakingWords)return{remainingToken:a,line:b,breakWord:!1};for(var f=0;f0&&(g=e),{remainingToken:a.substring(f),line:b+a.substring(0,f)+g,breakWord:f>0}},b}();b.Wrapper=c}(b=a.Wrappers||(a.Wrappers={}))}(f||(f={}));var f,e=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};!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments)}return e(b,a),b.prototype.wrap=function(c,d,e,f){var g=this;void 0===f&&(f=1/0);var h=c.split("\n");if(h.length>1)throw new Error("SingleLineWrapper is designed to work only on single line");var i=function(b){return a.prototype.wrap.call(g,c,d,b,f)},j=i(e);if(j.noLines<2)return j;for(var k=0,l=e,m=0;mk;++m){var n=(l+k)/2,o=i(n);this.areSameResults(j,o)?(l=n,j=o):k=n}return j},b.prototype.areSameResults=function(a,b){return a.noLines===b.noLines&&a.truncatedText===b.truncatedText},b.NO_WRAP_ITERATIONS=5,b}(a.Wrapper);a.SingleLineWrapper=b}(b=a.Wrappers||(a.Wrappers={}))}(f||(f={}));var f;!function(a){var b;!function(b){var c=function(){function b(a,c){this._writerID=b.nextID++,this._elementID=0,this.measurer(a),c&&this.wrapper(c),this.addTitleElement(!1)}return b.prototype.measurer=function(a){return this._measurer=a,this},b.prototype.wrapper=function(a){return this._wrapper=a,this},b.prototype.addTitleElement=function(a){return this._addTitleElement=a,this},b.prototype.writeLine=function(c,d,e,f,g){var h=d.append("text");h.text(c);var i=e*b.XOffsetFactor[f],j=b.AnchorConverter[f];h.attr("text-anchor",j).classed("text-line",!0),a.Utils.DOM.transform(h,i,g).attr("y","-0.25em")},b.prototype.writeText=function(a,c,d,e,f,g){var h=this,i=a.split("\n"),j=this._measurer.measure().height,k=b.YOffsetFactor[g]*(e-i.length*j);i.forEach(function(a,b){h.writeLine(a,c,d,f,(b+1)*j+k)})},b.prototype.write=function(a,c,d,e){if(-1===b.SupportedRotation.indexOf(e.textRotation))throw new Error("unsupported rotation - "+e.textRotation);var f=Math.abs(Math.abs(e.textRotation)-90)>45,g=f?c:d,h=f?d:c,i=e.selection.append("g").classed("text-container",!0);this._addTitleElement&&i.append("title").text(a);var j=i.append("g").classed("text-area",!0),k=this._wrapper?this._wrapper.wrap(a,this._measurer,g,h).wrappedText:a;this.writeText(k,j,g,h,e.xAlign,e.yAlign);var l=d3.transform(""),m=d3.transform("");switch(l.rotate=e.textRotation,e.textRotation){case 90:l.translate=[c,0],m.rotate=-90,m.translate=[0,200];break;case-90:l.translate=[0,d],m.rotate=90,m.translate=[c,0];break;case 180:l.translate=[c,d],m.translate=[c,d],m.rotate=180}j.attr("transform",l.toString()),this.addClipPath(i,m),e.animator&&e.animator.animate(i)},b.prototype.addClipPath=function(b,c){var d=this._elementID++,e=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;e=e.split("#")[0];var f="clipPath"+this._writerID+"_"+d;b.select(".text-area").attr("clip-path",'url("'+e+"#"+f+'")');var g=b.append("clipPath").attr("id",f),h=a.Utils.DOM.getBBox(b.select(".text-area")),i=g.append("rect");i.classed("clip-rect",!0).attr({x:h.x,y:h.y,width:h.width,height:h.height})},b.nextID=0,b.SupportedRotation=[-90,0,180,90],b.AnchorConverter={left:"start",center:"middle",right:"end"},b.XOffsetFactor={left:0,center:.5,right:1},b.YOffsetFactor={top:0,center:.5,bottom:1},b}();b.Writer=c}(b=a.Writers||(a.Writers={}))}(f||(f={}));var f;!function(a){var b;!function(b){var c=function(){function b(a,b){this.textMeasurer=this.getTextMeasurer(a,b)}return b.prototype.checkSelectionIsText=function(a){return"text"===a[0][0].tagName||!a.select("text").empty()},b.prototype.getTextMeasurer=function(a,b){var c=this;if(this.checkSelectionIsText(a)){var d,e=a.node().parentNode;return d="text"===a[0][0].tagName?a:a.select("text"),a.remove(),function(b){e.appendChild(a.node());var f=c.measureBBox(d,b);return a.remove(),f}}var f=a.append("text");return b&&f.classed(b,!0),f.remove(),function(b){a.node().appendChild(f.node());var d=c.measureBBox(f,b);return f.remove(),d}},b.prototype.measureBBox=function(b,c){b.text(c);var d=a.Utils.DOM.getBBox(b);return{width:d.width,height:d.height}},b.prototype.measure=function(a){return void 0===a&&(a=b.HEIGHT_TEXT),this.textMeasurer(a)},b.HEIGHT_TEXT="bqpdl",b}();b.AbstractMeasurer=c}(b=a.Measurers||(a.Measurers={}))}(f||(f={}));var f,e=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};!function(a){var b;!function(a){var b=function(b){function c(a,c,d){void 0===c&&(c=null),void 0===d&&(d=!1),b.call(this,a,c),this.useGuards=d}return e(c,b),c.prototype._addGuards=function(b){return a.AbstractMeasurer.HEIGHT_TEXT+b+a.AbstractMeasurer.HEIGHT_TEXT},c.prototype.getGuardWidth=function(){return null==this.guardWidth&&(this.guardWidth=b.prototype.measure.call(this).width),this.guardWidth},c.prototype._measureLine=function(a){var c=this.useGuards?this._addGuards(a):a,d=b.prototype.measure.call(this,c);return d.width-=this.useGuards?2*this.getGuardWidth():0,d},c.prototype.measure=function(b){var c=this;if(void 0===b&&(b=a.AbstractMeasurer.HEIGHT_TEXT),""===b.trim())return{width:0,height:0};var d=b.trim().split("\n").map(function(a){return c._measureLine(a)});return{width:d3.max(d,function(a){return a.width}),height:d3.sum(d,function(a){return a.height})}},c}(a.AbstractMeasurer);a.Measurer=b}(b=a.Measurers||(a.Measurers={}))}(f||(f={}));var f,e=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};!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments)}return e(b,a),b.prototype._measureCharacter=function(b){return a.prototype._measureLine.call(this,b)},b.prototype._measureLine=function(a){var b=this,c=a.split("").map(function(a){return b._measureCharacter(a)});return{width:d3.sum(c,function(a){return a.width}),height:d3.max(c,function(a){return a.height})}},b}(a.Measurer);a.CharacterMeasurer=b}(b=a.Measurers||(a.Measurers={}))}(f||(f={}));var f,e=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};return function(a){var b;!function(b){var c=function(b){function c(c,d){var e=this;b.call(this,c,d),this.cache=new a.Utils.Cache(function(a){return e._measureCharacterNotFromCache(a)},a.Utils.Methods.objEq)}return e(c,b),c.prototype._measureCharacterNotFromCache=function(a){return b.prototype._measureCharacter.call(this,a)},c.prototype._measureCharacter=function(a){return this.cache.get(a)},c.prototype.reset=function(){this.cache.clear()},c}(b.CharacterMeasurer);b.CacheCharacterMeasurer=c}(b=a.Measurers||(a.Measurers={}))}(f||(f={})),d}); \ No newline at end of file +!function(a,b){if("object"==typeof exports)module.exports=b(require,exports,module);else if("function"==typeof define&&define.amd)define(["require","exports","module"],b);else{var c=function(b){return a[b]},d=a,e={exports:d};a.Plottable=b(c,d,e)}}(this,function(a,b,c){var d;!function(a){var b;!function(b){var c;!function(b){function c(a,b,c){return l.min(b,c)<=a&&a<=l.max(b,c)}function d(a,b,c){return l.min(l.max(b,a),c)}function e(a,b,c){var d="function"==typeof b?b:null,e=null==d?b:c,f=null==d?d3.max(a):d3.max(a,d);return void 0!==f?f:e}function f(a,b,c){var d="function"==typeof b?b:null,e=null==d?b:c,f=null==d?d3.min(a):d3.min(a,d);return void 0!==f?f:e}function g(a){return a!==a}function h(b){return"number"==typeof b&&!a.Utils.Math.isNaN(b)&&isFinite(b)}function i(a,b,c){if(void 0===c&&(c=1),0===c)throw new Error("step cannot be 0");for(var d=l.max(l.ceil((b-a)/c),0),e=[],f=0;d>f;++f)e[f]=a+c*f;return e}function j(a,b){return l.pow(b.y-a.y,2)+l.pow(b.x-a.x,2)}function k(a){return a/360*l.PI*2}var l=window.Math;b.inRange=c,b.clamp=d,b.max=e,b.min=f,b.isNaN=g,b.isValidNumber=h,b.range=i,b.distanceSquared=j,b.degreesToRadians=k}(c=b.Math||(b.Math={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function b(){"function"==typeof window.Map?this._es6Map=new window.Map:this._keyValuePairs=[]}return b.prototype.set=function(b,c){if(a.Math.isNaN(b))throw new Error("NaN may not be used as a key to the Map");if(null!=this._es6Map)return this._es6Map.set(b,c),this;for(var d=0;d=n.floor(b.right)?!1:n.floor(a.bottom)<=n.ceil(b.top)?!1:n.ceil(a.top)>=n.floor(b.bottom)?!1:!0}function h(a,b){return n.floor(b.left)<=n.ceil(a.left)&&n.floor(b.top)<=n.ceil(a.top)&&n.floor(a.right)<=n.ceil(b.right)&&n.floor(a.bottom)<=n.ceil(b.bottom)}function i(a){var b=a.ownerSVGElement;return null!=b?b:"svg"===a.nodeName.toLowerCase()?a:null}function j(){return"plottableClipPath"+ ++o}function k(a,b,c,d){void 0===d&&(d=.5);var e=l(a),f=l(b);return c.x+c.width>=e.min-d&&c.x<=e.max+d&&c.y+c.height>=f.min-d&&c.y<=f.max+d}function l(a){if("number"==typeof a){var b=a;return{min:b,max:b}}var c=a;if(c instanceof Object&&"min"in c&&"max"in c)return c;throw new Error("input '"+a+"' can't be parsed as an Range")}function m(a,b){var c=a.getPropertyValue(b),d=parseFloat(c);return d||0}var n=window.Math;a.elementBBox=b,a.SCREEN_REFRESH_RATE_MILLISECONDS=1e3/60,a.requestAnimationFramePolyfill=c,a.elementWidth=d,a.elementHeight=e,a.translate=f,a.clientRectsOverlap=g,a.clientRectInside=h,a.boundingSVG=i;var o=0;a.generateUniqueClipPathId=j,a.intersectsBBox=k}(b=a.DOM||(a.DOM={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b;!function(a){function b(a,b){var c=e(a)+.05,d=e(b)+.05;return c>d?c/d:d/c}function c(a,b){var c=d3.hsl(a).brighter(b);return c.rgb().toString()}function d(a,b){a.classed(b,!0);var c=a.style("background-color");if("transparent"===c)return null;var d=/\((.+)\)/.exec(c)[1].split(",").map(function(a){var b=+a,c=b.toString(16);return 16>b?"0"+c:c});if(4===d.length&&"00"===d[3])return null;var e="#"+d.join("");return a.classed(b,!1),e}function e(a){var b=d3.rgb(a),c=function(a){return a/=255,.03928>=a?a/12.92:f.pow((a+.055)/1.055,2.4)},d=c(b.r),e=c(b.g),g=c(b.b);return.2126*d+.7152*e+.0722*g}var f=window.Math;a.contrast=b,a.lightenColor=c,a.colorTest=d}(b=a.Color||(a.Color={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b;!function(a){function b(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 c(a){var b=d3.set(),c=[];return a.forEach(function(a){b.has(String(a))||(b.add(String(a)),c.push(a))}),c}function d(a){return f.prototype.concat.apply([],a)}function e(a,b){for(var c=[],d=0;b>d;d++)c[d]="function"==typeof a?a(d):a;return c}var f=window.Array;a.add=b,a.uniq=c,a.flatten=d,a.createFilledArray=e}(b=a.Array||(a.Array={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments)}return e(b,a),b.prototype.callCallbacks=function(){for(var a=this,b=[],c=0;c=0?f:g;m.has(k)?(j=m.get(k),m.set(k,j+l)):(j=0,m.set(k,l)),i.set(k,{value:l,offset:j})}),h.set(b,i)}),h}function d(b,c,d){var g=[];b.forEach(function(a,b){b.data().forEach(function(f,h){if(null==d||d(f,h,b)){var i=a.get(e(c(f,h,b)));g.push(i.value+i.offset)}})});var h=a.Math.max(g,0),i=a.Math.min(g,0);return[f.min(i,0),f.max(0,h)]}function e(a){return String(a)}var f=window.Math;b.stack=c,b.stackedExtent=d,b.normalizeKey=e}(b=a.Stacking||(a.Stacking={}))}(b=a.Utils||(a.Utils={}))}(d||(d={}));var d;!function(a){var b;!function(b){var c;!function(c){function d(b){a.Configs.SHOW_WARNINGS&&null!=window.console&&(null!=window.console.warn?console.warn(b):null!=window.console.log&&console.log(b))}function e(a,b){for(var c=[],d=2;da&&(b="-"+b)),b}}function d(a){return void 0===a&&(a=3),m(a),function(b){return b.toFixed(a)}}function e(a){return void 0===a&&(a=3),m(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),m(a),function(b){return d3.format("."+a+"s")(b)}}function i(a){void 0===a&&(a=3),m(a);var b="KMBTQ",c=d3.format("."+a+"e"),d=d3.format("."+a+"f"),e=Math.pow(10,3*(b.length+1)),f=Math.pow(10,-a);return function(a){var g=Math.abs(a);if((f>g||g>=e)&&0!==g)return c(a);for(var h=-1;g>=Math.pow(1e3,h+2)&&h0&&"1000"===i.substr(0,4)||0>a&&"-1000"===i.substr(0,5))&&(hd;d++)if(b[d].filter(c))return d3.time.format(b[d].format)(c)}}function k(a){return d3.time.format(a)}function l(b,c,d){return void 0===b&&(b=0),void 0===c&&(c=a.MILLISECONDS_IN_ONE_DAY),void 0===d&&(d=""),a.Utils.Window.deprecated("relativeDate()","v1.3.0","Not safe for use with time zones."),function(a){var e=Math.round((a.valueOf()-b)/c);return e.toString()+d}}function m(a){if(0>a||a>20)throw new RangeError("Formatter precision must be between 0 and 20");if(a!==Math.floor(a))throw new RangeError("Formatter precision must be an integer")}b.currency=c,b.fixed=d,b.general=e,b.identity=f,b.percentage=g,b.siSuffix=h,b.shortScale=i,b.multiTime=j,b.time=k,b.relativeDate=l}(b=a.Formatters||(a.Formatters={}))}(d||(d={}));var d;!function(a){var b;!function(a){function b(){return function(a){return d3.svg.symbol().type("circle").size(Math.PI*Math.pow(a/2,2))(null)}}function c(){return function(a){return d3.svg.symbol().type("square").size(Math.pow(a,2))(null)}}function d(){return function(a){return d3.svg.symbol().type("cross").size(5/9*Math.pow(a,2))(null)}}function e(){return function(a){return d3.svg.symbol().type("diamond").size(Math.tan(Math.PI/6)*Math.pow(a,2)/2)(null)}}function f(){return function(a){return d3.svg.symbol().type("triangle-up").size(Math.sqrt(3)*Math.pow(a/2,2))(null)}}function g(){return function(a){return d3.svg.symbol().type("triangle-down").size(Math.sqrt(3)*Math.pow(a/2,2))(null)}}a.circle=b,a.square=c,a.cross=d,a.diamond=e,a.triangleUp=f,a.triangleDown=g}(b=a.SymbolFactories||(a.SymbolFactories={}))}(d||(d={}));var d;!function(a){var b=function(){function b(){this._autoDomainAutomatically=!0,this._domainModificationInProgress=!1,this._callbacks=new a.Utils.CallbackSet,this._includedValuesProviders=new a.Utils.Set}return b.prototype.extentOfValues=function(a){return[]},b.prototype._getAllIncludedValues=function(){var a=this,b=[];return this._includedValuesProviders.forEach(function(c){var d=c(a);b=b.concat(d)}),b},b.prototype._getExtent=function(){return[]},b.prototype.onUpdate=function(a){return this._callbacks.add(a),this},b.prototype.offUpdate=function(a){return this._callbacks["delete"](a),this},b.prototype._dispatchUpdate=function(){this._callbacks.callCallbacks(this)},b.prototype.autoDomain=function(){return this._autoDomainAutomatically=!0,this._setDomain(this._getExtent()),this},b.prototype._autoDomainIfAutomaticMode=function(){this._autoDomainAutomatically&&this.autoDomain()},b.prototype.scale=function(a){throw new Error("Subclasses should override scale")},b.prototype.domain=function(a){return null==a?this._getDomain():(this._autoDomainAutomatically=!1,this._setDomain(a),this)},b.prototype._getDomain=function(){throw new Error("Subclasses should override _getDomain")},b.prototype._setDomain=function(a){this._domainModificationInProgress||(this._domainModificationInProgress=!0,this._setBackingScaleDomain(a),this._dispatchUpdate(),this._domainModificationInProgress=!1)},b.prototype._setBackingScaleDomain=function(a){throw new Error("Subclasses should override _setBackingDomain")},b.prototype.range=function(a){return null==a?this._getRange():(this._setRange(a),this)},b.prototype._getRange=function(){throw new Error("Subclasses should override _getRange")},b.prototype._setRange=function(a){throw new Error("Subclasses should override _setRange")},b.prototype.addIncludedValuesProvider=function(a){return this._includedValuesProviders.add(a),this._autoDomainIfAutomaticMode(),this},b.prototype.removeIncludedValuesProvider=function(a){return this._includedValuesProviders["delete"](a),this._autoDomainIfAutomaticMode(),this},b}();a.Scale=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b=function(b){function c(){b.call(this),this._tickGenerator=function(a){return a.defaultTicks()},this._padProportion=.05,this._snappingDomainEnabled=!0,this._paddingExceptionsProviders=new a.Utils.Set}return e(c,b),c.prototype.autoDomain=function(){return this._domainMin=null,this._domainMax=null,b.prototype.autoDomain.call(this),this},c.prototype._autoDomainIfAutomaticMode=function(){if(null!=this._domainMin&&null!=this._domainMax)return void this._setDomain([this._domainMin,this._domainMax]);var a=this._getExtent();if(null!=this._domainMin){var c=a[1];return this._domainMin>=c&&(c=this._expandSingleValueDomain([this._domainMin,this._domainMin])[1]),void this._setDomain([this._domainMin,c])}if(null!=this._domainMax){var d=a[0];return this._domainMax<=d&&(d=this._expandSingleValueDomain([this._domainMax,this._domainMax])[0]),void this._setDomain([d,this._domainMax])}b.prototype._autoDomainIfAutomaticMode.call(this)},c.prototype._getExtent=function(){var b=this._getAllIncludedValues(),c=this._defaultExtent();if(0!==b.length){var d=[a.Utils.Math.min(b,c[0]),a.Utils.Math.max(b,c[1])];c=this._padDomain(d)}return null!=this._domainMin&&(c[0]=this._domainMin),null!=this._domainMax&&(c[1]=this._domainMax),c},c.prototype.addPaddingExceptionsProvider=function(a){return this._paddingExceptionsProviders.add(a),this._autoDomainIfAutomaticMode(),this},c.prototype.removePaddingExceptionsProvider=function(a){return this._paddingExceptionsProviders["delete"](a),this._autoDomainIfAutomaticMode(),this},c.prototype.padProportion=function(a){if(null==a)return this._padProportion;if(0>a)throw new Error("padProportion must be non-negative");return this._padProportion=a,this._autoDomainIfAutomaticMode(),this},c.prototype._padDomain=function(a){var b=this;if(a[0].valueOf()===a[1].valueOf())return this._expandSingleValueDomain(a);if(0===this._padProportion)return a;var c=this._padProportion/2,d=a[0],e=a[1],f=!1,g=!1;this._paddingExceptionsProviders.forEach(function(a){var c=a(b);c.forEach(function(a){a.valueOf()===d.valueOf()&&(f=!0),a.valueOf()===e.valueOf()&&(g=!0)})});var h=f?d:this.invert(this.scale(d)-(this.scale(e)-this.scale(d))*c),i=g?e:this.invert(this.scale(e)+(this.scale(e)-this.scale(d))*c);return this._snappingDomainEnabled?this._niceDomain([h,i]):[h,i]},c.prototype.snappingDomainEnabled=function(a){return null==a?this._snappingDomainEnabled:(this._snappingDomainEnabled=a,this._autoDomainIfAutomaticMode(),this)},c.prototype._expandSingleValueDomain=function(a){return a},c.prototype.invert=function(a){throw new Error("Subclasses should override invert")},c.prototype.domain=function(a){return null!=a&&(this._domainMin=a[0],this._domainMax=a[1]),b.prototype.domain.call(this,a)},c.prototype.domainMin=function(a){return null==a?this.domain()[0]:(this._domainMin=a,this._autoDomainIfAutomaticMode(),this)},c.prototype.domainMax=function(a){return null==a?this.domain()[1]:(this._domainMax=a,this._autoDomainIfAutomaticMode(),this)},c.prototype.extentOfValues=function(b){var c=d3.extent(b.filter(function(b){return a.Utils.Math.isValidNumber(+b)}));return null==c[0]||null==c[1]?[]:c},c.prototype._setDomain=function(c){var d=function(b){return a.Utils.Math.isNaN(b)||b===1/0||b===-(1/0)};return d(c[0])||d(c[1])?void a.Utils.Window.warn("Warning: QuantitativeScales cannot take NaN or Infinity as a domain value. Ignoring."):void b.prototype._setDomain.call(this,c)},c.prototype.defaultTicks=function(){throw new Error("Subclasses should override _getDefaultTicks")},c.prototype.ticks=function(){return this._tickGenerator(this)},c.prototype._niceDomain=function(a,b){throw new Error("Subclasses should override _niceDomain")},c.prototype._defaultExtent=function(){throw new Error("Subclasses should override _defaultExtent")},c.prototype.tickGenerator=function(a){return null==a?this._tickGenerator:(this._tickGenerator=a,this)},c._DEFAULT_NUM_TICKS=10,c}(a.Scale);a.QuantitativeScale=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function c(){a.call(this),this._d3Scale=d3.scale.linear()}return e(c,a),c.prototype._defaultExtent=function(){return[0,1]},c.prototype._expandSingleValueDomain=function(a){return a[0]===a[1]?[a[0]-1,a[1]+1]:a},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setBackingScaleDomain=function(a){this._d3Scale.domain(a)},c.prototype._getRange=function(){return this._d3Scale.range()},c.prototype._setRange=function(a){this._d3Scale.range(a)},c.prototype.invert=function(a){return this._d3Scale.invert(a)},c.prototype.defaultTicks=function(){return this._d3Scale.ticks(b.Linear._DEFAULT_NUM_TICKS)},c.prototype._niceDomain=function(a,b){return this._d3Scale.copy().domain(a).nice(b).domain()},c}(a.QuantitativeScale);b.Linear=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(a){if(void 0===a&&(a=10),c.call(this),this._d3Scale=d3.scale.linear(),this._base=a,this._pivot=this._base,this._setDomain(this._defaultExtent()),1>=a)throw new Error("ModifiedLogScale: The base must be > 1")}return e(d,c),d.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=b&&c>=a}),n=m.sort(function(a,b){return a-b});return n},d.prototype._howManyTicks=function(c,d){var e=this._adjustedLog(a.Utils.Math.min(this._untransformedDomain,0)),f=this._adjustedLog(a.Utils.Math.max(this._untransformedDomain,0)),g=this._adjustedLog(c),h=this._adjustedLog(d),i=(h-g)/(f-e),j=Math.ceil(i*b.ModifiedLog._DEFAULT_NUM_TICKS);return j},d.prototype._niceDomain=function(a,b){return a},d.prototype._defaultExtent=function(){return[0,this._base]},d.prototype._expandSingleValueDomain=function(a){if(a[0]===a[1]){var b=a[0];return b>0?[b/this._base,b*this._base]:0===b?[-this._base,this._base]:[b*this._base,b/this._base]}return a},d.prototype._getRange=function(){return this._d3Scale.range()},d.prototype._setRange=function(a){this._d3Scale.range(a)},d.prototype.defaultTicks=function(){return this._d3Scale.ticks(b.ModifiedLog._DEFAULT_NUM_TICKS)},d}(a.QuantitativeScale);b.ModifiedLog=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this._range=[0,1],this._d3Scale=d3.scale.ordinal();var a=.3;this._innerPadding=c._convertToPlottableInnerPadding(a),this._outerPadding=c._convertToPlottableOuterPadding(.5,a)}return e(c,b),c.prototype.extentOfValues=function(b){return a.Utils.Array.uniq(b)},c.prototype._getExtent=function(){return a.Utils.Array.uniq(this._getAllIncludedValues())},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){if(null==a)return this._range;this._range=a;var b=1-1/(1+this.innerPadding()),c=this.outerPadding()/(1+this.innerPadding());return this._d3Scale.rangeBands(a,b,c),this},c._convertToPlottableInnerPadding=function(a){return 1/(1-a)-1},c._convertToPlottableOuterPadding=function(a,b){return a/(1-b)},c.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},c.prototype.stepWidth=function(){return this.rangeBand()*(1+this.innerPadding())},c.prototype.innerPadding=function(a){return null==a?this._innerPadding:(this._innerPadding=a,this.range(this.range()),this._dispatchUpdate(),this)},c.prototype.outerPadding=function(a){return null==a?this._outerPadding:(this._outerPadding=a,this.range(this.range()),this._dispatchUpdate(),this)},c.prototype.scale=function(a){return this._d3Scale(a)+this.rangeBand()/2},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setBackingScaleDomain=function(a){this._d3Scale.domain(a)},c.prototype._getRange=function(){return this._d3Scale.range()},c.prototype._setRange=function(a){this._d3Scale.range(a)},c}(a.Scale);b.Category=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a){b.call(this);var d;switch(a){case null:case void 0:null==c._plottableColorCache&&(c._plottableColorCache=c._getPlottableColors()),d=d3.scale.ordinal().range(c._plottableColorCache);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")}this._d3Scale=d}return e(c,b),c.prototype.extentOfValues=function(b){return a.Utils.Array.uniq(b)},c.prototype._getExtent=function(){return a.Utils.Array.uniq(this._getAllIncludedValues())},c.invalidateColorCache=function(){c._plottableColorCache=null},c._getPlottableColors=function(){for(var b,c=[],d=d3.select("body").append("plottable-color-tester"),e=a.Utils.Color.colorTest(d,""),f=0;null!==(b=a.Utils.Color.colorTest(d,"plottable-colors-"+f))&&f0&&this._setDomain([a.Utils.Math.min(b,0),a.Utils.Math.max(b,0)]),this},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setBackingScaleDomain=function(a){this._d3Scale.domain(a)},c.prototype._getRange=function(){return this._colorRange},c.prototype._setRange=function(a){this._colorRange=a,this._resetScale()},c.REDS=["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],c.BLUES=["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],c.POSNEG=["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],c}(a.Scale);b.InterpolatedColor=c}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d;!function(a){var b;!function(b){var c;!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.Utils.Math.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.defaultTicks();return b.filter(function(a,c){return a%1===0||0===c||c===b.length-1})}}b.intervalTickGenerator=c,b.integerTickGenerator=d}(c=b.TickGenerators||(b.TickGenerators={}))}(b=a.Scales||(a.Scales={}))}(d||(d={}));var d;!function(a){var b=function(){function b(a){this._cachedSelectionValid=!1,this._dataset=a}return b.prototype.renderArea=function(a){return null==a?this._renderArea:(this._renderArea=a,this._cachedSelectionValid=!1,this)},b.prototype.remove=function(){null!=this.renderArea()&&this.renderArea().remove()},b.prototype._bindSelectionData=function(a){var b=this.selection().data(a);b.enter().append(this._svgElementName),b.exit().remove(),this._applyDefaultAttributes(b)},b.prototype._applyDefaultAttributes=function(a){null!=this._className&&a.classed(this._className,!0)},b.prototype._drawStep=function(a){var b=this.selection(),c=["fill","stroke"];c.forEach(function(c){null!=a.attrToAppliedProjector[c]&&b.attr(c,a.attrToAppliedProjector[c])}),a.animator.animate(b,a.attrToAppliedProjector),null!=this._className&&this.selection().classed(this._className,!0)},b.prototype._appliedProjectors=function(a){var b=this,c={};return Object.keys(a).forEach(function(d){c[d]=function(c,e){return a[d](c,e,b._dataset)}}),c},b.prototype.totalDrawTime=function(a,b){var c=0;return b.forEach(function(b,d){c+=b.animator.totalTime(a.length)}),c},b.prototype.draw=function(b,c){var d=this,e=c.map(function(a){var b=d._appliedProjectors(a.attrToProjector);return{attrToAppliedProjector:b,animator:a.animator}});this._bindSelectionData(b),this._cachedSelectionValid=!1;var f=0;return e.forEach(function(c,e){a.Utils.Window.setTimeout(function(){return d._drawStep(c)},f),f+=c.animator.totalTime(b.length)}),this},b.prototype.selection=function(){return this._cachedSelectionValid||(this._cachedSelection=this.renderArea().selectAll(this.selector()),this._cachedSelectionValid=!0),this._cachedSelection},b.prototype.selector=function(){return this._svgElementName},b.prototype.selectionForIndex=function(a){return d3.select(this.selection()[0][a])},b}();a.Drawer=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="line",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("fill","none")},b.prototype.selectionForIndex=function(a){return d3.select(this.selection()[0][0])},b}(a.Drawer);b.Line=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="area",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("stroke","none")},b.prototype.selectionForIndex=function(a){return d3.select(this.selection()[0][0])},b}(a.Drawer);b.Area=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._svgElementName="rect"}return e(b,a),b}(a.Drawer);b.Rectangle=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="arc fill",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("stroke","none")},b}(a.Drawer);b.Arc=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._className="arc outline",this._svgElementName="path"}return e(b,a),b.prototype._applyDefaultAttributes=function(b){a.prototype._applyDefaultAttributes.call(this,b),b.style("fill","none")},b}(a.Drawer);b.ArcOutline=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._svgElementName="path",this._className="symbol"}return e(b,a),b}(a.Drawer);b.Symbol=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b),this._svgElementName="line"}return e(b,a),b}(a.Drawer);b.Segment=c}(b=a.Drawers||(a.Drawers={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function a(){}return a.TOP="top",a.BOTTOM="bottom",a.LEFT="left",a.RIGHT="right",a.CENTER="center",a}();a.Alignment=b}(b=a.Components||(a.Components={}));var c=function(){function b(){this._clipPathEnabled=!1,this._origin={x:0,y:0},this._xAlignment="left",this._yAlignment="top",this._isSetup=!1,this._isAnchored=!1,this._boxes=[],this._isTopLevelComponent=!1,this._cssClasses=new a.Utils.Set,this._destroyed=!1,this._onAnchorCallbacks=new a.Utils.CallbackSet,this._onDetachCallbacks=new a.Utils.CallbackSet,this._cssClasses.add("component")}return b.prototype.anchor=function(a){if(this._destroyed)throw new Error("Can't reuse destroy()-ed Components!");return"svg"===a.node().nodeName.toLowerCase()&&(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,this._onAnchorCallbacks.callCallbacks(this),this},b.prototype.onAnchor=function(a){return this._isAnchored&&a(this),this._onAnchorCallbacks.add(a),this},b.prototype.offAnchor=function(a){return this._onAnchorCallbacks["delete"](a),this},b.prototype._setup=function(){var b=this;this._isSetup||(this._cssClasses.forEach(function(a){b._element.classed(a,!0)}),this._cssClasses=new a.Utils.Set,this._backgroundContainer=this._element.append("g").classed("background-container",!0),this._addBox("background-fill",this._backgroundContainer),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._boundingBox=this._addBox("bounding-box"),this._isSetup=!0)},b.prototype.requestedSpace=function(a,b){return{minWidth:0,minHeight:0}},b.prototype.computeLayout=function(c,d,e){var f=this;if(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");c={x:0,y: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.Utils.DOM.elementWidth(g),e=a.Utils.DOM.elementHeight(g)}var h=this._sizeFromOffer(d,e);this._width=h.width,this._height=h.height;var i=b._xAlignToProportion[this._xAlignment],j=b._yAlignToProportion[this._yAlignment];return this._origin={x:c.x+(d-this.width())*i,y:c.y+(e-this.height())*j},this._element.attr("transform","translate("+this._origin.x+","+this._origin.y+")"),this._boxes.forEach(function(a){return a.attr("width",f.width()).attr("height",f.height())}),this},b.prototype._sizeFromOffer=function(a,b){var c=this.requestedSpace(a,b);return{width:this.fixedWidth()?Math.min(a,c.minWidth):a,height:this.fixedHeight()?Math.min(b,c.minHeight):b}},b.prototype.render=function(){return this._isAnchored&&this._isSetup&&this.width()>=0&&this.height()>=0&&a.RenderController.registerToRender(this),this},b.prototype._scheduleComputeLayout=function(){this._isAnchored&&this._isSetup&&a.RenderController.registerToComputeLayout(this)},b.prototype.renderImmediately=function(){return this._clipPathEnabled&&this._updateClipPath(),this},b.prototype.redraw=function(){return this._isAnchored&&this._isSetup&&(this._isTopLevelComponent?this._scheduleComputeLayout():this.parent().redraw()),this},b.prototype.renderTo=function(b){if(this.detach(),null!=b){var c;if(c="string"==typeof b?d3.select(b):b instanceof Element?d3.select(b):b,!c.node()||"svg"!==c.node().nodeName.toLowerCase())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.RenderController.flush(),this},b.prototype.xAlignment=function(a){if(null==a)return this._xAlignment;if(a=a.toLowerCase(),null==b._xAlignToProportion[a])throw new Error("Unsupported alignment: "+a);return this._xAlignment=a,this.redraw(),this},b.prototype.yAlignment=function(a){if(null==a)return this._yAlignment;if(a=a.toLowerCase(),null==b._yAlignToProportion[a])throw new Error("Unsupported alignment: "+a);return this._yAlignment=a,this.redraw(),this},b.prototype._addBox=function(a,b){if(null==this._element)throw new Error("Adding boxes before anchoring is currently disallowed");b=null==b?this._boxContainer:b;var 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},b.prototype._generateClipPath=function(){this._clipPathID=a.Utils.DOM.generateUniqueClipPathId();var b=this._boxContainer.append("clipPath").attr("id",this._clipPathID);this._addBox("clip-rect",b),this._updateClipPath()},b.prototype._updateClipPath=function(){var a=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;a=a.split("#")[0],this._element.attr("clip-path",'url("'+a+"#"+this._clipPathID+'")')},b.prototype.hasClass=function(a){return null==a?!1:null==this._element?this._cssClasses.has(a):this._element.classed(a)},b.prototype.addClass=function(a){return null==a?this:(null==this._element?this._cssClasses.add(a):this._element.classed(a,!0),this)},b.prototype.removeClass=function(a){return null==a?this:(null==this._element?this._cssClasses["delete"](a):this._element.classed(a,!1),this)},b.prototype.fixedWidth=function(){return!1},b.prototype.fixedHeight=function(){return!1},b.prototype.detach=function(){return this.parent(null),this._isAnchored&&this._element.remove(),this._isAnchored=!1,this._onDetachCallbacks.callCallbacks(this),this},b.prototype.onDetach=function(a){return this._onDetachCallbacks.add(a),this},b.prototype.offDetach=function(a){return this._onDetachCallbacks["delete"](a),this},b.prototype.parent=function(a){if(void 0===a)return this._parent;if(null!==a&&!a.has(this))throw new Error("Passed invalid parent");return this._parent=a,this},b.prototype.destroy=function(){this._destroyed=!0,this.detach()},b.prototype.width=function(){return this._width},b.prototype.height=function(){return this._height},b.prototype.origin=function(){return{x:this._origin.x,y:this._origin.y}},b.prototype.originToSVG=function(){for(var a=this.origin(),b=this.parent();null!=b;){var c=b.origin();a.x+=c.x,a.y+=c.y,b=b.parent()}return a},b.prototype.foreground=function(){return this._foregroundContainer},b.prototype.content=function(){return this._content},b.prototype.background=function(){return this._backgroundContainer},b._xAlignToProportion={left:0,center:.5,right:1},b._yAlignToProportion={top:0,center:.5,bottom:1},b}();a.Component=c}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b=function(a){function b(){var b=this;a.call(this),this._detachCallback=function(a){return b.remove(a)}}return e(b,a),b.prototype.anchor=function(b){var c=this;return a.prototype.anchor.call(this,b),this._forEach(function(a){return a.anchor(c.content())}),this},b.prototype.render=function(){return this._forEach(function(a){return a.render()}),this},b.prototype.has=function(a){throw new Error("has() is not implemented on ComponentContainer")},b.prototype._adoptAndAnchor=function(a){a.parent(this),a.onDetach(this._detachCallback),this._isAnchored&&a.anchor(this.content())},b.prototype.remove=function(a){return this.has(a)&&(a.offDetach(this._detachCallback),this._remove(a),a.detach(),this.redraw()),this},b.prototype._remove=function(a){return!1},b.prototype._forEach=function(a){throw new Error("_forEach() is not implemented on ComponentContainer")},b.prototype.destroy=function(){a.prototype.destroy.call(this),this._forEach(function(a){return a.destroy()})},b}(a.Component);a.ComponentContainer=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this._components=[],this.addClass("component-group"),a.forEach(function(a){return c.append(a)})}return e(c,b),c.prototype._forEach=function(a){this.components().forEach(a)},c.prototype.has=function(a){return this._components.indexOf(a)>=0},c.prototype.requestedSpace=function(b,c){var d=this._components.map(function(a){return a.requestedSpace(b,c)});return{minWidth:a.Utils.Math.max(d,function(a){return a.minWidth},0),minHeight:a.Utils.Math.max(d,function(a){return a.minHeight},0)}},c.prototype.computeLayout=function(a,c,d){var e=this;return b.prototype.computeLayout.call(this,a,c,d),this._forEach(function(a){a.computeLayout({x:0,y:0},e.width(),e.height())}),this},c.prototype._sizeFromOffer=function(a,b){return{width:a,height:b}},c.prototype.fixedWidth=function(){return this._components.every(function(a){return a.fixedWidth()})},c.prototype.fixedHeight=function(){return this._components.every(function(a){return a.fixedHeight()})},c.prototype.components=function(){return this._components.slice()},c.prototype.append=function(a){return null==a||this.has(a)||(a.detach(),this._components.push(a),this._adoptAndAnchor(a),this.redraw()),this},c.prototype._remove=function(a){var b=this._components.indexOf(a);return b>=0?(this._components.splice(b,1),!0):!1},c}(a.ComponentContainer);b.Group=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b=function(b){function c(c,d){var e=this;if(b.call(this),this._endTickLength=5,this._innerTickLength=5,this._tickLabelPadding=10,this._margin=15,this._showEndTickLabels=!1,this._annotationsEnabled=!1,this._annotationTierCount=1,null==c||null==d)throw new Error("Axis requires a scale and orientation");this._scale=c,this.orientation(d),this._setDefaultAlignment(),this.addClass("axis"),this._isHorizontal()?this.addClass("x-axis"):this.addClass("y-axis"),this.formatter(a.Formatters.identity()),this._rescaleCallback=function(a){return e._rescale()},this._scale.onUpdate(this._rescaleCallback),this._annotatedTicks=[],this._annotationFormatter=a.Formatters.identity()}return e(c,b),c.prototype.destroy=function(){b.prototype.destroy.call(this),this._scale.offUpdate(this._rescaleCallback)},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 d=0,e=0;if(this._isHorizontal()){if(e=this._computeHeight()+this._margin,this.annotationsEnabled()){var f=this._annotationMeasurer.measure().height+2*c._ANNOTATION_LABEL_PADDING;e+=f*this.annotationTierCount()}}else if(d=this._computeWidth()+this._margin,this.annotationsEnabled()){var f=this._annotationMeasurer.measure().height+2*c._ANNOTATION_LABEL_PADDING;d+=f*this.annotationTierCount()}return{minWidth:d,minHeight:e}},c.prototype.fixedHeight=function(){return this._isHorizontal()},c.prototype.fixedWidth=function(){return!this._isHorizontal()},c.prototype._rescale=function(){this.render()},c.prototype.computeLayout=function(a,c,d){return b.prototype.computeLayout.call(this,a,c,d),this._isHorizontal()?this._scale.range([0,this.width()]):this._scale.range([this.height(),0]),this},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),this._annotationContainer=this.content().append("g").classed("annotation-container",!0),this._annotationContainer.append("g").classed("annotation-line-container",!0),this._annotationContainer.append("g").classed("annotation-circle-container",!0),this._annotationContainer.append("g").classed("annotation-rect-container",!0);var a=this._annotationContainer.append("g").classed("annotation-label-container",!0);this._annotationMeasurer=new f.Measurers.Measurer(a),this._annotationWriter=new f.Writers.Writer(this._annotationMeasurer)},c.prototype._getTickValues=function(){return[]},c.prototype.renderImmediately=function(){var a=this._getTickValues(),b=this._tickMarkContainer.selectAll("."+c.TICK_MARK_CLASS).data(a);return 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()),this.annotationsEnabled()?this._drawAnnotations():this._removeAnnotations(),this},c.prototype.annotatedTicks=function(a){return null==a?this._annotatedTicks:(this._annotatedTicks=a,this.render(),this)},c.prototype.annotationFormatter=function(a){return null==a?this._annotationFormatter:(this._annotationFormatter=a,this.render(),this)},c.prototype.annotationsEnabled=function(a){return null==a?this._annotationsEnabled:(this._annotationsEnabled=a,this.redraw(),this)},c.prototype.annotationTierCount=function(a){if(null==a)return this._annotationTierCount;if(0>a)throw new Error("annotationTierCount cannot be negative");return this._annotationTierCount=a,this.redraw(),this},c.prototype._drawAnnotations=function(){var b=this,d=c._ANNOTATION_LABEL_PADDING,e=new a.Utils.Map,f=this._annotatedTicksToRender();f.forEach(function(a){var c=b._annotationMeasurer.measure(b.annotationFormatter()(a)),f={width:c.width+2*d,height:c.height+2*d};e.set(a,f)});var g=this._annotationMeasurer.measure().height+2*d,h=this._annotationToTier(e),i=new a.Utils.Set,j=this._isHorizontal()?this.height():this.width(),k=this._coreSize(),l=Math.min(this.annotationTierCount(),Math.floor((j-k)/g));h.forEach(function(a,b){(-1===a||a>=l)&&i.add(b)});var m,n=function(a,b,c){var d=a.selectAll("."+c).data(f);return d.enter().append(b).classed(c,!0),d.exit().remove(),d},o=function(a){switch(b.orientation()){case"bottom":case"right":return h.get(a)*g+k;case"top":case"left":return j-k-h.get(a)*g}},p=function(a){return b._scale.scale(a)},q=function(a){return i.has(a)?"hidden":"visible"};switch(this.orientation()){case"bottom":case"right":m=0;break;case"top":m=this.height();break;case"left":m=this.width()}var r=this._isHorizontal();n(this._annotationContainer.select(".annotation-line-container"),"line",c.ANNOTATION_LINE_CLASS).attr({x1:r?p:m,x2:r?p:o,y1:r?m:p,y2:r?o:p,visibility:q}),n(this._annotationContainer.select(".annotation-circle-container"),"circle",c.ANNOTATION_CIRCLE_CLASS).attr({cx:r?p:m,cy:r?m:p,r:3});var s=function(a){switch(b.orientation()){case"bottom":case"right":return o(a);case"top":case"left":return o(a)-e.get(a).height}};n(this._annotationContainer.select(".annotation-rect-container"),"rect",c.ANNOTATION_RECT_CLASS).attr({x:r?p:s,y:r?s:p,width:r?function(a){return e.get(a).width}:function(a){return e.get(a).height},height:r?function(a){return e.get(a).height}:function(a){return e.get(a).width},visibility:q});var t=this._annotationWriter,u=this.annotationFormatter(),v=n(this._annotationContainer.select(".annotation-label-container"),"g",c.ANNOTATION_LABEL_CLASS);v.selectAll(".text-container").remove(),v.attr({transform:function(a){var b=r?p(a):s(a),c=r?s(a):p(a);return"translate("+b+","+c+")"},visibility:q}).each(function(a){var b={selection:d3.select(this),xAlign:"center",yAlign:"center",textRotation:r?0:90};t.write(u(a),r?e.get(a).width:e.get(a).height,r?e.get(a).height:e.get(a).width,b)})},c.prototype._annotatedTicksToRender=function(){var b=this,c=this._scale.range();return a.Utils.Array.uniq(this.annotatedTicks().filter(function(d){return null==d?!1:a.Utils.Math.inRange(b._scale.scale(d),c[0],c[1])}))},c.prototype._coreSize=function(){var a=this._isHorizontal()?this.height():this.width(),b=this._isHorizontal()?this._computeHeight():this._computeWidth();return Math.min(b,a)},c.prototype._annotationTierHeight=function(){return this._annotationMeasurer.measure().height+2*c._ANNOTATION_LABEL_PADDING},c.prototype._annotationToTier=function(b){var c=this,d=[[]],e=new a.Utils.Map,f=this._isHorizontal()?this.width():this.height();return this._annotatedTicksToRender().forEach(function(a){var g=c._scale.scale(a),h=b.get(a).width;if(0>g||g+h>f)return void e.set(a,-1);for(var i=function(a){return d[a].some(function(a){var d=c._scale.scale(a),e=b.get(a).width;return g+h>=d&&d+e>=g})},j=0;i(j);)j++,d.length===j&&d.push([]);d[j].push(a),e.set(a,j)}),e},c.prototype._removeAnnotations=function(){this._annotationContainer.selectAll(".annotation-line").remove(),this._annotationContainer.selectAll(".annotation-circle").remove(),this._annotationContainer.selectAll(".annotation-rect").remove(),this._annotationContainer.selectAll(".annotation-label").remove()},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._innerTickLength;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._setDefaultAlignment=function(){switch(this._orientation){case"bottom":this.yAlignment("top");break;case"top":this.yAlignment("bottom");break;case"left":this.xAlignment("right");break;case"right":this.xAlignment("left")}},c.prototype.formatter=function(a){return null==a?this._formatter:(this._formatter=a,this.redraw(),this)},c.prototype.tickLength=function(b){return a.Utils.Window.deprecated("tickLength()","v1.3.0","Replaced by innerTickLength()"),this.innerTickLength(b)},c.prototype.innerTickLength=function(a){if(null==a)return this._innerTickLength;if(0>a)throw new Error("inner tick length must be positive");return this._innerTickLength=a,this.redraw(),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.redraw(),this},c.prototype._maxLabelTickLength=function(){return this.showEndTickLabels()?Math.max(this.innerTickLength(),this.endTickLength()):this.innerTickLength()},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.redraw(),this},c.prototype.margin=function(a){if(null==a)return this._margin;if(0>a)throw new Error("margin size must be positive");return this._margin=a,this.redraw(),this},c.prototype.orientation=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.redraw(),this},c.prototype.showEndTickLabels=function(a){return null==a?this._showEndTickLabels:(this._showEndTickLabels=a,this.render(),this)},c.END_TICK_MARK_CLASS="end-tick-mark",c.TICK_MARK_CLASS="tick-mark",c.TICK_LABEL_CLASS="tick-label",c.ANNOTATION_LINE_CLASS="annotation-line",c.ANNOTATION_RECT_CLASS="annotation-rect",c.ANNOTATION_CIRCLE_CLASS="annotation-circle",c.ANNOTATION_LABEL_CLASS="annotation-label",c._ANNOTATION_LABEL_PADDING=4,c}(a.Component);a.Axis=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){a.second="second",a.minute="minute",a.hour="hour",a.day="day",a.week="week",a.month="month",a.year="year"}(b=a.TimeInterval||(a.TimeInterval={}));var c;!function(c){var d=function(c){function d(b,e){c.call(this,b,e),this._tierLabelPositions=[],this.addClass("time-axis"),this.tickLabelPadding(5),this.axisConfigurations(d._DEFAULT_TIME_AXIS_CONFIGURATIONS),this.annotationFormatter(a.Formatters.time("%a %b %d, %Y"))}return e(d,c),d.prototype.tierLabelPositions=function(a){if(null==a)return this._tierLabelPositions;if(!a.every(function(a){return"between"===a.toLowerCase()||"center"===a.toLowerCase()}))throw new Error("Unsupported position for tier labels");return this._tierLabelPositions=a,this.redraw(),this},d.prototype.axisConfigurations=function(b){if(null==b)return this._possibleTimeAxisConfigurations;this._possibleTimeAxisConfigurations=b,this._numTiers=a.Utils.Math.max(this._possibleTimeAxisConfigurations.map(function(a){return a.length}),0),this._isAnchored&&this._setupDomElements();for(var c=this.tierLabelPositions(),d=[],e=0;ed&&a.every(function(a){return b._checkTimeAxisTierConfigurationWidth(a)})&&(c=d)}),c===this._possibleTimeAxisConfigurations.length&&(a.Utils.Window.warn("zoomed out too far: could not find suitable interval to display labels"),--c),c},d.prototype.orientation=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.orientation.call(this,a)},d.prototype._computeHeight=function(){var a=this._measurer.measure().height;this._tierHeights=[];for(var b=0;bthis._scale.domain()[1])return this.width();var f=Math.abs(this._scale.scale(e)-this._scale.scale(c));return f},d.prototype._maxWidthForInterval=function(a){return this._measurer.measure(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._sizeFromOffer=function(a,b){var d=c.prototype._sizeFromOffer.call(this,a,b),e=this._tierHeights.reduce(function(a,b,c,e){ +return a+b>d.height?a:a+b}),f=this.margin()+(this.annotationsEnabled()?this.annotationTierCount()*this._annotationTierHeight():0);return d.height=Math.min(d.height,e+f),d},d.prototype._setup=function(){c.prototype._setup.call(this),this._setupDomElements()},d.prototype._setupDomElements=function(){this.content().selectAll("."+d.TIME_AXIS_TIER_CLASS).remove(),this._tierLabelContainers=[],this._tierMarkContainers=[],this._tierBaselines=[],this._tickLabelContainer.remove(),this._baseline.remove();for(var b=0;b=f.length||g.push(new Date((f[b+1].valueOf()-f[b].valueOf())/2+f[b].valueOf()))}):g=f;var h=b.selectAll("."+a.Axis.TICK_LABEL_CLASS).data(g,function(a){return String(a.valueOf())}),i=h.enter().append("g").classed(a.Axis.TICK_LABEL_CLASS,!0);i.append("text");var j,k="center"===this._tierLabelPositions[d]||1===c.step?0:this.tickLabelPadding();j="bottom"===this.orientation()?d3.sum(this._tierHeights.slice(0,d+1))-this.tickLabelPadding():"center"===this._tierLabelPositions[d]?this.height()-d3.sum(this._tierHeights.slice(0,d))-this.tickLabelPadding()-this._maxLabelTickLength():this.height()-d3.sum(this._tierHeights.slice(0,d))-this.tickLabelPadding();var l=h.selectAll("text");l.size()>0&&a.Utils.DOM.translate(l,k,j),h.exit().remove(),h.attr("transform",function(a){return"translate("+e._scale.scale(a)+",0)"});var m="center"===this._tierLabelPositions[d]||1===c.step?"middle":"start";h.selectAll("text").text(c.formatter).style("text-anchor",m)},d.prototype._renderTickMarks=function(b,c){var d=this._tierMarkContainers[c].selectAll("."+a.Axis.TICK_MARK_CLASS).data(b);d.enter().append("line").classed(a.Axis.TICK_MARK_CLASS,!0);var e=this._generateTickMarkAttrHash(),f=this._tierHeights.slice(0,c).reduce(function(a,b){return a+b},0);"bottom"===this.orientation()?(e.y1=f,e.y2=f+("center"===this._tierLabelPositions[c]?this.innerTickLength():this._tierHeights[c])):(e.y1=this.height()-f,e.y2=this.height()-(f+("center"===this._tierLabelPositions[c]?this.innerTickLength():this._tierHeights[c]))),d.attr(e),"bottom"===this.orientation()?(e.y1=f,e.y2=f+("center"===this._tierLabelPositions[c]?this.endTickLength():this._tierHeights[c])):(e.y1=this.height()-f,e.y2=this.height()-(f+("center"===this._tierLabelPositions[c]?this.endTickLength():this._tierHeights[c]))),d3.select(d[0][0]).attr(e),d3.select(d[0][d.size()-1]).attr(e),d3.select(d[0][0]).classed(a.Axis.END_TICK_MARK_CLASS,!0),d3.select(d[0][d.size()-1]).classed(a.Axis.END_TICK_MARK_CLASS,!0),d.exit().remove()},d.prototype._renderLabellessTickMarks=function(b){var c=this._tickMarkContainer.selectAll("."+a.Axis.TICK_MARK_CLASS).data(b);c.enter().append("line").classed(a.Axis.TICK_MARK_CLASS,!0);var d=this._generateTickMarkAttrHash();d.y2="bottom"===this.orientation()?this.tickLabelPadding():this.height()-this.tickLabelPadding(),c.attr(d),c.exit().remove()},d.prototype._generateLabellessTicks=function(){return this._mostPreciseConfigIndex<1?[]:this._getTickIntervalValues(this._possibleTimeAxisConfigurations[this._mostPreciseConfigIndex-1][0])},d.prototype.renderImmediately=function(){var a=this;this._mostPreciseConfigIndex=this._getMostPreciseConfigurationIndex();var b=this._possibleTimeAxisConfigurations[this._mostPreciseConfigIndex];this._cleanTiers(),b.forEach(function(b,c){return a._renderTierLabels(a._tierLabelContainers[c],b,c)});for(var c=b.map(function(b,c){return a._getTickValuesForConfiguration(b)}),d=0,e=0;e=i&&(g=this._generateLabellessTicks()),this._renderLabellessTickMarks(g),this._hideOverflowingTiers();for(var e=0;e=c?"inherit":"hidden"})},d.prototype._hideOverlappingAndCutOffLabels=function(b){var c,d=this,e=this._boundingBox.node().getBoundingClientRect(),f=function(a){return Math.floor(e.left)<=Math.ceil(a.left)&&Math.floor(e.top)<=Math.ceil(a.top)&&Math.floor(a.right)<=Math.ceil(e.left+d.width())&&Math.floor(a.bottom)<=Math.ceil(e.top+d.height())},g=this._tierMarkContainers[b].selectAll("."+a.Axis.TICK_MARK_CLASS).filter(function(a,b){var c=d3.select(this).style("visibility");return"visible"===c||"inherit"===c}),h=g[0].map(function(a){return a.getBoundingClientRect()}),i=this._tierLabelContainers[b].selectAll("."+a.Axis.TICK_LABEL_CLASS).filter(function(a,b){var c=d3.select(this).style("visibility");return"visible"===c||"inherit"===c});i.each(function(b,d){var e=this.getBoundingClientRect(),g=d3.select(this),i=h[d],j=h[d+1],k=null!=c&&a.Utils.DOM.clientRectsOverlap(e,c),l=null!=i&&a.Utils.DOM.clientRectsOverlap(e,i),m=null!=j&&a.Utils.DOM.clientRectsOverlap(e,j);!f(e)||k||l||m?g.style("visibility","hidden"):(c=e,g.style("visibility","inherit"))})},d.TIME_AXIS_TIER_CLASS="time-axis-tier",d._DEFAULT_TIME_AXIS_CONFIGURATIONS=[[{interval:b.second,step:1,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:5,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:10,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:15,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.second,step:30,formatter:a.Formatters.time("%I:%M:%S %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:1,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:5,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:10,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:15,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.minute,step:30,formatter:a.Formatters.time("%I:%M %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:1,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:3,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:6,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.hour,step:12,formatter:a.Formatters.time("%I %p")},{interval:b.day,step:1,formatter:a.Formatters.time("%B %e, %Y")}],[{interval:b.day,step:1,formatter:a.Formatters.time("%a %e")},{interval:b.month,step:1,formatter:a.Formatters.time("%B %Y")}],[{interval:b.day,step:1,formatter:a.Formatters.time("%e")},{interval:b.month,step:1,formatter:a.Formatters.time("%B %Y")}],[{interval:b.month,step:1,formatter:a.Formatters.time("%B")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.month,step:1,formatter:a.Formatters.time("%b")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.month,step:3,formatter:a.Formatters.time("%b")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.month,step:6,formatter:a.Formatters.time("%b")},{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:1,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:1,formatter:a.Formatters.time("%y")}],[{interval:b.year,step:5,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:25,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:50,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:100,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:200,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:500,formatter:a.Formatters.time("%Y")}],[{interval:b.year,step:1e3,formatter:a.Formatters.time("%Y")}]],d._LONG_DATE=new Date(9999,8,29,12,59,9999),d}(a.Axis);c.Time=d}(c=a.Axes||(a.Axes={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this._tickLabelPositioning="center",this._usesTextWidthApproximation=!1,this.formatter(a.Formatters.general())}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this._measurer=new f.Measurers.Measurer(this._tickLabelContainer,a.Axis.TICK_LABEL_CLASS),this._wrapper=(new f.Wrappers.Wrapper).maxLines(1)},c.prototype._computeWidth=function(){var a=this._usesTextWidthApproximation?this._computeApproximateTextWidth():this._computeExactTextWidth();return"center"===this._tickLabelPositioning?this._computedWidth=this._maxLabelTickLength()+this.tickLabelPadding()+a:this._computedWidth=Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+a),this._computedWidth},c.prototype._computeExactTextWidth=function(){var b=this,c=this._getTickValues(),d=c.map(function(a){var c=b.formatter()(a);return b._measurer.measure(c).width});return a.Utils.Math.max(d,0)},c.prototype._computeApproximateTextWidth=function(){var b=this,c=this._getTickValues(),d=this._measurer.measure("M").width,e=c.map(function(a){var c=b.formatter()(a);return c.length*d});return a.Utils.Math.max(e,0)},c.prototype._computeHeight=function(){var a=this._measurer.measure().height;return"center"===this._tickLabelPositioning?this._computedHeight=this._maxLabelTickLength()+this.tickLabelPadding()+a:this._computedHeight=Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+a),this._computedHeight},c.prototype._getTickValues=function(){var a=this._scale,b=a.domain(),c=b[0]<=b[1]?b[0]:b[1],d=b[0]>=b[1]?b[0]:b[1];return c===b[0]?a.ticks().filter(function(a){return a>=c&&d>=a}):a.ticks().filter(function(a){return a>=c&&d>=a}).reverse()},c.prototype._rescale=function(){if(this._isSetup){if(!this._isHorizontal()){var a=this._computeWidth();if(a>this.width()||a=f.left)return!1}else if(e.top-c<=f.bottom)return!1}return!0},c}(a.Axis);b.Numeric=c}(b=a.Axes||(a.Axes={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a,c){b.call(this,a,c),this._tickLabelAngle=0,this.addClass("category-axis")}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this._measurer=new f.Measurers.CacheCharacterMeasurer(this._tickLabelContainer),this._wrapper=new f.Wrappers.SingleLineWrapper,this._writer=new f.Writers.Writer(this._measurer,this._wrapper)},c.prototype._rescale=function(){return this.redraw()},c.prototype.requestedSpace=function(a,b){var c=this._isHorizontal()?0:this._maxLabelTickLength()+this.tickLabelPadding()+this.margin(),d=this._isHorizontal()?this._maxLabelTickLength()+this.tickLabelPadding()+this.margin():0;if(0===this._scale.domain().length)return{minWidth:0,minHeight:0};if(this.annotationsEnabled()){var e=this._annotationTierHeight()*this.annotationTierCount();this._isHorizontal()?d+=e:c+=e}var f=this._scale,g=this._measureTicks(a,b,f,f.domain());return{minWidth:g.usedWidth+c,minHeight:g.usedHeight+d}},c.prototype._coreSize=function(){var a=this._isHorizontal()?this.height():this.width(),b=this._isHorizontal()?this.requestedSpace(this.width(),this.height()).minHeight:this.requestedSpace(this.width(),this.height()).minWidth,c=this.margin()+this._annotationTierHeight(),d=b-c;return Math.min(d,a)},c.prototype._getTickValues=function(){return this._scale.domain()},c.prototype.tickLabelAngle=function(a){if(null==a)return this._tickLabelAngle;if(0!==a&&90!==a&&-90!==a)throw new Error("Angle "+a+" not supported; only 0, 90, and -90 are valid values");return this._tickLabelAngle=a,this.redraw(),this},c.prototype._drawTicks=function(a,b,c,d){var e,f,g=this;switch(this.tickLabelAngle()){case 0:e={left:"right",right:"left",top:"center",bottom:"center"},f={left:"center",right:"center",top:"bottom",bottom:"top"};break;case 90:e={left:"center",right:"center",top:"right",bottom:"left"},f={left:"top",right:"bottom",top:"center",bottom:"center"};break;case-90:e={left:"center",right:"center",top:"left",bottom:"right"},f={left:"bottom",right:"top",top:"center",bottom:"center"}}d.each(function(d){var h=c.stepWidth(),i=g._isHorizontal()?h:a-g._maxLabelTickLength()-g.tickLabelPadding(),j=g._isHorizontal()?b-g._maxLabelTickLength()-g.tickLabelPadding():h,k={selection:d3.select(this),xAlign:e[g.orientation()],yAlign:f[g.orientation()],textRotation:g.tickLabelAngle()};g._writer.write(g.formatter()(d),i,j,k)})},c.prototype._measureTicks=function(b,c,d,e){var g=this,h=this._isHorizontal()?b:c,i=2*d.outerPadding(),j=(e.length-1)*d.innerPadding(),k=h/(i+j+e.length),l=k*(1+d.innerPadding()),m=e.map(function(a){var d=b-g._maxLabelTickLength()-g.tickLabelPadding();g._isHorizontal()&&(d=l,0!==g._tickLabelAngle&&(d=c-g._maxLabelTickLength()-g.tickLabelPadding()),d=Math.max(d,0));var e=l;return g._isHorizontal()&&(e=c-g._maxLabelTickLength()-g.tickLabelPadding(),0!==g._tickLabelAngle&&(e=b-g._maxLabelTickLength()-g.tickLabelPadding()),e=Math.max(e,0)),g._wrapper.wrap(g.formatter()(a),g._measurer,d,e)}),n=this._isHorizontal()&&0===this._tickLabelAngle?d3.sum:a.Utils.Math.max,o=this._isHorizontal()&&0===this._tickLabelAngle?a.Utils.Math.max:d3.sum,p=m.every(function(a){return!f.Utils.StringMethods.isNotEmptyString(a.truncatedText)&&1===a.noLines}),q=n(m,function(a){return g._measurer.measure(a.wrappedText).width},0),r=o(m,function(a){return g._measurer.measure(a.wrappedText).height},0);if(0!==this._tickLabelAngle){var s=r;r=q,q=s}return{textFits:p,usedWidth:q,usedHeight:r}},c.prototype.renderImmediately=function(){var c=this;b.prototype.renderImmediately.call(this);var d=this._scale,e=this._tickLabelContainer.selectAll("."+a.Axis.TICK_LABEL_CLASS).data(this._scale.domain(),function(a){return a}),f=function(a,b){var e=d.stepWidth()-d.rangeBand(),f=d.scale(a)-d.rangeBand()/2-e/2,g=c._isHorizontal()?f:0,h=c._isHorizontal()?0:f;return"translate("+g+","+h+")"};e.enter().append("g").classed(a.Axis.TICK_LABEL_CLASS,!0),e.exit().remove(),e.attr("transform",f),e.text(""),this._drawTicks(this.width(),this.height(),d,e);var g="right"===this.orientation()?this._maxLabelTickLength()+this.tickLabelPadding():0,h="bottom"===this.orientation()?this._maxLabelTickLength()+this.tickLabelPadding():0;return a.Utils.DOM.translate(this._tickLabelContainer,g,h),this},c.prototype.computeLayout=function(a,c,d){return this._measurer.reset(),b.prototype.computeLayout.call(this,a,c,d)},c}(a.Axis);b.Category=c}(b=a.Axes||(a.Axes={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(a){function b(b,c){void 0===b&&(b=""),void 0===c&&(c=0),a.call(this),this.addClass("label"),this.text(b),this.angle(c),this.xAlignment("center").yAlignment("center"),this._padding=0}return e(b,a),b.prototype.requestedSpace=function(a,b){var c=this._measurer.measure(this._text),d=(0===this.angle()?c.width:c.height)+2*this.padding(),e=(0===this.angle()?c.height:c.width)+2*this.padding();return{minWidth:d,minHeight:e}},b.prototype._setup=function(){a.prototype._setup.call(this),this._textContainer=this.content().append("g"),this._measurer=new f.Measurers.Measurer(this._textContainer),this._wrapper=new f.Wrappers.Wrapper,this._writer=new f.Writers.Writer(this._measurer,this._wrapper),this.text(this._text)},b.prototype.text=function(a){if(null==a)return this._text;if("string"!=typeof a)throw new Error("Label.text() only takes strings as input");return this._text=a,this.redraw(),this},b.prototype.angle=function(a){if(null==a)return this._angle;if(a%=360,a>180?a-=360:-180>a&&(a+=360),-90!==a&&0!==a&&90!==a)throw new Error(a+" is not a valid angle for Label");return this._angle=a,this.redraw(),this},b.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.redraw(),this},b.prototype.fixedWidth=function(){return!0},b.prototype.fixedHeight=function(){return!0},b.prototype.renderImmediately=function(){a.prototype.renderImmediately.call(this),this._textContainer.selectAll("g").remove();var b=this._measurer.measure(this._text),c=Math.max(Math.min((this.height()-b.height)/2,this.padding()),0),d=Math.max(Math.min((this.width()-b.width)/2,this.padding()),0);this._textContainer.attr("transform","translate("+d+","+c+")");var e=this.width()-2*d,f=this.height()-2*c,g={selection:this._textContainer,xAlign:this.xAlignment(),yAlign:this.yAlignment(),textRotation:this.angle()};return this._writer.write(this._text,e,f,g),this},b}(a.Component);b.Label=c;var d=function(a){function b(c,d){a.call(this,c,d),this.addClass(b.TITLE_LABEL_CLASS)}return e(b,a),b.TITLE_LABEL_CLASS="title-label",b}(c);b.TitleLabel=d;var g=function(a){function b(c,d){a.call(this,c,d),this.addClass(b.AXIS_LABEL_CLASS)}return e(b,a),b.AXIS_LABEL_CLASS="axis-label",b}(c);b.AxisLabel=g}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;if(b.call(this),this._padding=5,this.addClass("legend"),this.maxEntriesPerRow(1),null==c)throw new Error("Legend requires a colorScale");this._colorScale=c,this._redrawCallback=function(a){return d.redraw()},this._colorScale.onUpdate(this._redrawCallback),this._formatter=a.Formatters.identity(),this.xAlignment("right").yAlignment("top"),this.comparator(function(a,b){var c=d._colorScale.domain().slice().map(function(a){return d._formatter(a)});return c.indexOf(a)-c.indexOf(b)}),this._symbolFactoryAccessor=function(){return a.SymbolFactories.circle()},this._symbolOpacityAccessor=function(){return 1}}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this);var d=this.content().append("g").classed(c.LEGEND_ROW_CLASS,!0),e=d.append("g").classed(c.LEGEND_ENTRY_CLASS,!0);e.append("text"),this._measurer=new f.Measurers.Measurer(d),this._wrapper=(new f.Wrappers.Wrapper).maxLines(1),this._writer=new f.Writers.Writer(this._measurer,this._wrapper).addTitleElement(a.Configs.ADD_TITLE_ELEMENTS)},c.prototype.formatter=function(a){return null==a?this._formatter:(this._formatter=a,this.redraw(),this)},c.prototype.maxEntriesPerRow=function(a){return null==a?this._maxEntriesPerRow:(this._maxEntriesPerRow=a,this.redraw(),this)},c.prototype.comparator=function(a){return null==a?this._comparator:(this._comparator=a,this.redraw(),this)},c.prototype.colorScale=function(a){return null!=a?(this._colorScale.offUpdate(this._redrawCallback),this._colorScale=a,this._colorScale.onUpdate(this._redrawCallback),this.redraw(),this):this._colorScale},c.prototype.destroy=function(){b.prototype.destroy.call(this),this._colorScale.offUpdate(this._redrawCallback)},c.prototype._calculateLayoutInfo=function(a,b){var c=this,d=this._measurer.measure().height,e=Math.max(0,a-this._padding),f=this._colorScale.domain().slice().sort(function(a,b){return c._comparator(c._formatter(a),c._formatter(b))}),g=d3.map(),h=d3.map();f.forEach(function(a){var b=d+c._measurer.measure(c._formatter(a)).width+c._padding,f=Math.min(b,e);g.set(a,f),h.set(a,b)});var i=this._packRows(e,f,g),j=Math.floor((b-2*this._padding)/d);return j!==j&&(j=0),{textHeight:d,entryLengths:g,untruncatedEntryLengths:h,rows:i,numRowsToDraw:Math.max(Math.min(j,i.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.untruncatedEntryLengths.get(a)})}),f=a.Utils.Math.max(e,0);return{minWidth:this._padding+f,minHeight:d.rows.length*d.textHeight+2*this._padding}},c.prototype._packRows=function(a,b,c){var d=this,e=[],f=[],g=a;return b.forEach(function(b){var h=c.get(b);(h>g||f.length===d._maxEntriesPerRow)&&(e.push(f),f=[],g=a),f.push(b),g-=h}),0!==f.length&&e.push(f),e},c.prototype.entitiesAt=function(a){if(!this._isSetup)return[];var b=[],d=this._calculateLayoutInfo(this.width(),this.height()),e=this._padding,f=this;return this.content().selectAll("g."+c.LEGEND_ROW_CLASS).each(function(g,h){var i=h*d.textHeight+e,j=(h+1)*d.textHeight+e,k=(i+j)/2,l=e,m=e;d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS).each(function(c){m+=d.entryLengths.get(c);var e=l+d.textHeight/2;if(m>=a.x&&l<=a.x&&j>=a.y&&i<=a.y){var g=d3.select(this),h=g.datum();b.push({datum:h,position:{x:e,y:k},selection:g,component:f})}l+=d.entryLengths.get(c)})}),b},c.prototype.renderImmediately=function(){var a=this;b.prototype.renderImmediately.call(this);var d=this._calculateLayoutInfo(this.width(),this.height()),e=d.rows.slice(0,d.numRowsToDraw),f=this.content().selectAll("g."+c.LEGEND_ROW_CLASS).data(e);f.enter().append("g").classed(c.LEGEND_ROW_CLASS,!0),f.exit().remove(),f.attr("transform",function(b,c){return"translate(0, "+(c*d.textHeight+a._padding)+")"});var g=f.selectAll("g."+c.LEGEND_ENTRY_CLASS).data(function(a){return a}),h=g.enter().append("g").classed(c.LEGEND_ENTRY_CLASS,!0);h.append("path"),h.append("g").classed("text-container",!0),g.exit().remove();var i=this._padding;f.each(function(a){var b=i,e=d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS);e.attr("transform",function(a,c){var e="translate("+b+", 0)";return b+=d.entryLengths.get(a),e})}),g.select("path").attr("d",function(b,c,e){return a.symbol()(b,e)(.6*d.textHeight)}).attr("transform","translate("+d.textHeight/2+","+d.textHeight/2+")").attr("fill",function(b){return a._colorScale.scale(b)}).attr("opacity",function(b,c,d){return a.symbolOpacity()(b,d)}).classed(c.LEGEND_SYMBOL_CLASS,!0);var j=this._padding,k=g.select("g.text-container");k.text("");var l=this;return k.attr("transform","translate("+d.textHeight+", 0)").each(function(a){var b=d3.select(this),c=d.entryLengths.get(a)-d.textHeight-j,e={selection:b,xAlign:"left",yAlign:"top",textRotation:0};l._writer.write(l._formatter(a),c,l.height(),e)}),this},c.prototype.symbol=function(a){return null==a?this._symbolFactoryAccessor:(this._symbolFactoryAccessor=a,this.render(),this)},c.prototype.symbolOpacity=function(a){return null==a?this._symbolOpacityAccessor:("number"==typeof a?this._symbolOpacityAccessor=function(){return a}:this._symbolOpacityAccessor=a,this.render(),this)},c.prototype.fixedWidth=function(){return!0},c.prototype.fixedHeight=function(){return!0},c.LEGEND_ROW_CLASS="legend-row",c.LEGEND_ENTRY_CLASS="legend-entry",c.LEGEND_SYMBOL_CLASS="legend-symbol",c}(a.Component);b.Legend=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;if(b.call(this),this._padding=5,null==c)throw new Error("InterpolatedColorLegend requires a interpolatedColorScale");this._scale=c,this._redrawCallback=function(a){return d.redraw()},this._scale.onUpdate(this._redrawCallback),this._formatter=a.Formatters.general(),this._orientation="horizontal",this._expands=!1,this.addClass("legend"),this.addClass("interpolated-color-legend")}return e(c,b),c.prototype.destroy=function(){b.prototype.destroy.call(this),this._scale.offUpdate(this._redrawCallback)},c.prototype.formatter=function(a){return void 0===a?this._formatter:(this._formatter=a,this.redraw(),this)},c.prototype.expands=function(a){return null==a?this._expands:(this._expands=a,this.redraw(),this)},c._ensureOrientation=function(a){if(a=a.toLowerCase(),"horizontal"===a||"left"===a||"right"===a)return a;throw new Error('"'+a+'" is not a valid orientation for InterpolatedColorLegend')},c.prototype.orientation=function(a){return null==a?this._orientation:(this._orientation=c._ensureOrientation(a),this.redraw(),this)},c.prototype.fixedWidth=function(){return!this.expands()||this._isVertical()},c.prototype.fixedHeight=function(){return!this.expands()||!this._isVertical()},c.prototype._generateTicks=function(a){void 0===a&&(a=c._DEFAULT_NUM_SWATCHES);for(var b=this._scale.domain(),d=(b[1]-b[0])/(a-1),e=[],f=0;a>f;f++)e.push(b[0]+d*f);return e},c.prototype._setup=function(){b.prototype._setup.call(this),this._swatchContainer=this.content().append("g").classed("swatch-container",!0),this._swatchBoundingBox=this.content().append("rect").classed("swatch-bounding-box",!0),this._lowerLabel=this.content().append("g").classed(c.LEGEND_LABEL_CLASS,!0),this._upperLabel=this.content().append("g").classed(c.LEGEND_LABEL_CLASS,!0),this._measurer=new f.Measurers.Measurer(this.content()),this._wrapper=new f.Wrappers.Wrapper,this._writer=new f.Writers.Writer(this._measurer,this._wrapper)},c.prototype.requestedSpace=function(b,d){var e,f,g=this,h=this._measurer.measure().height,i=this._scale.domain(),j=i.map(function(a){return g._measurer.measure(g._formatter(a)).width}),k=c._DEFAULT_NUM_SWATCHES;if(this._isVertical()){var l=a.Utils.Math.max(j,0);f=this._padding+h+this._padding+l+this._padding,e=this._padding+k*h+this._padding}else e=this._padding+h+this._padding,f=this._padding+j[0]+this._padding+k*h+this._padding+j[1]+this._padding;return{minWidth:f,minHeight:e}},c.prototype._isVertical=function(){return"horizontal"!==this._orientation},c.prototype.renderImmediately=function(){ +var a=this;b.prototype.renderImmediately.call(this);var d,e,f,g,h=this._scale.domain(),i=this._formatter(h[0]),j=this._measurer.measure(i).width,k=this._formatter(h[1]),l=this._measurer.measure(k).width,m=this._padding,n={x:0,y:0},o={x:0,y:0},p={selection:this._lowerLabel,xAlign:"center",yAlign:"center",textRotation:0},q={selection:this._upperLabel,xAlign:"center",yAlign:"center",textRotation:0},r={x:0,y:m,width:0,height:0},s=c._DEFAULT_NUM_SWATCHES,t=this._measurer.measure().height;if(this.expands()&&t>0){var u=this._isVertical()?2*m:4*m-j-l,v=this._isVertical()?this.height():this.width();s=Math.max(Math.floor((v-u)/t),s)}if(this._isVertical()){var w=Math.max(j,l);d=Math.max(this.width()-3*m-w,0),e=Math.max((this.height()-2*m)/s,0),g=function(a,b){return m+(s-(b+1))*e},q.yAlign="top",n.y=m,p.yAlign="bottom",o.y=-m,"left"===this._orientation?(f=function(a,b){return m+w+m},q.xAlign="right",n.x=-(m+d+m),p.xAlign="right",o.x=-(m+d+m)):(f=function(a,b){return m},q.xAlign="left",n.x=m+d+m,p.xAlign="left",o.x=m+d+m),r.width=d,r.height=s*e}else d=Math.max((this.width()-4*m-j-l)/s,0),e=Math.max(this.height()-2*m,0),f=function(a,b){return m+j+m+b*d},g=function(a,b){return m},q.xAlign="right",n.x=-m,p.xAlign="left",o.x=m,r.width=s*d,r.height=e;r.x=f(null,0),this._upperLabel.text(""),this._writer.write(k,this.width(),this.height(),q);var x="translate("+n.x+", "+n.y+")";this._upperLabel.attr("transform",x),this._lowerLabel.text(""),this._writer.write(i,this.width(),this.height(),p);var y="translate("+o.x+", "+o.y+")";this._lowerLabel.attr("transform",y),this._swatchBoundingBox.attr(r);var z=this._generateTicks(s),A=this._swatchContainer.selectAll("rect.swatch").data(z);return A.enter().append("rect").classed("swatch",!0),A.exit().remove(),A.attr({fill:function(b,c){return a._scale.scale(b)},width:d,height:e,x:f,y:g}),this},c._DEFAULT_NUM_SWATCHES=11,c.LEGEND_LABEL_CLASS="legend-label",c}(a.Component);b.InterpolatedColorLegend=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c,d){var e=this;if(null!=c&&!a.QuantitativeScale.prototype.isPrototypeOf(c))throw new Error("xScale needs to inherit from Scale.QuantitativeScale");if(null!=d&&!a.QuantitativeScale.prototype.isPrototypeOf(d))throw new Error("yScale needs to inherit from Scale.QuantitativeScale");b.call(this),this.addClass("gridlines"),this._xScale=c,this._yScale=d,this._renderCallback=function(a){return e.render()},this._xScale&&this._xScale.onUpdate(this._renderCallback),this._yScale&&this._yScale.onUpdate(this._renderCallback)}return e(c,b),c.prototype.destroy=function(){return b.prototype.destroy.call(this),this._xScale&&this._xScale.offUpdate(this._renderCallback),this._yScale&&this._yScale.offUpdate(this._renderCallback),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.renderImmediately=function(){return b.prototype.renderImmediately.call(this),this._redrawXLines(),this._redrawYLines(),this},c.prototype.computeLayout=function(a,c,d){return b.prototype.computeLayout.call(this,a,c,d),null!=this._xScale&&this._xScale.range([0,this.width()]),null!=this._yScale&&this._yScale.range([this.height(),0]),this},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}(a.Component);b.Gridlines=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this._rowPadding=0,this._columnPadding=0,this._rows=[],this._rowWeights=[],this._columnWeights=[],this._nRows=0,this._nCols=0,this._calculatedLayout=null,this.addClass("table"),a.forEach(function(a,b){a.forEach(function(a,d){null!=a&&c.add(a,b,d)})})}return e(c,b),c.prototype._forEach=function(a){for(var b=0;b0&&f!==z,E=g>0&&g!==A;if(!D&&!E)break;if(w>5)break}return f=m-d3.sum(h.guaranteedWidths),g=n-d3.sum(h.guaranteedHeights),s=c._calcProportionalSpace(p,f),t=c._calcProportionalSpace(o,g),{colProportionalSpace:s,rowProportionalSpace:t,guaranteedWidths:h.guaranteedWidths,guaranteedHeights:h.guaranteedHeights,wantsWidth:i,wantsHeight:j}},c.prototype._determineGuarantees=function(b,c,d){void 0===d&&(d=!1);var e=a.Utils.Array.createFilledArray(0,this._nCols),f=a.Utils.Array.createFilledArray(0,this._nRows),g=a.Utils.Array.createFilledArray(!1,this._nCols),h=a.Utils.Array.createFilledArray(!1,this._nRows);return this._rows.forEach(function(a,i){a.forEach(function(a,j){var k;k=null!=a?a.requestedSpace(b[j],c[i]):{minWidth:0,minHeight:0};var l=d?Math.min(k.minWidth,b[j]):k.minWidth;e[j]=Math.max(e[j],l);var m=d?Math.min(k.minHeight,c[i]):k.minHeight;f[i]=Math.max(f[i],m);var n=k.minWidth>b[j];g[j]=g[j]||n;var o=k.minHeight>c[i];h[i]=h[i]||o})}),{guaranteedWidths:e,guaranteedHeights:f,wantsWidthArr:g,wantsHeightArr:h}},c.prototype.requestedSpace=function(a,b){return this._calculatedLayout=this._iterateLayout(a,b),{minWidth:d3.sum(this._calculatedLayout.guaranteedWidths),minHeight:d3.sum(this._calculatedLayout.guaranteedHeights)}},c.prototype.computeLayout=function(c,d,e){var f=this;b.prototype.computeLayout.call(this,c,d,e);var g=d3.sum(this._calculatedLayout.guaranteedWidths),h=d3.sum(this._calculatedLayout.guaranteedHeights),i=this._calculatedLayout;(g>this.width()||h>this.height())&&(i=this._iterateLayout(this.width(),this.height(),!0));var j=0,k=a.Utils.Array.add(i.rowProportionalSpace,i.guaranteedHeights),l=a.Utils.Array.add(i.colProportionalSpace,i.guaranteedWidths);return this._rows.forEach(function(a,b){var c=0;a.forEach(function(a,d){null!=a&&a.computeLayout({x:c,y:j},l[d],k[b]),c+=l[d]+f._columnPadding}),j+=k[b]+f._rowPadding}),this},c.prototype.rowPadding=function(a){return null==a?this._rowPadding:(this._rowPadding=a,this.redraw(),this)},c.prototype.columnPadding=function(a){return null==a?this._columnPadding:(this._columnPadding=a,this.redraw(),this)},c.prototype.rowWeight=function(a,b){return null==b?this._rowWeights[a]:(this._rowWeights[a]=b,this.redraw(),this)},c.prototype.columnWeight=function(a,b){return null==b?this._columnWeights[a]:(this._columnWeights[a]=b,this.redraw(),this)},c.prototype.fixedWidth=function(){var a=d3.transpose(this._rows);return c._fixedSpace(a,function(a){return null==a||a.fixedWidth()})},c.prototype.fixedHeight=function(){return c._fixedSpace(this._rows,function(a){return null==a||a.fixedHeight()})},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(var d=0;b>d;d++)void 0===this._columnWeights[d]&&(this._columnWeights[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.Utils.Array.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}(a.ComponentContainer);b.Table=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){!function(a){a[a.VALUE=0]="VALUE",a[a.PIXEL=1]="PIXEL"}(b.PropertyMode||(b.PropertyMode={}));var c=b.PropertyMode,d=function(b){function d(){var a=this;b.call(this),this._boxVisible=!1,this._boxBounds={topLeft:{x:0,y:0},bottomRight:{x:0,y:0}},this._xBoundsMode=c.PIXEL,this._yBoundsMode=c.PIXEL,this.addClass("selection-box-layer"),this._adjustBoundsCallback=function(){a.render()},this._clipPathEnabled=!0,this._xExtent=[void 0,void 0],this._yExtent=[void 0,void 0]}return e(d,b),d.prototype._setup=function(){b.prototype._setup.call(this),this._box=this.content().append("g").classed("selection-box",!0).remove(),this._boxArea=this._box.append("rect").classed("selection-area",!0)},d.prototype._sizeFromOffer=function(a,b){return{width:a,height:b}},d.prototype.bounds=function(a){return null==a?this._getBounds():(this._setBounds(a),this._xBoundsMode=c.PIXEL,this._yBoundsMode=c.PIXEL,this.render(),this)},d.prototype._setBounds=function(a){var b={x:Math.min(a.topLeft.x,a.bottomRight.x),y:Math.min(a.topLeft.y,a.bottomRight.y)},c={x:Math.max(a.topLeft.x,a.bottomRight.x),y:Math.max(a.topLeft.y,a.bottomRight.y)};this._boxBounds={topLeft:b,bottomRight:c}},d.prototype._getBounds=function(){return{topLeft:{x:this._xBoundsMode===c.PIXEL?this._boxBounds.topLeft.x:null==this._xScale?0:Math.min(this.xScale().scale(this.xExtent()[0]),this.xScale().scale(this.xExtent()[1])),y:this._yBoundsMode===c.PIXEL?this._boxBounds.topLeft.y:null==this._yScale?0:Math.min(this.yScale().scale(this.yExtent()[0]),this.yScale().scale(this.yExtent()[1]))},bottomRight:{x:this._xBoundsMode===c.PIXEL?this._boxBounds.bottomRight.x:null==this._xScale?0:Math.max(this.xScale().scale(this.xExtent()[0]),this.xScale().scale(this.xExtent()[1])),y:this._yBoundsMode===c.PIXEL?this._boxBounds.bottomRight.y:null==this._yScale?0:Math.max(this.yScale().scale(this.yExtent()[0]),this.yScale().scale(this.yExtent()[1]))}}},d.prototype.renderImmediately=function(){if(b.prototype.renderImmediately.call(this),this._boxVisible){var c=this.bounds(),d=c.topLeft.y,e=c.bottomRight.y,f=c.topLeft.x,g=c.bottomRight.x;if(!(a.Utils.Math.isValidNumber(d)&&a.Utils.Math.isValidNumber(e)&&a.Utils.Math.isValidNumber(f)&&a.Utils.Math.isValidNumber(g)))throw new Error("bounds have not been properly set");this._boxArea.attr({x:f,y:d,width:g-f,height:e-d}),this.content().node().appendChild(this._box.node())}else this._box.remove();return this},d.prototype.boxVisible=function(a){return null==a?this._boxVisible:(this._boxVisible=a,this.render(),this)},d.prototype.fixedWidth=function(){return!0},d.prototype.fixedHeight=function(){return!0},d.prototype.xScale=function(a){return null==a?this._xScale:(null!=this._xScale&&this._xScale.offUpdate(this._adjustBoundsCallback),this._xScale=a,this._xBoundsMode=c.VALUE,this._xScale.onUpdate(this._adjustBoundsCallback),this.render(),this)},d.prototype.yScale=function(a){return null==a?this._yScale:(null!=this._yScale&&this._yScale.offUpdate(this._adjustBoundsCallback),this._yScale=a,this._yBoundsMode=c.VALUE,this._yScale.onUpdate(this._adjustBoundsCallback),this.render(),this)},d.prototype.xExtent=function(a){return null==a?this._getXExtent():(this._setXExtent(a),this._xBoundsMode=c.VALUE,this.render(),this)},d.prototype._getXExtent=function(){return this._xBoundsMode===c.VALUE?this._xExtent:null==this._xScale?[void 0,void 0]:[this._xScale.invert(this._boxBounds.topLeft.x),this._xScale.invert(this._boxBounds.bottomRight.x)]},d.prototype._setXExtent=function(a){this._xExtent=a},d.prototype.yExtent=function(a){return null==a?this._getYExtent():(this._setYExtent(a),this._yBoundsMode=c.VALUE,this.render(),this)},d.prototype._getYExtent=function(){return this._yBoundsMode===c.VALUE?this._yExtent:null==this._yScale?[void 0,void 0]:[this._yScale.invert(this._boxBounds.topLeft.y),this._yScale.invert(this._boxBounds.bottomRight.y)]},d.prototype._setYExtent=function(a){this._yExtent=a},d.prototype.destroy=function(){b.prototype.destroy.call(this),null!=this._xScale&&this.xScale().offUpdate(this._adjustBoundsCallback),null!=this._yScale&&this.yScale().offUpdate(this._adjustBoundsCallback)},d}(a.Component);b.SelectionBoxLayer=d}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c;!function(a){a[a.VALUE=0]="VALUE",a[a.PIXEL=1]="PIXEL"}(c||(c={}));var d=function(b){function d(a){var e=this;if(b.call(this),this._mode=c.VALUE,a!==d.ORIENTATION_VERTICAL&&a!==d.ORIENTATION_HORIZONTAL)throw new Error(a+" is not a valid orientation for GuideLineLayer");this._orientation=a,this._clipPathEnabled=!0,this.addClass("guide-line-layer"),this._isVertical()?this.addClass("vertical"):this.addClass("horizontal"),this._scaleUpdateCallback=function(){e._syncPixelPositionAndValue(),e.render()}}return e(d,b),d.prototype._setup=function(){b.prototype._setup.call(this),this._guideLine=this.content().append("line").classed("guide-line",!0)},d.prototype._sizeFromOffer=function(a,b){return{width:a,height:b}},d.prototype._isVertical=function(){return this._orientation===d.ORIENTATION_VERTICAL},d.prototype.fixedWidth=function(){return!0},d.prototype.fixedHeight=function(){return!0},d.prototype.computeLayout=function(a,c,d){return b.prototype.computeLayout.call(this,a,c,d),null!=this.scale()&&(this._isVertical()?this.scale().range([0,this.width()]):this.scale().range([this.height(),0])),this},d.prototype.renderImmediately=function(){return b.prototype.renderImmediately.call(this),this._syncPixelPositionAndValue(),this._guideLine.attr({x1:this._isVertical()?this.pixelPosition():0,y1:this._isVertical()?0:this.pixelPosition(),x2:this._isVertical()?this.pixelPosition():this.width(),y2:this._isVertical()?this.height():this.pixelPosition()}),this},d.prototype._syncPixelPositionAndValue=function(){null!=this.scale()&&(this._mode===c.VALUE&&null!=this.value()?this._pixelPosition=this.scale().scale(this.value()):this._mode===c.PIXEL&&null!=this.pixelPosition()&&(this._value=this.scale().invert(this.pixelPosition())))},d.prototype._setPixelPositionWithoutChangingMode=function(a){this._pixelPosition=a,null!=this.scale()&&(this._value=this.scale().invert(this.pixelPosition())),this.render()},d.prototype.scale=function(a){if(null==a)return this._scale;var b=this._scale;return null!=b&&b.offUpdate(this._scaleUpdateCallback),this._scale=a,this._scale.onUpdate(this._scaleUpdateCallback),this._syncPixelPositionAndValue(),this.redraw(),this},d.prototype.value=function(a){return null==a?this._value:(this._value=a,this._mode=c.VALUE,this._syncPixelPositionAndValue(),this.render(),this)},d.prototype.pixelPosition=function(b){if(null==b)return this._pixelPosition;if(!a.Utils.Math.isValidNumber(b))throw new Error("pixelPosition must be a finite number");return this._pixelPosition=b,this._mode=c.PIXEL,this._syncPixelPositionAndValue(),this.render(),this},d.prototype.destroy=function(){b.prototype.destroy.call(this),null!=this.scale()&&this.scale().offUpdate(this._scaleUpdateCallback)},d.ORIENTATION_VERTICAL="vertical",d.ORIENTATION_HORIZONTAL="horizontal",d}(a.Component);b.GuideLineLayer=d}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b;!function(a){a.MAIN="main",a.RESET="reset"}(b=a.Animator||(a.Animator={}))}(b=a.Plots||(a.Plots={}));var c=function(c){function d(){var e=this;c.call(this),this._dataChanged=!1,this._animate=!1,this._animators={},this._clipPathEnabled=!0,this.addClass("plot"),this._datasetToDrawer=new a.Utils.Map,this._attrBindings=d3.map(),this._attrExtents=d3.map(),this._includedValuesProvider=function(a){return e._includedValuesForScale(a)},this._renderCallback=function(a){return e.render()},this._onDatasetUpdateCallback=function(){return e._onDatasetUpdate()},this._propertyBindings=d3.map(),this._propertyExtents=d3.map();var f=(new a.Animators.Easing).maxTotalDuration(d._ANIMATION_MAX_DURATION);this.animator(b.Animator.MAIN,f),this.animator(b.Animator.RESET,new a.Animators.Null)}return e(d,c),d.prototype.anchor=function(a){return c.prototype.anchor.call(this,a),this._dataChanged=!0,this._updateExtents(),this},d.prototype._setup=function(){var a=this;c.prototype._setup.call(this),this._renderArea=this.content().append("g").classed("render-area",!0),this.datasets().forEach(function(b){return a._createNodesForDataset(b)})},d.prototype.destroy=function(){var a=this;c.prototype.destroy.call(this),this._scales().forEach(function(b){return b.offUpdate(a._renderCallback)}),this.datasets([])},d.prototype._createNodesForDataset=function(a){var b=this._datasetToDrawer.get(a);return b.renderArea(this._renderArea.append("g")),b},d.prototype._createDrawer=function(b){return new a.Drawer(b)},d.prototype._getAnimator=function(b){return this._animateOnNextRender()?this._animators[b]||new a.Animators.Null:new a.Animators.Null},d.prototype._onDatasetUpdate=function(){this._updateExtents(),this._dataChanged=!0,this.render()},d.prototype.attr=function(a,b,c){return null==b?this._attrBindings.get(a):(this._bindAttr(a,b,c),this.render(),this)},d.prototype._bindProperty=function(a,b,c){var d=this._propertyBindings.get(a),e=null!=d?d.scale:null;this._propertyBindings.set(a,{accessor:d3.functor(b),scale:c}),this._updateExtentsForProperty(a),null!=e&&this._uninstallScaleForKey(e,a),null!=c&&this._installScaleForKey(c,a)},d.prototype._bindAttr=function(a,b,c){var d=this._attrBindings.get(a),e=null!=d?d.scale:null;this._attrBindings.set(a,{accessor:d3.functor(b),scale:c}),this._updateExtentsForAttr(a),null!=e&&this._uninstallScaleForKey(e,a),null!=c&&this._installScaleForKey(c,a)},d.prototype._generateAttrToProjector=function(){var a={};this._attrBindings.forEach(function(b,c){var d=c.accessor,e=c.scale,f=e?function(a,b,c){return e.scale(d(a,b,c))}:d;a[b]=f});var b=this._propertyProjectors();return Object.keys(b).forEach(function(c){null==a[c]&&(a[c]=b[c])}),a},d.prototype.renderImmediately=function(){return c.prototype.renderImmediately.call(this),this._isAnchored&&(this._paint(),this._dataChanged=!1),this},d.prototype.animated=function(a){return null==a?this._animate:(this._animate=a,this)},d.prototype.detach=function(){return c.prototype.detach.call(this),this._updateExtents(),this},d.prototype._scales=function(){var a=[];return this._attrBindings.forEach(function(b,c){var d=c.scale;null!=d&&-1===a.indexOf(d)&&a.push(d)}),this._propertyBindings.forEach(function(b,c){var d=c.scale;null!=d&&-1===a.indexOf(d)&&a.push(d)}),a},d.prototype._updateExtents=function(){var a=this;this._attrBindings.forEach(function(b){return a._updateExtentsForAttr(b)}),this._propertyExtents.forEach(function(b){return a._updateExtentsForProperty(b)}),this._scales().forEach(function(b){return b.addIncludedValuesProvider(a._includedValuesProvider)})},d.prototype._updateExtentsForAttr=function(a){this._updateExtentsForKey(a,this._attrBindings,this._attrExtents,null)},d.prototype._updateExtentsForProperty=function(a){this._updateExtentsForKey(a,this._propertyBindings,this._propertyExtents,this._filterForProperty(a))},d.prototype._filterForProperty=function(a){return null},d.prototype._updateExtentsForKey=function(a,b,c,d){var e=this,f=b.get(a);null!=f&&null!=f.accessor&&c.set(a,this.datasets().map(function(a){return e._computeExtent(a,f,d)}))},d.prototype._computeExtent=function(a,b,c){var d=b.accessor,e=b.scale;if(null==e)return[];var f=a.data();null!=c&&(f=f.filter(function(b,d){return c(b,d,a)}));var g=function(b,c){return d(b,c,a)},h=f.map(g);return e.extentOfValues(h)},d.prototype._extentsForProperty=function(a){return this._propertyExtents.get(a)},d.prototype._includedValuesForScale=function(a){var b=this;if(!this._isAnchored)return[];var c=[];return this._attrBindings.forEach(function(d,e){if(e.scale===a){var f=b._attrExtents.get(d);null!=f&&(c=c.concat(d3.merge(f)))}}),this._propertyBindings.forEach(function(d,e){if(e.scale===a){var f=b._extentsForProperty(d);null!=f&&(c=c.concat(d3.merge(f)))}}),c},d.prototype.animator=function(a,b){return void 0===b?this._animators[a]:(this._animators[a]=b,this)},d.prototype.addDataset=function(a){return this._addDataset(a),this._onDatasetUpdate(),this},d.prototype._addDataset=function(a){this._removeDataset(a);var b=this._createDrawer(a);return this._datasetToDrawer.set(a,b),this._isSetup&&this._createNodesForDataset(a),a.onUpdate(this._onDatasetUpdateCallback),this},d.prototype.removeDataset=function(a){return this._removeDataset(a),this._onDatasetUpdate(),this},d.prototype._removeDataset=function(a){return-1===this.datasets().indexOf(a)?this:(this._removeDatasetNodes(a),a.offUpdate(this._onDatasetUpdateCallback),this._datasetToDrawer["delete"](a),this)},d.prototype._removeDatasetNodes=function(a){var b=this._datasetToDrawer.get(a);b.remove()},d.prototype.datasets=function(a){var b=this,c=[];return this._datasetToDrawer.forEach(function(a,b){return c.push(b)}),null==a?c:(c.forEach(function(a){return b._removeDataset(a)}),a.forEach(function(a){return b._addDataset(a)}),this._onDatasetUpdate(),this)},d.prototype._getDrawersInOrder=function(){var a=this;return this.datasets().map(function(b){return a._datasetToDrawer.get(b)})},d.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animators.Null}]},d.prototype._additionalPaint=function(a){},d.prototype._getDataToDraw=function(){var b=new a.Utils.Map;return this.datasets().forEach(function(a){return b.set(a,a.data())}),b},d.prototype._paint=function(){var b=this._generateDrawSteps(),c=this._getDataToDraw(),d=this._getDrawersInOrder();this.datasets().forEach(function(a,e){return d[e].draw(c.get(a),b)});var e=this.datasets().map(function(a,e){return d[e].totalDrawTime(c.get(a),b)}),f=a.Utils.Math.max(e,0);this._additionalPaint(f)},d.prototype.selections=function(a){var b=this;void 0===a&&(a=this.datasets());var c=[];return a.forEach(function(a){var d=b._datasetToDrawer.get(a);null!=d&&d.renderArea().selectAll(d.selector()).each(function(){c.push(this)})}),d3.selectAll(c)},d.prototype.entities=function(a){var b=this;return void 0===a&&(a=this.datasets()),this._lightweightEntities(a).map(function(a){return b._lightweightPlotEntityToPlotEntity(a)})},d.prototype._lightweightEntities=function(b){var c=this;void 0===b&&(b=this.datasets());var d=[];return b.forEach(function(b){var e=c._datasetToDrawer.get(b),f=0;b.data().forEach(function(g,h){var i=c._pixelPoint(g,h,b);a.Utils.Math.isNaN(i.x)||a.Utils.Math.isNaN(i.y)||(d.push({datum:g,index:h,dataset:b,position:i,component:c,drawer:e,validDatumIndex:f}),f++)})}),d},d.prototype._lightweightPlotEntityToPlotEntity=function(a){var b={datum:a.datum,position:a.position,dataset:a.dataset,index:a.index,component:a.component,selection:a.drawer.selectionForIndex(a.validDatumIndex)};return b},d.prototype.entityNearest=function(b){var c,d=this,e=1/0,f=this._lightweightEntities();return f.forEach(function(f){if(d._entityVisibleOnPlot(f.position,f.datum,f.index,f.dataset)){var g=a.Utils.Math.distanceSquared(f.position,b);e>g&&(e=g,c=f)}}),this._lightweightPlotEntityToPlotEntity(c)},d.prototype._visibleOnPlot=function(b,c,d){return a.Utils.Window.deprecated("Plot._visibleOnPlot()","v1.1.0","replaced by _entityVisibleOnPlot()"),!(c.x<0||c.y<0||c.x>this.width()||c.y>this.height())},d.prototype._entityVisibleOnPlot=function(a,b,c,d){return!(a.x<0||a.y<0||a.x>this.width()||a.y>this.height())},d.prototype._uninstallScaleForKey=function(a,b){a.offUpdate(this._renderCallback),a.removeIncludedValuesProvider(this._includedValuesProvider)},d.prototype._installScaleForKey=function(a,b){a.onUpdate(this._renderCallback),a.addIncludedValuesProvider(this._includedValuesProvider)},d.prototype._propertyProjectors=function(){return{}},d._scaledAccessor=function(a){return null==a.scale?a.accessor:function(b,c,d){return a.scale.scale(a.accessor(b,c,d))}},d.prototype._pixelPoint=function(a,b,c){return{x:0,y:0}},d.prototype._animateOnNextRender=function(){return this._animate&&this._dataChanged},d._ANIMATION_MAX_DURATION=600,d}(a.Component);a.Plot=c}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.call(this),this._labelFormatter=a.Formatters.identity(),this._labelsEnabled=!1,this.innerRadius(0),this.outerRadius(function(){return Math.min(c.width(),c.height())/2}),this.addClass("pie-plot"),this.attr("fill",function(a,b){return String(b)},new a.Scales.Color),this._strokeDrawers=new a.Utils.Map}return e(c,b),c.prototype._setup=function(){var a=this;b.prototype._setup.call(this),this._strokeDrawers.forEach(function(b){return b.renderArea(a._renderArea.append("g"))})},c.prototype.computeLayout=function(a,c,d){b.prototype.computeLayout.call(this,a,c,d),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")");var e=Math.min(this.width(),this.height())/2;return null!=this.innerRadius().scale&&this.innerRadius().scale.range([0,e]),null!=this.outerRadius().scale&&this.outerRadius().scale.range([0,e]),this},c.prototype.addDataset=function(a){return b.prototype.addDataset.call(this,a),this},c.prototype._addDataset=function(c){if(1===this.datasets().length)return a.Utils.Window.warn("Only one dataset is supported in Pie plots"),this;this._updatePieAngles();var d=new a.Drawers.ArcOutline(c);return this._isSetup&&d.renderArea(this._renderArea.append("g")),this._strokeDrawers.set(c,d),b.prototype._addDataset.call(this,c),this},c.prototype.removeDataset=function(a){return b.prototype.removeDataset.call(this,a),this},c.prototype._removeDatasetNodes=function(a){b.prototype._removeDatasetNodes.call(this,a),this._strokeDrawers.get(a).remove()},c.prototype._removeDataset=function(a){return b.prototype._removeDataset.call(this,a),this._startAngles=[],this._endAngles=[],this},c.prototype.selections=function(a){var c=this;void 0===a&&(a=this.datasets());var d=b.prototype.selections.call(this,a)[0];return a.forEach(function(a){var b=c._strokeDrawers.get(a);null!=b&&b.renderArea().selectAll(b.selector()).each(function(){d.push(this)})}),d3.selectAll(d)},c.prototype._onDatasetUpdate=function(){this._updatePieAngles(),b.prototype._onDatasetUpdate.call(this)},c.prototype._createDrawer=function(b){return new a.Drawers.Arc(b)},c.prototype.entities=function(a){var c=this;void 0===a&&(a=this.datasets());var d=b.prototype.entities.call(this,a);return d.forEach(function(a){a.position.x+=c.width()/2,a.position.y+=c.height()/2;var b=c._strokeDrawers.get(a.dataset).selectionForIndex(a.index);a.selection[0].push(b[0][0])}),d},c.prototype.sectorValue=function(a,b){return null==a?this._propertyBindings.get(c._SECTOR_VALUE_KEY):(this._bindProperty(c._SECTOR_VALUE_KEY,a,b),this._updatePieAngles(),this.render(),this)},c.prototype.innerRadius=function(a,b){return null==a?this._propertyBindings.get(c._INNER_RADIUS_KEY):(this._bindProperty(c._INNER_RADIUS_KEY,a,b),this.render(),this)},c.prototype.outerRadius=function(a,b){return null==a?this._propertyBindings.get(c._OUTER_RADIUS_KEY):(this._bindProperty(c._OUTER_RADIUS_KEY,a,b),this.render(),this)},c.prototype.labelsEnabled=function(a){return null==a?this._labelsEnabled:(this._labelsEnabled=a,this.render(),this)},c.prototype.labelFormatter=function(a){return null==a?this._labelFormatter:(this._labelFormatter=a,this.render(),this)},c.prototype.entitiesAt=function(a){var b={x:this.width()/2,y:this.height()/2},c={x:a.x-b.x,y:a.y-b.y},d=this._sliceIndexForPoint(c);return null==d?[]:[this.entities()[d]]},c.prototype._propertyProjectors=function(){var c=this,d=b.prototype._propertyProjectors.call(this),e=a.Plot._scaledAccessor(this.innerRadius()),f=a.Plot._scaledAccessor(this.outerRadius());return d.d=function(a,b,d){return d3.svg.arc().innerRadius(e(a,b,d)).outerRadius(f(a,b,d)).startAngle(c._startAngles[b]).endAngle(c._endAngles[b])(a,b)},d},c.prototype._updatePieAngles=function(){if(null!=this.sectorValue()&&0!==this.datasets().length){var b=a.Plot._scaledAccessor(this.sectorValue()),c=this.datasets()[0],d=this._getDataToDraw().get(c),e=d3.layout.pie().sort(null).value(function(a,d){return b(a,d,c)})(d);this._startAngles=e.map(function(a){return a.startAngle}),this._endAngles=e.map(function(a){return a.endAngle})}},c.prototype._getDataToDraw=function(){var d=b.prototype._getDataToDraw.call(this);if(0===this.datasets().length)return d;var e=a.Plot._scaledAccessor(this.sectorValue()),f=this.datasets()[0],g=d.get(f),h=g.filter(function(a,b){return c._isValidData(e(a,b,f))});return d.set(f,h),d},c._isValidData=function(b){return a.Utils.Math.isValidNumber(b)&&b>=0},c.prototype._pixelPoint=function(b,d,e){var f=a.Plot._scaledAccessor(this.sectorValue());if(!c._isValidData(f(b,d,e)))return{x:NaN,y:NaN};var g=a.Plot._scaledAccessor(this.innerRadius())(b,d,e),h=a.Plot._scaledAccessor(this.outerRadius())(b,d,e),i=(g+h)/2,j=d3.layout.pie().sort(null).value(function(a,b){var d=f(a,b,e);return c._isValidData(d)?d:0})(e.data()),k=j[d].startAngle,l=j[d].endAngle,m=(k+l)/2;return{x:i*Math.sin(m),y:-i*Math.cos(m)}},c.prototype._additionalPaint=function(b){var c=this;this._renderArea.select(".label-area").remove(), +this._labelsEnabled&&a.Utils.Window.setTimeout(function(){return c._drawLabels()},b);var d=this._generateStrokeDrawSteps(),e=this._getDataToDraw();this.datasets().forEach(function(a){return c._strokeDrawers.get(a).draw(e.get(a),d)})},c.prototype._generateStrokeDrawSteps=function(){var b=this._generateAttrToProjector();return[{attrToProjector:b,animator:new a.Animators.Null}]},c.prototype._sliceIndexForPoint=function(a){var b=Math.sqrt(Math.pow(a.x,2)+Math.pow(a.y,2)),c=Math.acos(-a.y/b);a.x<0&&(c=2*Math.PI-c);for(var d,e=0;ec){d=e;break}if(void 0!==d){var f=this.datasets()[0],g=f.data()[d],h=this.innerRadius().accessor(g,d,f),i=this.outerRadius().accessor(g,d,f);if(b>h&&i>b)return d}return null},c.prototype._drawLabels=function(){var b=this,c=this._generateAttrToProjector(),d=this._renderArea.append("g").classed("label-area",!0),e=new f.Measurers.Measurer(d),g=new f.Writers.Writer(e),h=this.datasets()[0],i=this._getDataToDraw().get(h);i.forEach(function(f,i){var j=b.sectorValue().accessor(f,i,h);if(a.Utils.Math.isValidNumber(j)){j=b._labelFormatter(j);var k=e.measure(j),l=(b._endAngles[i]+b._startAngles[i])/2,m=b.outerRadius().accessor(f,i,h);b.outerRadius().scale&&(m=b.outerRadius().scale.scale(m));var n=b.innerRadius().accessor(f,i,h);b.innerRadius().scale&&(n=b.innerRadius().scale.scale(n));var o=(m+n)/2,p=Math.sin(l)*o-k.width/2,q=-Math.cos(l)*o-k.height/2,r=[{x:p,y:q},{x:p,y:q+k.height},{x:p+k.width,y:q},{x:p+k.width,y:q+k.height}],s=r.every(function(a){return Math.abs(a.x)<=b.width()/2&&Math.abs(a.y)<=b.height()/2});if(s){var t=r.map(function(a){return b._sliceIndexForPoint(a)});s=t.every(function(a){return a===i})}var u=c.fill(f,i,h),v=1.6*a.Utils.Color.contrast("white",u)n||y.minp)return;if(e._overlayLabel(x,y,k,d,b))return;var z=g.fill(f,k,c),A=1.6*a.Utils.Color.contrast("white",z)=p-i&&q+i>=h)l=0;else{var r=d._isVertical?m.y:m.x;l=Math.abs(h-r)}}(e>k||k===e&&f>l)&&(c=j,e=k,f=l)}}),c},d.prototype._visibleOnPlot=function(b,c,d){a.Utils.Window.deprecated("Bar._visibleOnPlot()","v1.1.0","replaced by _entityVisibleOnPlot()");var e={min:0,max:this.width()},f={min:0,max:this.height()},g=a.Utils.DOM.elementBBox(d);return a.Utils.DOM.intersectsBBox(e,f,g)},d.prototype._entityVisibleOnPlot=function(b,c,d,e){var f={min:0,max:this.width()},g={min:0,max:this.height()},h=this._generateAttrToProjector(),i={x:h.x(c,d,e),y:h.y(c,d,e),width:h.width(c,d,e),height:h.height(c,d,e)};return a.Utils.DOM.intersectsBBox(f,g,i)},d.prototype.entitiesAt=function(a){return this._entitiesIntersecting(a.x,a.y)},d.prototype.entitiesIn=function(a,b){var c,d;if(null==b){var e=a;c={min:e.topLeft.x,max:e.bottomRight.x},d={min:e.topLeft.y,max:e.bottomRight.y}}else c=a,d=b;return this._entitiesIntersecting(c,d)},d.prototype._entitiesIntersecting=function(b,c){var d=[];return this.entities().forEach(function(e){a.Utils.DOM.intersectsBBox(b,c,a.Utils.DOM.elementBBox(e.selection))&&d.push(e)}),d},d.prototype._updateValueScale=function(){if(this._projectorsReady()){var b=this._isVertical?this.y().scale:this.x().scale;if(b instanceof a.QuantitativeScale){var c=b;c.addPaddingExceptionsProvider(this._baselineValueProvider),c.addIncludedValuesProvider(this._baselineValueProvider)}}},d.prototype._additionalPaint=function(b){var c=this,d=this._isVertical?this.y().scale:this.x().scale,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),this.datasets().forEach(function(a){return c._labelConfig.get(a).labelArea.selectAll("g").remove()}),this._labelsEnabled&&a.Utils.Window.setTimeout(function(){return c._drawLabels()},b)},d.prototype._extentsForProperty=function(b){var d,e=this,f=c.prototype._extentsForProperty.call(this,b);if("x"===b&&this._isVertical)d=this.x();else{if("y"!==b||this._isVertical)return f;d=this.y()}if(!(d&&d.scale&&d.scale instanceof a.QuantitativeScale))return f;var g=d.scale;return f=f.map(function(a){return d3.extent([g.invert(g.scale(a[0])-e._barPixelWidth/2),g.invert(g.scale(a[0])+e._barPixelWidth/2),g.invert(g.scale(a[1])-e._barPixelWidth/2),g.invert(g.scale(a[1])+e._barPixelWidth/2)])})},d.prototype._drawLabels=function(){var a=this,b=this._getDataToDraw(),c=!1;this.datasets().forEach(function(d){return c=c||a._drawLabel(b.get(d),d)}),this._hideBarsIfAnyAreTooWide&&c&&this.datasets().forEach(function(b){return a._labelConfig.get(b).labelArea.selectAll("g").remove()})},d.prototype._drawLabel=function(b,c){var e=this,f=this._generateAttrToProjector(),g=this._labelConfig.get(c),h=g.labelArea,i=g.measurer,j=g.writer,k=function(b,g){var k,l=e._isVertical?e.y().accessor:e.x().accessor,m=l(b,g,c),n=e._isVertical?e.y().scale:e.x().scale,o=null!=n?n.scale(m):m,p=null!=n?n.scale(e.baselineValue()):e.baselineValue(),q=f.width(b,g,c),r=f.height(b,g,c),s=e._labelFormatter(l(b,g,c)),t=i.measure(s),u="center",v="center",w={x:f.x(b,g,c),y:f.y(b,g,c)},x=q,y=r,z={x:w.x,y:w.y};if(e._isVertical){z.x+=x/2-t.width/2;var A=f.y(b,g,c),B=r;A+r>e.height()?B=e.height()-A:0>A&&(B=A+r);var C=d._LABEL_VERTICAL_PADDING;k=t.height+2*C<=B,k?p>o?(w.y+=C,v="top",z.y+=C):(w.y-=C,v="bottom",z.y+=y-C-t.height):(y=r+C+t.height,p>=o?(w.y-=C+t.height,v="top",z.y-=C+t.height):(v="bottom",z.y+=r+C))}else{z.y+=y/2-t.height/2;var D=f.x(b,g,c),E=q;D+q>e.width()?E=e.width()-D:0>D&&(E=D+q);var C=d._LABEL_HORIZONTAL_PADDING;k=t.width+2*C<=E,k?p>o?(w.x+=C,u="left",z.x+=C):(w.x-=C,u="right",z.x+=x-C-t.width):(x=q+C+t.width,p>o?(w.x-=C+t.width,u="left",z.x-=C+t.width):(u="right",z.x+=q+C))}var F=h.append("g").attr("transform","translate("+w.x+", "+w.y+")");if(k){F.classed("on-bar-label",!0);var G=f.fill(b,g,c),H=1.6*a.Utils.Color.contrast("white",G)e.width()||z.y+t.height>e.height();F.style("visibility",I?"hidden":"inherit");var J={selection:F,xAlign:u,yAlign:v,textRotation:0};j.write(s,x,y,J);var K=e._isVertical?qg?g:d},b},d.prototype._getBarPixelWidth=function(){if(!this._projectorsReady())return 0;var b,c=this._isVertical?this.x().scale:this.y().scale;if(c instanceof a.Scales.Category)b=c.rangeBand();else{var e=this._isVertical?this.x().accessor:this.y().accessor,f=d3.set(a.Utils.Array.flatten(this.datasets().map(function(a){return a.data().map(function(b,c){return e(b,c,a)}).filter(function(a){return null!=a}).map(function(a){return a.valueOf()})}))).values().map(function(a){return+a});f.sort(function(a,b){return a-b});var g=f.map(function(a){return c.scale(a)}),h=d3.pairs(g),i=this._isVertical?this.width():this.height();b=a.Utils.Math.min(h,function(a,b){return Math.abs(a[1]-a[0])},i*d._SINGLE_BAR_DIMENSION_RATIO),b*=d._BAR_WIDTH_RATIO}return b},d.prototype._updateBarPixelWidth=function(){this._barPixelWidth=this._getBarPixelWidth()},d.prototype.entities=function(a){if(void 0===a&&(a=this.datasets()),!this._projectorsReady())return[];var b=c.prototype.entities.call(this,a);return b},d.prototype._pixelPoint=function(b,c,d){var e,f,g=this._generateAttrToProjector(),h=g.x(b,c,d),i=g.y(b,c,d),j=g.width(b,c,d),k=g.height(b,c,d),l=(this._isVertical?a.Plot._scaledAccessor(this.y()):a.Plot._scaledAccessor(this.x()))(b,c,d),m=(this._isVertical?this.y().scale:this.x().scale).scale(this.baselineValue());return this._isVertical?(e=h+j/2,f=m>=l?i:i+k):(e=l>=m?h+j:h,f=i+k/2),{x:e,y:f}},d.prototype._uninstallScaleForKey=function(a,b){a.offUpdate(this._updateBarPixelWidthCallback),c.prototype._uninstallScaleForKey.call(this,a,b)},d.prototype._getDataToDraw=function(){var b=new a.Utils.Map,c=this._generateAttrToProjector();return this.datasets().forEach(function(d){var e=d.data().filter(function(b,e){return a.Utils.Math.isValidNumber(c.x(b,e,d))&&a.Utils.Math.isValidNumber(c.y(b,e,d))&&a.Utils.Math.isValidNumber(c.width(b,e,d))&&a.Utils.Math.isValidNumber(c.height(b,e,d))});b.set(d,e)}),b},d.ORIENTATION_VERTICAL="vertical",d.ORIENTATION_HORIZONTAL="horizontal",d._BAR_WIDTH_RATIO=.95,d._SINGLE_BAR_DIMENSION_RATIO=.4,d._BAR_AREA_CLASS="bar-area",d._LABEL_AREA_CLASS="bar-label-text-area",d._LABEL_VERTICAL_PADDING=5,d._LABEL_HORIZONTAL_PADDING=5,d}(a.XYPlot);b.Bar=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(){c.call(this),this._interpolator="linear",this._autorangeSmooth=!1,this._croppedRenderingEnabled=!0,this._downsamplingEnabled=!1,this.addClass("line-plot");var d=new a.Animators.Easing;d.stepDuration(a.Plot._ANIMATION_MAX_DURATION),d.easingMode("exp-in-out"),d.maxTotalDuration(a.Plot._ANIMATION_MAX_DURATION),this.animator(b.Animator.MAIN,d),this.attr("stroke",(new a.Scales.Color).range()[0]),this.attr("stroke-width","2px")}return e(d,c),d.prototype.x=function(a,b){return null==a?c.prototype.x.call(this):(null==b?c.prototype.x.call(this,a):c.prototype.x.call(this,a,b),this._setScaleSnapping(),this)},d.prototype.y=function(a,b){return null==a?c.prototype.y.call(this):(c.prototype.y.call(this,a,b),this._setScaleSnapping(),this)},d.prototype.autorangeMode=function(a){return null==a?c.prototype.autorangeMode.call(this):(c.prototype.autorangeMode.call(this,a),this._setScaleSnapping(),this)},d.prototype.autorangeSmooth=function(a){return null==a?this._autorangeSmooth:(this._autorangeSmooth=a,this._setScaleSnapping(),this)},d.prototype._setScaleSnapping=function(){"x"===this.autorangeMode()&&this.x()&&this.x().scale&&this.x().scale instanceof a.QuantitativeScale&&this.x().scale.snappingDomainEnabled(!this.autorangeSmooth()),"y"===this.autorangeMode()&&this.y()&&this.y().scale&&this.y().scale instanceof a.QuantitativeScale&&this.y().scale.snappingDomainEnabled(!this.autorangeSmooth())},d.prototype.interpolator=function(a){return null==a?this._interpolator:(this._interpolator=a,this.render(),this)},d.prototype.downsamplingEnabled=function(a){return null==a?this._downsamplingEnabled:(this._downsamplingEnabled=a,this)},d.prototype.croppedRenderingEnabled=function(a){return null==a?this._croppedRenderingEnabled:(this._croppedRenderingEnabled=a,this.render(),this)},d.prototype._createDrawer=function(b){return new a.Drawers.Line(b)},d.prototype._extentsForProperty=function(a){var b=c.prototype._extentsForProperty.call(this,a);if(!this._autorangeSmooth)return b;if(this.autorangeMode()!==a)return b;if("x"!==this.autorangeMode()&&"y"!==this.autorangeMode())return b;var d,e=this._getEdgeIntersectionPoints();return d="y"===this.autorangeMode()?e.left.concat(e.right).map(function(a){return a.y}):e.top.concat(e.bottom).map(function(a){return a.x}),b.map(function(a){ +return d3.extent(d3.merge([a,d]))})},d.prototype._getEdgeIntersectionPoints=function(){var b=this;if(!(this.y().scale instanceof a.QuantitativeScale&&this.x().scale instanceof a.QuantitativeScale))return{left:[],right:[],top:[],bottom:[]};var c=this.y().scale,d=this.x().scale,e={left:[],right:[],top:[],bottom:[]},f=d.scale(d.domain()[0]),g=d.scale(d.domain()[1]),h=c.scale(c.domain()[0]),i=c.scale(c.domain()[1]);return this.datasets().forEach(function(a){for(var j,k,l,m,n,o,p,q,r=a.data(),s=1;sn==p>=f&&(j=f-n,k=p-n,m=q-o,l=j*m/k,e.left.push({x:f,y:c.invert(o+l)})),g>n==p>=g&&(j=g-n,k=p-n,m=q-o,l=j*m/k,e.right.push({x:g,y:c.invert(o+l)})),i>o==q>=i&&(k=p-n,l=i-o,m=q-o,j=l*k/m,e.top.push({x:d.invert(n+j),y:i})),h>o==q>=h&&(k=p-n,l=h-o,m=q-o,j=l*k/m,e.bottom.push({x:d.invert(n+j),y:h}))}),e},d.prototype._getResetYFunction=function(){var a=this.y().scale.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.y().scale.scale(d);return function(a,b,c){return e}},d.prototype._generateDrawSteps=function(){var c=[];if(this._animateOnNextRender()){var d=this._generateAttrToProjector();d.d=this._constructLineProjector(a.Plot._scaledAccessor(this.x()),this._getResetYFunction()),c.push({attrToProjector:d,animator:this._getAnimator(b.Animator.RESET)})}return c.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator(b.Animator.MAIN)}),c},d.prototype._generateAttrToProjector=function(){var a=c.prototype._generateAttrToProjector.call(this);return Object.keys(a).forEach(function(b){if("d"!==b){var c=a[b];a[b]=function(a,b,d){return a.length>0?c(a[0],b,d):null}}}),a},d.prototype.entityNearest=function(a){var b,c=this,d=1/0,e=1/0;return this.entities().forEach(function(f){if(c._entityVisibleOnPlot(f.position,f.datum,f.index,f.dataset)){var g=Math.abs(a.x-f.position.x),h=Math.abs(a.y-f.position.y);(d>g||g===d&&e>h)&&(b=f,d=g,e=h)}}),b},d.prototype._propertyProjectors=function(){var b=c.prototype._propertyProjectors.call(this);return b.d=this._constructLineProjector(a.Plot._scaledAccessor(this.x()),a.Plot._scaledAccessor(this.y())),b},d.prototype._constructLineProjector=function(b,c){var d=this,e=function(b,c,e){var f=a.Plot._scaledAccessor(d.x())(b,c,e),g=a.Plot._scaledAccessor(d.y())(b,c,e);return null!=f&&!a.Utils.Math.isNaN(f)&&null!=g&&!a.Utils.Math.isNaN(g)};return function(a,f,g){return d3.svg.line().x(function(a,c){return b(a,c,g)}).y(function(a,b){return c(a,b,g)}).interpolate(d.interpolator()).defined(function(a,b){return e(a,b,g)})(a)}},d.prototype._getDataToDraw=function(){var b=this,c=new a.Utils.Map;return this.datasets().forEach(function(a){var d=a.data();if(!b._croppedRenderingEnabled&&!b._downsamplingEnabled)return void c.set(a,[d]);var e=d.map(function(a,b){return b});b._croppedRenderingEnabled&&(e=b._filterCroppedRendering(a,e)),b._downsamplingEnabled&&(e=b._filterDownsampling(a,e)),c.set(a,[e.map(function(a,b){return d[a]})])}),c},d.prototype._filterCroppedRendering=function(b,c){for(var d=this,e=a.Plot._scaledAccessor(this.x()),f=a.Plot._scaledAccessor(this.y()),g=b.data(),h=[],i=function(b,c){return a.Utils.Math.inRange(b,0,d.width())&&a.Utils.Math.inRange(c,0,d.height())},j=0;js&&(s=u,r=c[i]),q>u&&(q=u,p=c[i])}var v=c[i];p!==j&&g.push(p),r!==p&&r!==j&&g.push(r),v!==j&&v!==p&&v!==r&&g.push(v)}return g},d}(a.XYPlot);b.Line=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(){c.call(this),this.addClass("area-plot"),this.y0(0),this.attr("fill-opacity",.25),this.attr("fill",(new a.Scales.Color).range()[0]),this._lineDrawers=new a.Utils.Map}return e(d,c),d.prototype._setup=function(){var a=this;c.prototype._setup.call(this),this._lineDrawers.forEach(function(b){return b.renderArea(a._renderArea.append("g"))})},d.prototype.y=function(a,b){if(null==a)return c.prototype.y.call(this);if(null==b?c.prototype.y.call(this,a):c.prototype.y.call(this,a,b),null!=b){var e=this.y0().accessor;null!=e&&this._bindProperty(d._Y0_KEY,e,b),this._updateYScale()}return this},d.prototype.y0=function(a){if(null==a)return this._propertyBindings.get(d._Y0_KEY);var b=this.y(),c=b&&b.scale;return this._bindProperty(d._Y0_KEY,a,c),this._updateYScale(),this.render(),this},d.prototype._onDatasetUpdate=function(){c.prototype._onDatasetUpdate.call(this),this._updateYScale()},d.prototype.addDataset=function(a){return c.prototype.addDataset.call(this,a),this},d.prototype._addDataset=function(b){var d=new a.Drawers.Line(b);return this._isSetup&&d.renderArea(this._renderArea.append("g")),this._lineDrawers.set(b,d),c.prototype._addDataset.call(this,b),this},d.prototype._removeDatasetNodes=function(a){c.prototype._removeDatasetNodes.call(this,a),this._lineDrawers.get(a).remove()},d.prototype._additionalPaint=function(){var a=this,b=this._generateLineDrawSteps(),c=this._getDataToDraw();this.datasets().forEach(function(d){return a._lineDrawers.get(d).draw(c.get(d),b)})},d.prototype._generateLineDrawSteps=function(){var c=[];if(this._animateOnNextRender()){var d=this._generateLineAttrToProjector();d.d=this._constructLineProjector(a.Plot._scaledAccessor(this.x()),this._getResetYFunction()),c.push({attrToProjector:d,animator:this._getAnimator(b.Animator.RESET)})}return c.push({attrToProjector:this._generateLineAttrToProjector(),animator:this._getAnimator(b.Animator.MAIN)}),c},d.prototype._generateLineAttrToProjector=function(){var b=this._generateAttrToProjector();return b.d=this._constructLineProjector(a.Plot._scaledAccessor(this.x()),a.Plot._scaledAccessor(this.y())),b},d.prototype._createDrawer=function(b){return new a.Drawers.Area(b)},d.prototype._generateDrawSteps=function(){var c=[];if(this._animateOnNextRender()){var d=this._generateAttrToProjector();d.d=this._constructAreaProjector(a.Plot._scaledAccessor(this.x()),this._getResetYFunction(),a.Plot._scaledAccessor(this.y0())),c.push({attrToProjector:d,animator:this._getAnimator(b.Animator.RESET)})}return c.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator(b.Animator.MAIN)}),c},d.prototype._updateYScale=function(){var b=this._propertyExtents.get("y0"),c=a.Utils.Array.flatten(b),d=a.Utils.Array.uniq(c),e=1===d.length?d[0]:null,f=this.y(),g=f&&f.scale;null!=g&&(null!=this._constantBaselineValueProvider&&(g.removePaddingExceptionsProvider(this._constantBaselineValueProvider),this._constantBaselineValueProvider=null),null!=e&&(this._constantBaselineValueProvider=function(){return[e]},g.addPaddingExceptionsProvider(this._constantBaselineValueProvider)))},d.prototype._getResetYFunction=function(){return a.Plot._scaledAccessor(this.y0())},d.prototype._propertyProjectors=function(){var b=c.prototype._propertyProjectors.call(this);return b.d=this._constructAreaProjector(a.Plot._scaledAccessor(this.x()),a.Plot._scaledAccessor(this.y()),a.Plot._scaledAccessor(this.y0())),b},d.prototype.selections=function(a){var b=this;void 0===a&&(a=this.datasets());var d=c.prototype.selections.call(this,a)[0],e=a.map(function(a){return b._lineDrawers.get(a)}).filter(function(a){return null!=a});return e.forEach(function(a,b){return d.push(a.selectionForIndex(b).node())}),d3.selectAll(d)},d.prototype._constructAreaProjector=function(b,c,d){var e=this,f=function(b,c,d){var f=a.Plot._scaledAccessor(e.x())(b,c,d),g=a.Plot._scaledAccessor(e.y())(b,c,d);return a.Utils.Math.isValidNumber(f)&&a.Utils.Math.isValidNumber(g)};return function(a,g,h){var i=d3.svg.area().x(function(a,c){return b(a,c,h)}).y1(function(a,b){return c(a,b,h)}).y0(function(a,b){return d(a,b,h)}).interpolate(e.interpolator()).defined(function(a,b){return f(a,b,h)});return i(a)}},d._Y0_KEY="y0",d}(b.Line);b.Area=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(d){void 0===d&&(d=b.Bar.ORIENTATION_VERTICAL),c.call(this,d),this._clusterOffsets=new a.Utils.Map}return e(d,c),d.prototype._generateAttrToProjector=function(){var a=this,b=c.prototype._generateAttrToProjector.call(this),d=this._makeInnerScale(),e=function(a,b){return d.rangeBand()};b.width=this._isVertical?e:b.width,b.height=this._isVertical?b.height:e;var f=b.x,g=b.y;return b.x=this._isVertical?function(b,c,d){return f(b,c,d)+a._clusterOffsets.get(d)}:function(a,b,c){return f(a,b,c)},b.y=this._isVertical?function(a,b,c){return g(a,b,c)}:function(b,c,d){return g(b,c,d)+a._clusterOffsets.get(d)},b},d.prototype._updateClusterPosition=function(){var a=this,b=this._makeInnerScale();this.datasets().forEach(function(c,d){return a._clusterOffsets.set(c,b.scale(String(d))-b.rangeBand()/2)})},d.prototype._makeInnerScale=function(){var b=new a.Scales.Category;b.domain(this.datasets().map(function(a,b){return String(b)}));var c=a.Plot._scaledAccessor(this.attr("width"));return b.range([0,c(null,0,null)]),b},d.prototype._getDataToDraw=function(){return this._updateClusterPosition(),c.prototype._getDataToDraw.call(this)},d}(b.Bar);b.ClusteredBar=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.call(this),this._baselineValue=0,this.addClass("stacked-area-plot"),this.attr("fill-opacity",1),this._stackingResult=new a.Utils.Map,this._stackedExtent=[],this._baselineValueProvider=function(){return[c._baselineValue]}}return e(c,b),c.prototype._getAnimator=function(b){return new a.Animators.Null},c.prototype._setup=function(){b.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},c.prototype.x=function(a,c){return null==a?b.prototype.x.call(this):(null==c?b.prototype.x.call(this,a):b.prototype.x.call(this,a,c),this._updateStackExtentsAndOffsets(),this)},c.prototype.y=function(a,c){return null==a?b.prototype.y.call(this):(null==c?b.prototype.y.call(this,a):b.prototype.y.call(this,a,c),this._updateStackExtentsAndOffsets(),this)},c.prototype.downsamplingEnabled=function(c){return null==c?b.prototype.downsamplingEnabled.call(this):(a.Utils.Window.warn("Warning: Stacked Area Plot does not support downsampling"),this)},c.prototype._additionalPaint=function(){var a=this.y().scale.scale(this._baselineValue),b={x1:0,y1:a,x2:this.width(),y2:a};this._getAnimator("baseline").animate(this._baseline,b)},c.prototype._updateYScale=function(){var a=this.y(),b=a&&a.scale;null!=b&&(b.addPaddingExceptionsProvider(this._baselineValueProvider),b.addIncludedValuesProvider(this._baselineValueProvider))},c.prototype._onDatasetUpdate=function(){return this._updateStackExtentsAndOffsets(),b.prototype._onDatasetUpdate.call(this),this},c.prototype._updateExtentsForProperty=function(a){b.prototype._updateExtentsForProperty.call(this,a),"x"!==a&&"y"!==a||!this._projectorsReady()||this._updateStackExtentsAndOffsets()},c.prototype._extentsForProperty=function(a){var c="y";return a===c?[this._stackedExtent]:b.prototype._extentsForProperty.call(this,a)},c.prototype._updateStackExtentsAndOffsets=function(){if(this._projectorsReady()){var b=this.datasets(),c=this.x().accessor,d=this.y().accessor,e=this._filterForProperty("y");this._checkSameDomain(b,c),this._stackingResult=a.Utils.Stacking.stack(b,c,d),this._stackedExtent=a.Utils.Stacking.stackedExtent(this._stackingResult,c,e)}},c.prototype._checkSameDomain=function(b,d){var e=b.map(function(a){return d3.set(a.data().map(function(b,c){return d(b,c,a).toString()})).values()}),f=c._domainKeys(b,d);e.some(function(a){return a.length!==f.length})&&a.Utils.Window.warn("the domains across the datasets are not the same. Plot may produce unintended behavior.")},c._domainKeys=function(a,b){var c=d3.set();return a.forEach(function(a){a.data().forEach(function(d,e){c.add(b(d,e,a))})}),c.values()},c.prototype._propertyProjectors=function(){var c=this,d=b.prototype._propertyProjectors.call(this),e=this.y().accessor,f=this.x().accessor,g=function(b,c,d){return a.Utils.Stacking.normalizeKey(f(b,c,d))},h=function(a,b,d){return c.y().scale.scale(+e(a,b,d)+c._stackingResult.get(d).get(g(a,b,d)).offset)},i=function(a,b,d){return c.y().scale.scale(c._stackingResult.get(d).get(g(a,b,d)).offset)};return d.d=this._constructAreaProjector(a.Plot._scaledAccessor(this.x()),h,i),d},c.prototype._pixelPoint=function(c,d,e){var f=b.prototype._pixelPoint.call(this,c,d,e),g=this.x().accessor(c,d,e),h=this.y().accessor(c,d,e),i=this.y().scale.scale(+h+this._stackingResult.get(e).get(a.Utils.Stacking.normalizeKey(g)).offset);return{x:f.x,y:i}},c}(b.Area);b.StackedArea=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(d){void 0===d&&(d=b.Bar.ORIENTATION_VERTICAL),c.call(this,d),this.addClass("stacked-bar-plot"),this._stackingResult=new a.Utils.Map,this._stackedExtent=[]}return e(d,c),d.prototype.x=function(a,b){return null==a?c.prototype.x.call(this):(null==b?c.prototype.x.call(this,a):c.prototype.x.call(this,a,b),this._updateStackExtentsAndOffsets(),this)},d.prototype.y=function(a,b){return null==a?c.prototype.y.call(this):(null==b?c.prototype.y.call(this,a):c.prototype.y.call(this,a,b),this._updateStackExtentsAndOffsets(),this)},d.prototype._generateAttrToProjector=function(){var b=this,d=c.prototype._generateAttrToProjector.call(this),e=this._isVertical?"y":"x",f=this._isVertical?"x":"y",g=this._isVertical?this.y().scale:this.x().scale,h=this._propertyBindings.get(e).accessor,i=this._propertyBindings.get(f).accessor,j=function(b,c,d){return a.Utils.Stacking.normalizeKey(i(b,c,d))},k=function(a,c,d){return g.scale(b._stackingResult.get(d).get(j(a,c,d)).offset)},l=function(a,c,d){return g.scale(+h(a,c,d)+b._stackingResult.get(d).get(j(a,c,d)).offset)},m=function(a,b,c){return Math.abs(l(a,b,c)-k(a,b,c))};d[this._isVertical?"height":"width"]=m;var n=function(a,b,c){return+h(a,b,c)<0?k(a,b,c):l(a,b,c)};return d[e]=function(a,c,d){return b._isVertical?n(a,c,d):n(a,c,d)-m(a,c,d)},d},d.prototype._onDatasetUpdate=function(){return this._updateStackExtentsAndOffsets(),c.prototype._onDatasetUpdate.call(this),this},d.prototype._updateExtentsForProperty=function(a){c.prototype._updateExtentsForProperty.call(this,a),"x"!==a&&"y"!==a||!this._projectorsReady()||this._updateStackExtentsAndOffsets()},d.prototype._extentsForProperty=function(a){var b=this._isVertical?"y":"x";return a===b?[this._stackedExtent]:c.prototype._extentsForProperty.call(this,a)},d.prototype._updateStackExtentsAndOffsets=function(){if(this._projectorsReady()){var b=this.datasets(),c=this._isVertical?this.x().accessor:this.y().accessor,d=this._isVertical?this.y().accessor:this.x().accessor,e=this._filterForProperty(this._isVertical?"y":"x");this._stackingResult=a.Utils.Stacking.stack(b,c,d),this._stackedExtent=a.Utils.Stacking.stackedExtent(this._stackingResult,c,e)}},d}(b.Bar);b.StackedBar=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this.addClass("segment-plot"),this.attr("stroke",(new a.Scales.Color).range()[0]),this.attr("stroke-width","2px")}return e(c,b),c.prototype._createDrawer=function(b){return new a.Drawers.Segment(b)},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animators.Null}]},c.prototype._updateExtentsForProperty=function(a){b.prototype._updateExtentsForProperty.call(this,a),"x"===a?b.prototype._updateExtentsForProperty.call(this,"x2"):"y"===a&&b.prototype._updateExtentsForProperty.call(this,"y2")},c.prototype._filterForProperty=function(a){return"x2"===a?b.prototype._filterForProperty.call(this,"x"):"y2"===a?b.prototype._filterForProperty.call(this,"y"):b.prototype._filterForProperty.call(this,a)},c.prototype.x=function(a,d){if(null==a)return b.prototype.x.call(this);if(null==d)b.prototype.x.call(this,a);else{b.prototype.x.call(this,a,d);var e=this.x2(),f=e&&e.accessor;null!=f&&this._bindProperty(c._X2_KEY,f,d)}return this},c.prototype.x2=function(a){if(null==a)return this._propertyBindings.get(c._X2_KEY);var b=this.x(),d=b&&b.scale;return this._bindProperty(c._X2_KEY,a,d),this.render(),this},c.prototype.y=function(a,d){if(null==a)return b.prototype.y.call(this);if(null==d)b.prototype.y.call(this,a);else{b.prototype.y.call(this,a,d);var e=this.y2(),f=e&&e.accessor;null!=f&&this._bindProperty(c._Y2_KEY,f,d)}return this},c.prototype.y2=function(a){if(null==a)return this._propertyBindings.get(c._Y2_KEY);var b=this.y(),d=b&&b.scale;return this._bindProperty(c._Y2_KEY,a,d),this.render(),this},c.prototype._propertyProjectors=function(){var c=b.prototype._propertyProjectors.call(this);return c.x1=a.Plot._scaledAccessor(this.x()),c.x2=null==this.x2()?a.Plot._scaledAccessor(this.x()):a.Plot._scaledAccessor(this.x2()),c.y1=a.Plot._scaledAccessor(this.y()),c.y2=null==this.y2()?a.Plot._scaledAccessor(this.y()):a.Plot._scaledAccessor(this.y2()),c},c.prototype.entitiesIn=function(a,b){var c,d;if(null==b){var e=a;c={min:e.topLeft.x,max:e.bottomRight.x},d={min:e.topLeft.y,max:e.bottomRight.y}}else c=a,d=b;return this._entitiesIntersecting(c,d)},c.prototype._entitiesIntersecting=function(a,b){var c=this,d=[],e=this._generateAttrToProjector();return this.entities().forEach(function(f){c._lineIntersectsBox(f,a,b,e)&&d.push(f)}),d},c.prototype._lineIntersectsBox=function(a,b,c,d){var e=this,f=d.x1(a.datum,a.index,a.dataset),g=d.x2(a.datum,a.index,a.dataset),h=d.y1(a.datum,a.index,a.dataset),i=d.y2(a.datum,a.index,a.dataset);if(b.min<=f&&f<=b.max&&c.min<=h&&h<=c.max||b.min<=g&&g<=b.max&&c.min<=i&&i<=c.max)return!0;var j={x:f,y:h},k={x:g,y:i},l=[{x:b.min,y:c.min},{x:b.min,y:c.max},{x:b.max,y:c.max},{x:b.max,y:c.min}],m=l.filter(function(a,b){return 0!==b?e._lineIntersectsSegment(j,k,a,l[b-1])&&e._lineIntersectsSegment(a,l[b-1],j,k):void 0});return m.length>0},c.prototype._lineIntersectsSegment=function(a,b,c,d){var e=function(a,b,c){return(b.x-a.x)*(c.y-b.y)-(b.y-a.y)*(c.x-b.x)};return e(a,b,c)*e(a,b,d)<0},c._X2_KEY="x2",c._Y2_KEY="y2",c}(a.XYPlot);b.Segment=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this._connectorsEnabled=!1,this.addClass("waterfall-plot")}return e(c,b),c.prototype.connectorsEnabled=function(a){return null==a?this._connectorsEnabled:(this._connectorsEnabled=a,this)},c.prototype.total=function(a){return null==a?this._propertyBindings.get(c._TOTAL_KEY):(this._bindProperty(c._TOTAL_KEY,a,null),this)},c.prototype._additionalPaint=function(b){var c=this;this._connectorArea.selectAll("line").remove(),this._connectorsEnabled&&a.Utils.Window.setTimeout(function(){return c._drawConnectors()},b)},c.prototype._createNodesForDataset=function(a){var d=b.prototype._createNodesForDataset.call(this,a);return this._connectorArea=this._renderArea.append("g").classed(c._CONNECTOR_AREA_CLASS,!0),d},c.prototype._extentsForProperty=function(a){var c="y";return a===c?[this._extent]:b.prototype._extentsForProperty.call(this,a)},c.prototype._generateAttrToProjector=function(){var d=this,e=b.prototype._generateAttrToProjector.call(this),f=this.y().scale,g=a.Plot._scaledAccessor(this.total()),h=this.attr("y");null==h&&(e.y=function(a,b,c){var e=d.y().accessor(a,b,c),h=g(a,b,c);if(h)return Math.min(f.scale(e),f.scale(0));var i=d._subtotals[b];if(0===b)return 0>e?f.scale(i-e):f.scale(i);var j=d._subtotals[b-1];return i>j?f.scale(i):f.scale(j)});var i=this.attr("height");return null==i&&(e.height=function(a,b,c){var e=g(a,b,c),h=d.y().accessor(a,b,c);if(e)return Math.abs(f.scale(h)-f.scale(0));var i=d._subtotals[b];if(0===b)return Math.abs(f.scale(i)-f.scale(i-h));var j=d._subtotals[b-1];return Math.abs(f.scale(i)-f.scale(j))}),e["class"]=function(a,b,e){var f="";null!=d.attr("class")&&(f=d.attr("class").accessor(a,b,e)+" ");var h=g(a,b,e);if(h)return f+c._BAR_TOTAL_CLASS;var i=d.y().accessor(a,b,e);return f+(i>0?c._BAR_GROWTH_CLASS:c._BAR_DECLINE_CLASS)},e},c.prototype._onDatasetUpdate=function(){return this._updateSubtotals(),b.prototype._onDatasetUpdate.call(this),this},c.prototype._calculateSubtotalsAndExtent=function(a){var b=this,c=Number.MAX_VALUE,d=Number.MIN_VALUE,e=0,f=!1;a.data().forEach(function(g,h){var i=b.y().accessor(g,h,a),j=b.total().accessor(g,h,a);if(j&&0!==h||(e+=i),b._subtotals.push(e),c>e&&(c=e),e>d&&(d=e),j&&(c>i&&(c=i),i>d&&(d=i)),!f&&j){for(var k=i-e,l=0;l0&&this._subtotals[d]>this._subtotals[e]||this._subtotals[d]<0&&this._subtotals[d]>=this._subtotals[e])&&(j=a.y(f,d,b)+a.height(f,d,b)),this._connectorArea.append("line").classed(c._CONNECTOR_CLASS,!0).attr("x1",h).attr("x2",i).attr("y1",j).attr("y2",j)}},c.prototype._updateSubtotals=function(){var a=this.datasets();if(a.length>0){var b=a[a.length-1];this._subtotals=new Array,this._calculateSubtotalsAndExtent(b)}},c._BAR_DECLINE_CLASS="waterfall-decline",c._BAR_GROWTH_CLASS="waterfall-growth",c._BAR_TOTAL_CLASS="waterfall-total",c._CONNECTOR_CLASS="connector",c._CONNECTOR_AREA_CLASS="connector-area",c._TOTAL_KEY="total",c}(b.Bar);b.Waterfall=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){b.call(this),this.addClass("wheel-plot"),this.attr("fill",(new a.Scales.Color).range()[0])}return e(c,b),c.prototype.computeLayout=function(a,c,d){b.prototype.computeLayout.call(this,a,c,d),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")");var e=Math.min(this.width(),this.height())/2;return null!=this.r()&&null!=this.r().scale&&this.r().scale.range([0,e]),null!=this.r2()&&null!=this.r2().scale&&this.r2().scale.range([0,e]),this},c.prototype._createDrawer=function(b){return new a.Drawers.Arc(b)},c.prototype.entities=function(a){var c=this;void 0===a&&(a=this.datasets());var d=b.prototype.entities.call(this,a);return d.forEach(function(a){a.position.x+=c.width()/2,a.position.y+=c.height()/2}),d},c.prototype._getDataToDraw=function(){var c=b.prototype._getDataToDraw.call(this);if(0===this.datasets().length)return c;var d=a.Plot._scaledAccessor(this.t()),e=a.Plot._scaledAccessor(this.t2()),f=a.Plot._scaledAccessor(this.r()),g=a.Plot._scaledAccessor(this.r2()),h=this.datasets()[0],i=c.get(h),j=i.filter(function(b,c){return a.Utils.Math.isValidNumber(d(b,c,h))&&a.Utils.Math.isValidNumber(e(b,c,h))&&a.Utils.Math.isValidNumber(f(b,c,h))&&a.Utils.Math.isValidNumber(g(b,c,h))&&f(b,c,h)>=0&&g(b,c,h)>=0});return c.set(h,j),c},c.prototype._propertyProjectors=function(){var c=b.prototype._propertyProjectors.call(this),d=a.Plot._scaledAccessor(this.r()),e=a.Plot._scaledAccessor(this.r2()),f=a.Plot._scaledAccessor(this.t()),g=a.Plot._scaledAccessor(this.t2());return c.d=function(b,c,h){var i=f(b,c,h),j=g(b,c,h);return i>j&&(j+=360*(Math.floor((i-j)/360)+1)),d3.svg.arc().innerRadius(d(b,c,h)).outerRadius(e(b,c,h)).startAngle(a.Utils.Math.degreesToRadians(i)).endAngle(a.Utils.Math.degreesToRadians(j))(b,c)},c},c.prototype.t=function(b,d){if(null==b)return this._propertyBindings.get(c._T_KEY);if(null!=d){if(!a.QuantitativeScale.prototype.isPrototypeOf(d))throw new Error("scale needs to inherit from Scale.QuantitativeScale");d.range([0,360]),d.padProportion(0)}var e=this.t2(),f=e&&e.accessor;return null!=f&&this._bindProperty(c._T2_KEY,f,d),this._bindProperty(c._T_KEY,b,d),this.render(),this},c.prototype.t2=function(a){if(null==a)return this._propertyBindings.get(c._T2_KEY);var b=this.t(),d=b&&b.scale;return this._bindProperty(c._T2_KEY,a,d),this.render(),this},c.prototype.r=function(b,d){if(null==b)return this._propertyBindings.get(c._R_KEY);if(null!=d&&!a.QuantitativeScale.prototype.isPrototypeOf(d))throw new Error("scale needs to inherit from Scale.QuantitativeScale");var e=this.r2(),f=e&&e.accessor;return null!=f&&this._bindProperty(c._R2_KEY,f,d),this._bindProperty(c._R_KEY,b,d),this.render(),this},c.prototype.r2=function(a){if(null==a)return this._propertyBindings.get(c._R2_KEY);var b=this.r(),d=b&&b.scale;return this._bindProperty(c._R2_KEY,a,d),this.render(),this},c.prototype._pixelPoint=function(b,c,d){var e=a.Plot._scaledAccessor(this.r())(b,c,d),f=a.Plot._scaledAccessor(this.r2())(b,c,d),g=e>=0&&f>=0?(e+f)/2:NaN,h=a.Plot._scaledAccessor(this.t())(b,c,d),i=a.Plot._scaledAccessor(this.t2())(b,c,d),j=a.Utils.Math.degreesToRadians((h+i)/2);return{x:g*Math.sin(j),y:-g*Math.cos(j)}},c._R_KEY="r",c._R2_KEY="r2",c._T_KEY="t",c._T2_KEY="t2",c}(a.Plot);b.Wheel=c}(b=a.Plots||(a.Plots={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.totalTime=function(a){return 0},a.prototype.animate=function(a,b){return a.attr(b)},a}();a.Null=b}(b=a.Animators||(a.Animators={}))}(d||(d={}));var d;!function(a){var b;!function(a){var b=function(){function a(){this._startDelay=a._DEFAULT_START_DELAY_MILLISECONDS,this._stepDuration=a._DEFAULT_STEP_DURATION_MILLISECONDS,this._stepDelay=a._DEFAULT_ITERATIVE_DELAY_MILLISECONDS,this._maxTotalDuration=a._DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS,this._easingMode=a._DEFAULT_EASING_MODE}return a.prototype.totalTime=function(a){var b=this._getAdjustedIterativeDelay(a);return this.startDelay()+b*Math.max(a-1,0)+this.stepDuration()},a.prototype.animate=function(a,b){var c=this,d=a[0].length,e=this._getAdjustedIterativeDelay(d);return a.transition().ease(this.easingMode()).duration(this.stepDuration()).delay(function(a,b){return c.startDelay()+e*b}).attr(b)},a.prototype.startDelay=function(a){return null==a?this._startDelay:(this._startDelay=a,this)},a.prototype.stepDuration=function(a){return null==a?Math.min(this._stepDuration,this._maxTotalDuration):(this._stepDuration=a,this)},a.prototype.stepDelay=function(a){return null==a?this._stepDelay:(this._stepDelay=a,this)},a.prototype.maxTotalDuration=function(a){return null==a?this._maxTotalDuration:(this._maxTotalDuration=a,this)},a.prototype.easingMode=function(a){return null==a?this._easingMode:(this._easingMode=a,this)},a.prototype._getAdjustedIterativeDelay=function(a){var b=this.maxTotalDuration()-this.stepDuration();b=Math.max(b,0);var c=b/Math.max(a-1,1);return Math.min(this.stepDelay(),c)},a._DEFAULT_START_DELAY_MILLISECONDS=0,a._DEFAULT_STEP_DURATION_MILLISECONDS=300,a._DEFAULT_ITERATIVE_DELAY_MILLISECONDS=15,a._DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS=1/0,a._DEFAULT_EASING_MODE="exp-out",a}();a.Easing=b}(b=a.Animators||(a.Animators={}))}(d||(d={}));var d;!function(a){var b=function(){function a(){this._eventToCallback={},this._callbacks=[],this._connected=!1}return a.prototype._hasNoListeners=function(){return this._callbacks.every(function(a){return 0===a.size})},a.prototype._connect=function(){var a=this;this._connected||(Object.keys(this._eventToCallback).forEach(function(b){var c=a._eventToCallback[b];document.addEventListener(b,c)}),this._connected=!0)},a.prototype._disconnect=function(){var a=this;this._connected&&this._hasNoListeners()&&(Object.keys(this._eventToCallback).forEach(function(b){var c=a._eventToCallback[b];document.removeEventListener(b,c)}),this._connected=!1)},a.prototype._setCallback=function(a,b){this._connect(),a.add(b)},a.prototype._unsetCallback=function(a,b){a["delete"](b),this._disconnect()},a}();a.Dispatcher=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;b.call(this),this._translator=a.Utils.ClientToSVGTranslator.getTranslator(c),this._lastMousePosition={x:-1,y:-1},this._moveCallbacks=new a.Utils.CallbackSet,this._downCallbacks=new a.Utils.CallbackSet,this._upCallbacks=new a.Utils.CallbackSet,this._wheelCallbacks=new a.Utils.CallbackSet,this._dblClickCallbacks=new a.Utils.CallbackSet,this._callbacks=[this._moveCallbacks,this._downCallbacks,this._upCallbacks,this._wheelCallbacks,this._dblClickCallbacks];var e=function(a){return d._measureAndDispatch(a,d._moveCallbacks,"page")};this._eventToCallback.mouseover=e,this._eventToCallback.mousemove=e,this._eventToCallback.mouseout=e,this._eventToCallback.mousedown=function(a){return d._measureAndDispatch(a,d._downCallbacks)},this._eventToCallback.mouseup=function(a){return d._measureAndDispatch(a,d._upCallbacks,"page")},this._eventToCallback.wheel=function(a){return d._measureAndDispatch(a,d._wheelCallbacks)},this._eventToCallback.dblclick=function(a){return d._measureAndDispatch(a,d._dblClickCallbacks)}}return e(c,b),c.getDispatcher=function(b){var d=a.Utils.DOM.boundingSVG(b),e=d[c._DISPATCHER_KEY];return null==e&&(e=new c(d),d[c._DISPATCHER_KEY]=e),e},c.prototype.onMouseMove=function(a){return this._setCallback(this._moveCallbacks,a),this},c.prototype.offMouseMove=function(a){return this._unsetCallback(this._moveCallbacks,a),this},c.prototype.onMouseDown=function(a){return this._setCallback(this._downCallbacks,a),this},c.prototype.offMouseDown=function(a){return this._unsetCallback(this._downCallbacks,a),this},c.prototype.onMouseUp=function(a){return this._setCallback(this._upCallbacks,a),this},c.prototype.offMouseUp=function(a){return this._unsetCallback(this._upCallbacks,a),this},c.prototype.onWheel=function(a){return this._setCallback(this._wheelCallbacks,a),this},c.prototype.offWheel=function(a){return this._unsetCallback(this._wheelCallbacks,a),this},c.prototype.onDblClick=function(a){return this._setCallback(this._dblClickCallbacks,a),this},c.prototype.offDblClick=function(a){ +return this._unsetCallback(this._dblClickCallbacks,a),this},c.prototype._measureAndDispatch=function(a,b,c){if(void 0===c&&(c="element"),"page"!==c&&"element"!==c)throw new Error("Invalid scope '"+c+"', must be 'element' or 'page'");if("page"===c||this.eventInsideSVG(a)){var d=this._translator.computePosition(a.clientX,a.clientY);null!=d&&(this._lastMousePosition=d,b.callCallbacks(this.lastMousePosition(),a))}},c.prototype.eventInsideSVG=function(a){return this._translator.insideSVG(a)},c.prototype.lastMousePosition=function(){return this._lastMousePosition},c._DISPATCHER_KEY="__Plottable_Dispatcher_Mouse",c}(a.Dispatcher);b.Mouse=c}(b=a.Dispatchers||(a.Dispatchers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;b.call(this),this._translator=a.Utils.ClientToSVGTranslator.getTranslator(c),this._startCallbacks=new a.Utils.CallbackSet,this._moveCallbacks=new a.Utils.CallbackSet,this._endCallbacks=new a.Utils.CallbackSet,this._cancelCallbacks=new a.Utils.CallbackSet,this._callbacks=[this._moveCallbacks,this._startCallbacks,this._endCallbacks,this._cancelCallbacks],this._eventToCallback.touchstart=function(a){return d._measureAndDispatch(a,d._startCallbacks,"page")},this._eventToCallback.touchmove=function(a){return d._measureAndDispatch(a,d._moveCallbacks,"page")},this._eventToCallback.touchend=function(a){return d._measureAndDispatch(a,d._endCallbacks,"page")},this._eventToCallback.touchcancel=function(a){return d._measureAndDispatch(a,d._cancelCallbacks,"page")}}return e(c,b),c.getDispatcher=function(b){var d=a.Utils.DOM.boundingSVG(b),e=d[c._DISPATCHER_KEY];return null==e&&(e=new c(d),d[c._DISPATCHER_KEY]=e),e},c.prototype.onTouchStart=function(a){return this._setCallback(this._startCallbacks,a),this},c.prototype.offTouchStart=function(a){return this._unsetCallback(this._startCallbacks,a),this},c.prototype.onTouchMove=function(a){return this._setCallback(this._moveCallbacks,a),this},c.prototype.offTouchMove=function(a){return this._unsetCallback(this._moveCallbacks,a),this},c.prototype.onTouchEnd=function(a){return this._setCallback(this._endCallbacks,a),this},c.prototype.offTouchEnd=function(a){return this._unsetCallback(this._endCallbacks,a),this},c.prototype.onTouchCancel=function(a){return this._setCallback(this._cancelCallbacks,a),this},c.prototype.offTouchCancel=function(a){return this._unsetCallback(this._cancelCallbacks,a),this},c.prototype._measureAndDispatch=function(a,b,c){if(void 0===c&&(c="element"),"page"!==c&&"element"!==c)throw new Error("Invalid scope '"+c+"', must be 'element' or 'page'");if("element"!==c||this.eventInsideSVG(a)){for(var d=a.changedTouches,e={},f=[],g=0;g0&&b.callCallbacks(f,e,a)}},c.prototype.eventInsideSVG=function(a){return this._translator.insideSVG(a)},c._DISPATCHER_KEY="__Plottable_Dispatcher_Touch",c}(a.Dispatcher);b.Touch=c}(b=a.Dispatchers||(a.Dispatchers={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.call(this),this._eventToCallback.keydown=function(a){return c._processKeydown(a)},this._eventToCallback.keyup=function(a){return c._processKeyup(a)},this._keydownCallbacks=new a.Utils.CallbackSet,this._keyupCallbacks=new a.Utils.CallbackSet,this._callbacks=[this._keydownCallbacks,this._keyupCallbacks]}return e(c,b),c.getDispatcher=function(){var a=document[c._DISPATCHER_KEY];return null==a&&(a=new c,document[c._DISPATCHER_KEY]=a),a},c.prototype.onKeyDown=function(a){return this._setCallback(this._keydownCallbacks,a),this},c.prototype.offKeyDown=function(a){return this._unsetCallback(this._keydownCallbacks,a),this},c.prototype.onKeyUp=function(a){return this._setCallback(this._keyupCallbacks,a),this},c.prototype.offKeyUp=function(a){return this._unsetCallback(this._keyupCallbacks,a),this},c.prototype._processKeydown=function(a){this._keydownCallbacks.callCallbacks(a.keyCode,a)},c.prototype._processKeyup=function(a){this._keyupCallbacks.callCallbacks(a.keyCode,a)},c._DISPATCHER_KEY="__Plottable_Dispatcher_Key",c}(a.Dispatcher);b.Key=c}(b=a.Dispatchers||(a.Dispatchers={}))}(d||(d={}));var d;!function(a){var b=function(){function a(){var a=this;this._anchorCallback=function(b){return a._anchor(b)},this._enabled=!0}return a.prototype._anchor=function(a){this._isAnchored=!0},a.prototype._unanchor=function(){this._isAnchored=!1},a.prototype.attachTo=function(a){return this._disconnect(),this._componentAttachedTo=a,this._connect(),this},a.prototype._connect=function(){this.enabled()&&null!=this._componentAttachedTo&&!this._isAnchored&&this._componentAttachedTo.onAnchor(this._anchorCallback)},a.prototype.detachFrom=function(a){return this._disconnect(),this._componentAttachedTo=null,this},a.prototype._disconnect=function(){this._isAnchored&&this._unanchor(),null!=this._componentAttachedTo&&this._componentAttachedTo.offAnchor(this._anchorCallback)},a.prototype.enabled=function(a){return null==a?this._enabled:(this._enabled=a,this._enabled?this._connect():this._disconnect(),this)},a.prototype._translateToComponentSpace=function(a){var b=this._componentAttachedTo.originToSVG();return{x:a.x-b.x,y:a.y-b.y}},a.prototype._isInsideComponent=function(a){return 0<=a.x&&0<=a.y&&a.x<=this._componentAttachedTo.width()&&a.y<=this._componentAttachedTo.height()},a}();a.Interaction=b}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.apply(this,arguments),this._clickedDown=!1,this._onClickCallbacks=new a.Utils.CallbackSet,this._mouseDownCallback=function(a){return c._handleClickDown(a)},this._mouseUpCallback=function(a){return c._handleClickUp(a)},this._touchStartCallback=function(a,b){return c._handleClickDown(b[a[0]])},this._touchEndCallback=function(a,b){return c._handleClickUp(b[a[0]])},this._touchCancelCallback=function(a,b){return c._clickedDown=!1}}return e(c,b),c.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(c.content().node()),this._mouseDispatcher.onMouseDown(this._mouseDownCallback),this._mouseDispatcher.onMouseUp(this._mouseUpCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(c.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback),this._touchDispatcher.onTouchEnd(this._touchEndCallback),this._touchDispatcher.onTouchCancel(this._touchCancelCallback)},c.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._mouseDispatcher.offMouseDown(this._mouseDownCallback),this._mouseDispatcher.offMouseUp(this._mouseUpCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher.offTouchEnd(this._touchEndCallback),this._touchDispatcher.offTouchCancel(this._touchCancelCallback),this._touchDispatcher=null},c.prototype._handleClickDown=function(a){var b=this._translateToComponentSpace(a);this._isInsideComponent(b)&&(this._clickedDown=!0)},c.prototype._handleClickUp=function(a){var b=this._translateToComponentSpace(a);this._clickedDown&&this._isInsideComponent(b)&&this._onClickCallbacks.callCallbacks(b),this._clickedDown=!1},c.prototype.onClick=function(a){return this._onClickCallbacks.add(a),this},c.prototype.offClick=function(a){return this._onClickCallbacks["delete"](a),this},c}(a.Interaction);b.Click=c}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c;!function(a){a[a.NotClicked=0]="NotClicked",a[a.SingleClicked=1]="SingleClicked",a[a.DoubleClicked=2]="DoubleClicked"}(c||(c={}));var d=function(b){function d(){var d=this;b.apply(this,arguments),this._clickState=c.NotClicked,this._clickedDown=!1,this._onDoubleClickCallbacks=new a.Utils.CallbackSet,this._mouseDownCallback=function(a){return d._handleClickDown(a)},this._mouseUpCallback=function(a){return d._handleClickUp(a)},this._dblClickCallback=function(a){return d._handleDblClick()},this._touchStartCallback=function(a,b){return d._handleClickDown(b[a[0]])},this._touchEndCallback=function(a,b){return d._handleClickUp(b[a[0]])},this._touchCancelCallback=function(a,b){return d._handleClickCancel()}}return e(d,b),d.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(c.content().node()),this._mouseDispatcher.onMouseDown(this._mouseDownCallback),this._mouseDispatcher.onMouseUp(this._mouseUpCallback),this._mouseDispatcher.onDblClick(this._dblClickCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(c.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback),this._touchDispatcher.onTouchEnd(this._touchEndCallback),this._touchDispatcher.onTouchCancel(this._touchCancelCallback)},d.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._mouseDispatcher.offMouseDown(this._mouseDownCallback),this._mouseDispatcher.offMouseUp(this._mouseUpCallback),this._mouseDispatcher.offDblClick(this._dblClickCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher.offTouchEnd(this._touchEndCallback),this._touchDispatcher.offTouchCancel(this._touchCancelCallback),this._touchDispatcher=null},d.prototype._handleClickDown=function(a){var b=this._translateToComponentSpace(a);this._isInsideComponent(b)&&(this._clickState===c.SingleClicked&&d._pointsEqual(b,this._clickedPoint)||(this._clickState=c.NotClicked),this._clickedPoint=b,this._clickedDown=!0)},d.prototype._handleClickUp=function(a){var b=this._translateToComponentSpace(a);this._clickedDown&&d._pointsEqual(b,this._clickedPoint)?this._clickState=this._clickState===c.NotClicked?c.SingleClicked:c.DoubleClicked:this._clickState=c.NotClicked,this._clickedDown=!1},d.prototype._handleDblClick=function(){this._clickState===c.DoubleClicked&&(this._onDoubleClickCallbacks.callCallbacks(this._clickedPoint),this._clickState=c.NotClicked)},d.prototype._handleClickCancel=function(){this._clickState=c.NotClicked,this._clickedDown=!1},d._pointsEqual=function(a,b){return a.x===b.x&&a.y===b.y},d.prototype.onDoubleClick=function(a){return this._onDoubleClickCallbacks.add(a),this},d.prototype.offDoubleClick=function(a){return this._onDoubleClickCallbacks["delete"](a),this},d}(a.Interaction);b.DoubleClick=d}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.apply(this,arguments),this._keyPressCallbacks={},this._keyReleaseCallbacks={},this._mouseMoveCallback=function(a){return!1},this._downedKeys=new a.Utils.Set,this._keyDownCallback=function(a,b){return c._handleKeyDownEvent(a,b)},this._keyUpCallback=function(a){return c._handleKeyUpEvent(a)}}return e(c,b),c.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._positionDispatcher=a.Dispatchers.Mouse.getDispatcher(this._componentAttachedTo._element.node()),this._positionDispatcher.onMouseMove(this._mouseMoveCallback),this._keyDispatcher=a.Dispatchers.Key.getDispatcher(),this._keyDispatcher.onKeyDown(this._keyDownCallback),this._keyDispatcher.onKeyUp(this._keyUpCallback)},c.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._positionDispatcher.offMouseMove(this._mouseMoveCallback),this._positionDispatcher=null,this._keyDispatcher.offKeyDown(this._keyDownCallback),this._keyDispatcher.offKeyUp(this._keyUpCallback),this._keyDispatcher=null},c.prototype._handleKeyDownEvent=function(a,b){var c=this._translateToComponentSpace(this._positionDispatcher.lastMousePosition());this._isInsideComponent(c)&&!b.repeat&&(this._keyPressCallbacks[a]&&this._keyPressCallbacks[a].callCallbacks(a),this._downedKeys.add(a))},c.prototype._handleKeyUpEvent=function(a){this._downedKeys.has(a)&&this._keyReleaseCallbacks[a]&&this._keyReleaseCallbacks[a].callCallbacks(a),this._downedKeys["delete"](a)},c.prototype.onKeyPress=function(b,c){return this._keyPressCallbacks[b]||(this._keyPressCallbacks[b]=new a.Utils.CallbackSet),this._keyPressCallbacks[b].add(c),this},c.prototype.offKeyPress=function(a,b){return this._keyPressCallbacks[a]["delete"](b),0===this._keyPressCallbacks[a].size&&delete this._keyPressCallbacks[a],this},c.prototype.onKeyRelease=function(b,c){return this._keyReleaseCallbacks[b]||(this._keyReleaseCallbacks[b]=new a.Utils.CallbackSet),this._keyReleaseCallbacks[b].add(c),this},c.prototype.offKeyRelease=function(a,b){return this._keyReleaseCallbacks[a]["delete"](b),0===this._keyReleaseCallbacks[a].size&&delete this._keyReleaseCallbacks[a],this},c}(a.Interaction);b.Key=c}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(){var c=this;b.apply(this,arguments),this._insideComponent=!1,this._pointerEnterCallbacks=new a.Utils.CallbackSet,this._pointerMoveCallbacks=new a.Utils.CallbackSet,this._pointerExitCallbacks=new a.Utils.CallbackSet,this._mouseMoveCallback=function(a,b){return c._handleMouseEvent(a,b)},this._touchStartCallback=function(a,b,d){return c._handleTouchEvent(b[a[0]],d)}}return e(c,b),c.prototype._anchor=function(c){b.prototype._anchor.call(this,c),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(this._componentAttachedTo.content().node()),this._mouseDispatcher.onMouseMove(this._mouseMoveCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(this._componentAttachedTo.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback)},c.prototype._unanchor=function(){b.prototype._unanchor.call(this),this._mouseDispatcher.offMouseMove(this._mouseMoveCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher=null},c.prototype._handleMouseEvent=function(a,b){var c=this._mouseDispatcher.eventInsideSVG(b);this._handlePointerEvent(a,c)},c.prototype._handleTouchEvent=function(a,b){var c=this._touchDispatcher.eventInsideSVG(b);this._handlePointerEvent(a,c)},c.prototype._handlePointerEvent=function(a,b){var c=this._translateToComponentSpace(a),d=this._isInsideComponent(c);d&&b?(this._insideComponent||this._pointerEnterCallbacks.callCallbacks(c),this._pointerMoveCallbacks.callCallbacks(c)):this._insideComponent&&this._pointerExitCallbacks.callCallbacks(c),this._insideComponent=d&&b},c.prototype.onPointerEnter=function(a){return this._pointerEnterCallbacks.add(a),this},c.prototype.offPointerEnter=function(a){return this._pointerEnterCallbacks["delete"](a),this},c.prototype.onPointerMove=function(a){return this._pointerMoveCallbacks.add(a),this},c.prototype.offPointerMove=function(a){return this._pointerMoveCallbacks["delete"](a),this},c.prototype.onPointerExit=function(a){return this._pointerExitCallbacks.add(a),this},c.prototype.offPointerExit=function(a){return this._pointerExitCallbacks["delete"](a),this},c}(a.Interaction);b.Pointer=c}(b=a.Interactions||(a.Interactions={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(c){function d(d,e){var f=this;c.call(this),this._wheelCallback=function(a,b){return f._handleWheelEvent(a,b)},this._touchStartCallback=function(a,b,c){return f._handleTouchStart(a,b,c)},this._touchMoveCallback=function(a,b,c){return f._handlePinch(a,b,c)},this._touchEndCallback=function(a,b,c){return f._handleTouchEnd(a,b,c)},this._touchCancelCallback=function(a,b,c){return f._handleTouchEnd(a,b,c)},this._xScales=new a.Utils.Set,this._yScales=new a.Utils.Set,this._dragInteraction=new b.Drag,this._setupDragInteraction(),this._touchIds=d3.map(),this._minDomainExtents=new a.Utils.Map,this._maxDomainExtents=new a.Utils.Map,null!=d&&this.addXScale(d),null!=e&&this.addYScale(e)}return e(d,c),d.prototype._anchor=function(b){c.prototype._anchor.call(this,b),this._dragInteraction.attachTo(b),this._mouseDispatcher=a.Dispatchers.Mouse.getDispatcher(this._componentAttachedTo.content().node()),this._mouseDispatcher.onWheel(this._wheelCallback),this._touchDispatcher=a.Dispatchers.Touch.getDispatcher(this._componentAttachedTo.content().node()),this._touchDispatcher.onTouchStart(this._touchStartCallback),this._touchDispatcher.onTouchMove(this._touchMoveCallback),this._touchDispatcher.onTouchEnd(this._touchEndCallback),this._touchDispatcher.onTouchCancel(this._touchCancelCallback)},d.prototype._unanchor=function(){c.prototype._unanchor.call(this),this._mouseDispatcher.offWheel(this._wheelCallback),this._mouseDispatcher=null,this._touchDispatcher.offTouchStart(this._touchStartCallback),this._touchDispatcher.offTouchMove(this._touchMoveCallback),this._touchDispatcher.offTouchEnd(this._touchEndCallback),this._touchDispatcher.offTouchCancel(this._touchCancelCallback),this._touchDispatcher=null,this._dragInteraction.detachFrom(this._componentAttachedTo)},d.prototype._handleTouchStart=function(a,b,c){for(var d=0;d1,d=c?this.maxDomainExtent(a):this.minDomainExtent(a);if(null==d)return b;var e=a.domain(),f=Math.abs(e[1]-e[0]),g=c?Math.min:Math.max;return g(b,d/f)},d.prototype._setupDragInteraction=function(){var a=this;this._dragInteraction.constrainedToComponent(!1);var b;this._dragInteraction.onDragStart(function(){return b=null}),this._dragInteraction.onDrag(function(c,d){if(!(a._touchIds.size()>=2)){var e=(null==b?c.x:b.x)-d.x;a.xScales().forEach(function(b){a._translateScale(b,e)});var f=(null==b?c.y:b.y)-d.y;a.yScales().forEach(function(b){a._translateScale(b,f)}),b=d}})},d.prototype._nonLinearScaleWithExtents=function(b){return!(null==this.minDomainExtent(b)||null==this.maxDomainExtent(b)||b instanceof a.Scales.Linear||b instanceof a.Scales.Time)},d.prototype.xScales=function(b){var c=this;if(null==b){var d=[];return this._xScales.forEach(function(a){d.push(a)}),d}return this._xScales=new a.Utils.Set,b.forEach(function(a){c.addXScale(a)}),this},d.prototype.yScales=function(b){var c=this;if(null==b){var d=[];return this._yScales.forEach(function(a){d.push(a)}),d}return this._yScales=new a.Utils.Set,b.forEach(function(a){c.addYScale(a)}),this},d.prototype.addXScale=function(a){return this._xScales.add(a),this},d.prototype.removeXScale=function(a){return this._xScales["delete"](a),this._minDomainExtents["delete"](a),this._maxDomainExtents["delete"](a),this},d.prototype.addYScale=function(a){return this._yScales.add(a),this},d.prototype.removeYScale=function(a){return this._yScales["delete"](a),this._minDomainExtents["delete"](a),this._maxDomainExtents["delete"](a),this},d.prototype.minDomainExtent=function(b,c){if(null==c)return this._minDomainExtents.get(b);if(c.valueOf()<0)throw new Error("extent must be non-negative");var d=this.maxDomainExtent(b);if(null!=d&&d.valueOf()a)throw new Error("detection radius cannot be negative.");return this._detectionRadius=a,this.render(),this},d.prototype.resizable=function(a){return null==a?this._resizable:(this._resizable=a,this._setResizableClasses(a),this)},d.prototype._setResizableClasses=function(a){a&&this.enabled()?(this.addClass("x-resizable"),this.addClass("y-resizable")):(this.removeClass("x-resizable"),this.removeClass("y-resizable"))},d.prototype.movable=function(a){return null==a?this._movable:(this._movable=a,this._setMovableClass(),this)},d.prototype._setMovableClass=function(){this.movable()&&this.enabled()?this.addClass("movable"):this.removeClass("movable")},d.prototype.onDragStart=function(a){return this._dragStartCallbacks.add(a),this},d.prototype.offDragStart=function(a){return this._dragStartCallbacks["delete"](a),this},d.prototype.onDrag=function(a){return this._dragCallbacks.add(a),this},d.prototype.offDrag=function(a){ +return this._dragCallbacks["delete"](a),this},d.prototype.onDragEnd=function(a){return this._dragEndCallbacks.add(a),this},d.prototype.offDragEnd=function(a){return this._dragEndCallbacks["delete"](a),this},d.prototype.dragInteraction=function(){return this._dragInteraction},d.prototype.enabled=function(a){return null==a?this._dragInteraction.enabled():(this._dragInteraction.enabled(a),this._setResizableClasses(this.resizable()),this._setMovableClass(),this)},d.prototype.destroy=function(){var a=this;c.prototype.destroy.call(this),this._dragStartCallbacks.forEach(function(b){return a._dragCallbacks["delete"](b)}),this._dragCallbacks.forEach(function(b){return a._dragCallbacks["delete"](b)}),this._dragEndCallbacks.forEach(function(b){return a._dragEndCallbacks["delete"](b)}),this._disconnectInteraction()},d.prototype.detach=function(){return this._resetState(),this._dragInteraction.detachFrom(this),c.prototype.detach.call(this)},d.prototype.anchor=function(a){return this._dragInteraction.attachTo(this),c.prototype.anchor.call(this,a)},d.prototype._resetState=function(){this.bounds({topLeft:{x:0,y:0},bottomRight:{x:0,y:0}})},d}(b.SelectionBoxLayer);b.DragBoxLayer=c}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.addClass("x-drag-box-layer"),this._hasCorners=!1}return e(b,a),b.prototype.computeLayout=function(b,c,d){return a.prototype.computeLayout.call(this,b,c,d),this._setBounds(this.bounds()),this},b.prototype._setBounds=function(b){a.prototype._setBounds.call(this,{topLeft:{x:b.topLeft.x,y:0},bottomRight:{x:b.bottomRight.x,y:this.height()}})},b.prototype._setResizableClasses=function(a){a&&this.enabled()?this.addClass("x-resizable"):this.removeClass("x-resizable")},b.prototype.yScale=function(b){if(null==b)return a.prototype.yScale.call(this);throw new Error("yScales cannot be set on an XDragBoxLayer")},b.prototype.yExtent=function(b){if(null==b)return a.prototype.yExtent.call(this);throw new Error("XDragBoxLayer has no yExtent")},b}(a.DragBoxLayer);a.XDragBoxLayer=b}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.addClass("y-drag-box-layer"),this._hasCorners=!1}return e(b,a),b.prototype.computeLayout=function(b,c,d){return a.prototype.computeLayout.call(this,b,c,d),this._setBounds(this.bounds()),this},b.prototype._setBounds=function(b){a.prototype._setBounds.call(this,{topLeft:{x:0,y:b.topLeft.y},bottomRight:{x:this.width(),y:b.bottomRight.y}})},b.prototype._setResizableClasses=function(a){a&&this.enabled()?this.addClass("y-resizable"):this.removeClass("y-resizable")},b.prototype.xScale=function(b){if(null==b)return a.prototype.xScale.call(this);throw new Error("xScales cannot be set on an YDragBoxLayer")},b.prototype.xExtent=function(b){if(null==b)return a.prototype.xExtent.call(this);throw new Error("YDragBoxLayer has no xExtent")},b}(a.DragBoxLayer);a.YDragBoxLayer=b}(b=a.Components||(a.Components={}))}(d||(d={}));var d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){var b;!function(b){var c=function(b){function c(c){var d=this;b.call(this,c),this._detectionRadius=3,this._enabled=!0,this.addClass("drag-line-layer"),this.addClass("enabled"),this._dragInteraction=new a.Interactions.Drag,this._dragInteraction.attachTo(this);var e=function(a){return d._isVertical()&&d.pixelPosition()-d.detectionRadius()<=a.x&&a.x<=d.pixelPosition()+d.detectionRadius()||!d._isVertical()&&d.pixelPosition()-d.detectionRadius()<=a.y&&a.y<=d.pixelPosition()+d.detectionRadius()},f=!1,g=function(a){e(a)&&(f=!0,d._dragStartCallbacks.callCallbacks(d))};this._dragInteraction.onDragStart(g);var h=function(a,b){f&&(d._setPixelPositionWithoutChangingMode(d._isVertical()?b.x:b.y),d._dragCallbacks.callCallbacks(d))};this._dragInteraction.onDrag(h);var i=function(a,b){f&&(f=!1,d._dragEndCallbacks.callCallbacks(d))};this._dragInteraction.onDragEnd(i),this._disconnectInteraction=function(){d._dragInteraction.offDragStart(g),d._dragInteraction.offDrag(h),d._dragInteraction.offDragEnd(i),d._dragInteraction.detachFrom(d)},this._dragStartCallbacks=new a.Utils.CallbackSet,this._dragCallbacks=new a.Utils.CallbackSet,this._dragEndCallbacks=new a.Utils.CallbackSet}return e(c,b),c.prototype._setup=function(){b.prototype._setup.call(this),this._detectionEdge=this.content().append("line").style({opacity:0,stroke:"pink","pointer-events":"visibleStroke"}).classed("drag-edge",!0)},c.prototype.renderImmediately=function(){return b.prototype.renderImmediately.call(this),this._detectionEdge.attr({x1:this._isVertical()?this.pixelPosition():0,y1:this._isVertical()?0:this.pixelPosition(),x2:this._isVertical()?this.pixelPosition():this.width(),y2:this._isVertical()?this.height():this.pixelPosition(),"stroke-width":2*this._detectionRadius}),this},c.prototype.detectionRadius=function(a){if(null==a)return this._detectionRadius;if(0>a)throw new Error("detection radius cannot be negative.");return this._detectionRadius=a,this.render(),this},c.prototype.enabled=function(a){return null==a?this._enabled:(this._enabled=a,a?this.addClass("enabled"):this.removeClass("enabled"),this._dragInteraction.enabled(a),this)},c.prototype.onDragStart=function(a){return this._dragStartCallbacks.add(a),this},c.prototype.offDragStart=function(a){return this._dragStartCallbacks["delete"](a),this},c.prototype.onDrag=function(a){return this._dragCallbacks.add(a),this},c.prototype.offDrag=function(a){return this._dragCallbacks["delete"](a),this},c.prototype.onDragEnd=function(a){return this._dragEndCallbacks.add(a),this},c.prototype.offDragEnd=function(a){return this._dragEndCallbacks["delete"](a),this},c.prototype.destroy=function(){var a=this;b.prototype.destroy.call(this),this._dragStartCallbacks.forEach(function(b){return a._dragStartCallbacks["delete"](b)}),this._dragCallbacks.forEach(function(b){return a._dragCallbacks["delete"](b)}),this._dragEndCallbacks.forEach(function(b){return a._dragEndCallbacks["delete"](b)}),this._disconnectInteraction()},c}(b.GuideLineLayer);b.DragLineLayer=c}(b=a.Components||(a.Components={}))}(d||(d={}));var f;!function(a){var b;!function(a){var b;!function(a){function b(a,b){if(null==a||null==b)return a===b;if(a.length!==b.length)return!1;for(var c=0;c0&&"\n"===b[0]?"\n":"";if(g>=c){var i=g/3,j=Math.floor(c/i);return{wrappedToken:h+"...".substr(0,j),remainingToken:b}}for(;f+g>c;)e=a.Utils.StringMethods.trimEnd(e.substr(0,e.length-1)),f=d.measure(e).width;return{wrappedToken:h+e+"...",remainingToken:a.Utils.StringMethods.trimEnd(b.substring(e.length),"-").trim()}},b.prototype.wrapNextToken=function(b,c,d){if(!c.canFitText||c.availableLines===c.wrapping.noLines||!this.canFitToken(b,c.availableWidth,d))return this.finishWrapping(b,c,d);for(var e=b;e;){var f=this.breakTokenToFitInWidth(e,c.currentLine,c.availableWidth,d);if(c.currentLine=f.line,e=f.remainingToken,null!=e){if(c.wrapping.noBrokeWords+=+f.breakWord,++c.wrapping.noLines,c.availableLines===c.wrapping.noLines){var g=this.addEllipsis(c.currentLine,c.availableWidth,d);return c.wrapping.wrappedText+=g.wrappedToken,c.wrapping.truncatedText+=g.remainingToken+e,c.currentLine="\n",c}c.wrapping.wrappedText+=a.Utils.StringMethods.trimEnd(c.currentLine),c.currentLine="\n"}}return c},b.prototype.finishWrapping=function(a,b,c){if(b.canFitText&&b.availableLines!==b.wrapping.noLines&&this._allowBreakingWords&&"none"!==this._textTrimming){var d=this.addEllipsis(b.currentLine+a,b.availableWidth,c);b.wrapping.wrappedText+=d.wrappedToken,b.wrapping.truncatedText+=d.remainingToken,b.wrapping.noBrokeWords+=+(d.remainingToken.length0),b.currentLine=""}else b.wrapping.truncatedText+=a;return b.canFitText=!1,b},b.prototype.breakTokenToFitInWidth=function(a,b,c,d,e){if(void 0===e&&(e=this._breakingCharacter),d.measure(b+a).width<=c)return{remainingToken:null,line:b+a,breakWord:!1};if(""===a.trim())return{remainingToken:"",line:b,breakWord:!1};if(!this._allowBreakingWords)return{remainingToken:a,line:b,breakWord:!1};for(var f=0;f0&&(g=e),{remainingToken:a.substring(f),line:b+a.substring(0,f)+g,breakWord:f>0}},b}();b.Wrapper=c}(b=a.Wrappers||(a.Wrappers={}))}(f||(f={}));var f,e=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};!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments)}return e(b,a),b.prototype.wrap=function(c,d,e,f){var g=this;void 0===f&&(f=1/0);var h=c.split("\n");if(h.length>1)throw new Error("SingleLineWrapper is designed to work only on single line");var i=function(b){return a.prototype.wrap.call(g,c,d,b,f)},j=i(e);if(j.noLines<2)return j;for(var k=0,l=e,m=0;mk;++m){var n=(l+k)/2,o=i(n);this.areSameResults(j,o)?(l=n,j=o):k=n}return j},b.prototype.areSameResults=function(a,b){return a.noLines===b.noLines&&a.truncatedText===b.truncatedText},b.NO_WRAP_ITERATIONS=5,b}(a.Wrapper);a.SingleLineWrapper=b}(b=a.Wrappers||(a.Wrappers={}))}(f||(f={}));var f;!function(a){var b;!function(b){var c=function(){function b(a,c){this._writerID=b.nextID++,this._elementID=0,this.measurer(a),c&&this.wrapper(c),this.addTitleElement(!1)}return b.prototype.measurer=function(a){return this._measurer=a,this},b.prototype.wrapper=function(a){return this._wrapper=a,this},b.prototype.addTitleElement=function(a){return this._addTitleElement=a,this},b.prototype.writeLine=function(c,d,e,f,g){var h=d.append("text");h.text(c);var i=e*b.XOffsetFactor[f],j=b.AnchorConverter[f];h.attr("text-anchor",j).classed("text-line",!0),a.Utils.DOM.transform(h,i,g).attr("y","-0.25em")},b.prototype.writeText=function(a,c,d,e,f,g){var h=this,i=a.split("\n"),j=this._measurer.measure().height,k=b.YOffsetFactor[g]*(e-i.length*j);i.forEach(function(a,b){h.writeLine(a,c,d,f,(b+1)*j+k)})},b.prototype.write=function(a,c,d,e){if(-1===b.SupportedRotation.indexOf(e.textRotation))throw new Error("unsupported rotation - "+e.textRotation);var f=Math.abs(Math.abs(e.textRotation)-90)>45,g=f?c:d,h=f?d:c,i=e.selection.append("g").classed("text-container",!0);this._addTitleElement&&i.append("title").text(a);var j=i.append("g").classed("text-area",!0),k=this._wrapper?this._wrapper.wrap(a,this._measurer,g,h).wrappedText:a;this.writeText(k,j,g,h,e.xAlign,e.yAlign);var l=d3.transform(""),m=d3.transform("");switch(l.rotate=e.textRotation,e.textRotation){case 90:l.translate=[c,0],m.rotate=-90,m.translate=[0,200];break;case-90:l.translate=[0,d],m.rotate=90,m.translate=[c,0];break;case 180:l.translate=[c,d],m.translate=[c,d],m.rotate=180}j.attr("transform",l.toString()),this.addClipPath(i,m),e.animator&&e.animator.animate(i)},b.prototype.addClipPath=function(b,c){var d=this._elementID++,e=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;e=e.split("#")[0];var f="clipPath"+this._writerID+"_"+d;b.select(".text-area").attr("clip-path",'url("'+e+"#"+f+'")');var g=b.append("clipPath").attr("id",f),h=a.Utils.DOM.getBBox(b.select(".text-area")),i=g.append("rect");i.classed("clip-rect",!0).attr({x:h.x,y:h.y,width:h.width,height:h.height})},b.nextID=0,b.SupportedRotation=[-90,0,180,90],b.AnchorConverter={left:"start",center:"middle",right:"end"},b.XOffsetFactor={left:0,center:.5,right:1},b.YOffsetFactor={top:0,center:.5,bottom:1},b}();b.Writer=c}(b=a.Writers||(a.Writers={}))}(f||(f={}));var f;!function(a){var b;!function(b){var c=function(){function b(a,b){this.textMeasurer=this.getTextMeasurer(a,b)}return b.prototype.checkSelectionIsText=function(a){return"text"===a[0][0].tagName||!a.select("text").empty()},b.prototype.getTextMeasurer=function(a,b){var c=this;if(this.checkSelectionIsText(a)){var d,e=a.node().parentNode;return d="text"===a[0][0].tagName?a:a.select("text"),a.remove(),function(b){e.appendChild(a.node());var f=c.measureBBox(d,b);return a.remove(),f}}var f=a.append("text");return b&&f.classed(b,!0),f.remove(),function(b){a.node().appendChild(f.node());var d=c.measureBBox(f,b);return f.remove(),d}},b.prototype.measureBBox=function(b,c){b.text(c);var d=a.Utils.DOM.getBBox(b);return{width:d.width,height:d.height}},b.prototype.measure=function(a){return void 0===a&&(a=b.HEIGHT_TEXT),this.textMeasurer(a)},b.HEIGHT_TEXT="bqpdl",b}();b.AbstractMeasurer=c}(b=a.Measurers||(a.Measurers={}))}(f||(f={}));var f,e=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};!function(a){var b;!function(a){var b=function(b){function c(a,c,d){void 0===c&&(c=null),void 0===d&&(d=!1),b.call(this,a,c),this.useGuards=d}return e(c,b),c.prototype._addGuards=function(b){return a.AbstractMeasurer.HEIGHT_TEXT+b+a.AbstractMeasurer.HEIGHT_TEXT},c.prototype.getGuardWidth=function(){return null==this.guardWidth&&(this.guardWidth=b.prototype.measure.call(this).width),this.guardWidth},c.prototype._measureLine=function(a){var c=this.useGuards?this._addGuards(a):a,d=b.prototype.measure.call(this,c);return d.width-=this.useGuards?2*this.getGuardWidth():0,d},c.prototype.measure=function(b){var c=this;if(void 0===b&&(b=a.AbstractMeasurer.HEIGHT_TEXT),""===b.trim())return{width:0,height:0};var d=b.trim().split("\n").map(function(a){return c._measureLine(a)});return{width:d3.max(d,function(a){return a.width}),height:d3.sum(d,function(a){return a.height})}},c}(a.AbstractMeasurer);a.Measurer=b}(b=a.Measurers||(a.Measurers={}))}(f||(f={}));var f,e=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};!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments)}return e(b,a),b.prototype._measureCharacter=function(b){return a.prototype._measureLine.call(this,b)},b.prototype._measureLine=function(a){var b=this,c=a.split("").map(function(a){return b._measureCharacter(a)});return{width:d3.sum(c,function(a){return a.width}),height:d3.max(c,function(a){return a.height})}},b}(a.Measurer);a.CharacterMeasurer=b}(b=a.Measurers||(a.Measurers={}))}(f||(f={}));var f,e=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};return function(a){var b;!function(b){var c=function(b){function c(c,d){var e=this;b.call(this,c,d),this.cache=new a.Utils.Cache(function(a){return e._measureCharacterNotFromCache(a)},a.Utils.Methods.objEq)}return e(c,b),c.prototype._measureCharacterNotFromCache=function(a){return b.prototype._measureCharacter.call(this,a)},c.prototype._measureCharacter=function(a){return this.cache.get(a)},c.prototype.reset=function(){this.cache.clear()},c}(b.CharacterMeasurer);b.CacheCharacterMeasurer=c}(b=a.Measurers||(a.Measurers={}))}(f||(f={})),d}); \ No newline at end of file diff --git a/plottable.zip b/plottable.zip index 280b98edea..c9a285654b 100644 Binary files a/plottable.zip and b/plottable.zip differ diff --git a/src/axes/axis.ts b/src/axes/axis.ts index 1020b6859d..762e5ddf58 100644 --- a/src/axes/axis.ts +++ b/src/axes/axis.ts @@ -37,7 +37,9 @@ export class Axis extends Component { protected _scale: Scale; private _formatter: Formatter; private _orientation: string; + // @deprecated As of release v1.15.0, removed as premature optimization, use _computeWidth() directly instead protected _computedWidth: number; + // @deprecated As of release v1.15.0, removed as premature optimization, use _computeHeight() directly instead protected _computedHeight: number; private _endTickLength = 5; private _innerTickLength = 5; @@ -110,19 +112,13 @@ export class Axis extends Component { let requestedHeight = 0; if (this._isHorizontal()) { - if (this._computedHeight == null) { - this._computeHeight(); - } - requestedHeight = this._computedHeight + this._margin; + requestedHeight = this._computeHeight() + this._margin; if (this.annotationsEnabled()) { let tierHeight = this._annotationMeasurer.measure().height + 2 * Axis._ANNOTATION_LABEL_PADDING; requestedHeight += tierHeight * this.annotationTierCount(); } } else { // vertical - if (this._computedWidth == null) { - this._computeWidth(); - } - requestedWidth = this._computedWidth + this._margin; + requestedWidth = this._computeWidth() + this._margin; if (this.annotationsEnabled()) { let tierHeight = this._annotationMeasurer.measure().height + 2 * Axis._ANNOTATION_LABEL_PADDING; requestedWidth += tierHeight * this.annotationTierCount(); @@ -417,7 +413,7 @@ export class Axis extends Component { */ protected _coreSize() { let relevantDimension = this._isHorizontal() ? this.height() : this.width(); - let axisHeightWithoutMargin = this._isHorizontal() ? this._computedHeight : this._computedWidth; + let axisHeightWithoutMargin = this._isHorizontal() ? this._computeHeight() : this._computeWidth(); return Math.min(axisHeightWithoutMargin, relevantDimension); } @@ -536,12 +532,6 @@ export class Axis extends Component { return tickMarkAttrHash; } - public redraw() { - this._computedWidth = null; - this._computedHeight = null; - return super.redraw(); - } - protected _setDefaultAlignment() { switch (this._orientation) { case "bottom": diff --git a/src/axes/timeAxis.ts b/src/axes/timeAxis.ts index c7c02e7c37..29ad3b77d4 100644 --- a/src/axes/timeAxis.ts +++ b/src/axes/timeAxis.ts @@ -392,9 +392,16 @@ export module Axes { let tickLabelsEnter = tickLabels.enter().append("g").classed(Axis.TICK_LABEL_CLASS, true); tickLabelsEnter.append("text"); let xTranslate = (this._tierLabelPositions[index] === "center" || config.step === 1) ? 0 : this.tickLabelPadding(); - let yTranslate = this.orientation() === "bottom" ? - d3.sum(this._tierHeights.slice(0, index + 1)) - this.tickLabelPadding() : - this.height() - d3.sum(this._tierHeights.slice(0, index)) - this.tickLabelPadding(); + let yTranslate: number; + if (this.orientation() === "bottom") { + yTranslate = d3.sum(this._tierHeights.slice(0, index + 1)) - this.tickLabelPadding(); + } else { + if (this._tierLabelPositions[index] === "center") { + yTranslate = this.height() - d3.sum(this._tierHeights.slice(0, index)) - this.tickLabelPadding() - this._maxLabelTickLength(); + } else { + yTranslate = this.height() - d3.sum(this._tierHeights.slice(0, index)) - this.tickLabelPadding(); + } + } let textSelection = tickLabels.selectAll("text"); if (textSelection.size() > 0) { diff --git a/src/components/legend.ts b/src/components/legend.ts index ecd16f17a2..18dfe402cd 100644 --- a/src/components/legend.ts +++ b/src/components/legend.ts @@ -48,7 +48,10 @@ export module Components { this._colorScale.onUpdate(this._redrawCallback); this._formatter = Formatters.identity(); this.xAlignment("right").yAlignment("top"); - this.comparator((a: string, b: string) => 0); + this.comparator((a: string, b: string) => { + let formattedText = this._colorScale.domain().slice().map((d: string) => this._formatter(d)); + return formattedText.indexOf(a) - formattedText.indexOf(b); + }); this._symbolFactoryAccessor = () => SymbolFactories.circle(); this._symbolOpacityAccessor = () => 1; } diff --git a/src/plots/barPlot.ts b/src/plots/barPlot.ts index 2109f4b4f9..9020e09144 100644 --- a/src/plots/barPlot.ts +++ b/src/plots/barPlot.ts @@ -99,8 +99,9 @@ export module Plots { } public render() { - super.render(); this._updateBarPixelWidth(); + this._updateExtents(); + super.render(); return this; } diff --git a/src/plots/linePlot.ts b/src/plots/linePlot.ts index d68cbabf83..d40f9313b2 100644 --- a/src/plots/linePlot.ts +++ b/src/plots/linePlot.ts @@ -15,6 +15,8 @@ export module Plots { private _autorangeSmooth = false; private _croppedRenderingEnabled = true; + private _downsamplingEnabled = false; + /** * A Line Plot draws line segments starting from the first data point to the next. * @@ -138,6 +140,25 @@ export module Plots { this.render(); return this; } + /** + * Gets if downsampling is enabled + * + * When downsampling is enabled, two consecutive lines with the same slope will be merged to one line. + */ + public downsamplingEnabled(): boolean; + /** + * Sets if downsampling is enabled + * + * @returns {Plots.Line} The calling Plots.Line + */ + public downsamplingEnabled(downsampling: boolean): Plots.Line; + public downsamplingEnabled(downsampling?: boolean): any { + if (downsampling == null) { + return this._downsamplingEnabled; + } + this._downsamplingEnabled = downsampling; + return this; + } /** * Gets if croppedRendering is enabled @@ -375,15 +396,18 @@ export module Plots { this.datasets().forEach((dataset) => { let data = dataset.data(); - if (!this._croppedRenderingEnabled) { + if (!this._croppedRenderingEnabled && !this._downsamplingEnabled) { dataToDraw.set(dataset, [data]); return; } let filteredDataIndices = data.map((d, i) => i); - - filteredDataIndices = this._filterCroppedRendering(dataset, filteredDataIndices); - + if (this._croppedRenderingEnabled) { + filteredDataIndices = this._filterCroppedRendering(dataset, filteredDataIndices); + } + if (this._downsamplingEnabled) { + filteredDataIndices = this._filterDownsampling(dataset, filteredDataIndices); + } dataToDraw.set(dataset, [filteredDataIndices.map((d, i) => data[d])]); }); @@ -425,6 +449,70 @@ export module Plots { return filteredDataIndices; } + private _filterDownsampling(dataset: Dataset, indices: number[]) { + if (indices.length === 0) { + return []; + } + let data = dataset.data(); + let scaledXAccessor = Plot._scaledAccessor(this.x()); + let scaledYAccessor = Plot._scaledAccessor(this.y()); + let filteredIndices = [indices[0]]; + + let indexOnCurrentSlope = (i: number, currentSlope: number) => { + let p1x = scaledXAccessor(data[indices[i]], indices[i], dataset); + let p1y = scaledYAccessor(data[indices[i]], indices[i], dataset); + let p2x = scaledXAccessor(data[indices[i + 1]], indices[i + 1], dataset); + let p2y = scaledYAccessor(data[indices[i + 1]], indices[i + 1], dataset); + if (currentSlope === Infinity) { + return Math.floor(p1x) === Math.floor(p2x); + } else { + let expectedP2y = p1y + (p2x - p1x) * currentSlope; + return Math.floor(p2y) === Math.floor(expectedP2y); + } + }; + + for (let i = 0; i < indices.length - 1; ) { + let indexFirst = indices[i]; + let p1x = scaledXAccessor(data[indices[i]], indices[i], dataset); + let p1y = scaledYAccessor(data[indices[i]], indices[i], dataset); + let p2x = scaledXAccessor(data[indices[i + 1]], indices[i + 1], dataset); + let p2y = scaledYAccessor(data[indices[i + 1]], indices[i + 1], dataset); + let currentSlope = (Math.floor(p1x) === Math.floor(p2x)) ? Infinity : (p2y - p1y) / (p2x - p1x); + let indexMin = indices[i]; + let minScaledValue = (currentSlope === Infinity) ? p1y : p1x; + let indexMax = indexMin; + let maxScaledValue = minScaledValue; + let firstIndexOnCurrentSlope = true; + + while (i < indices.length - 1 && (firstIndexOnCurrentSlope || indexOnCurrentSlope(i, currentSlope))) { + i++; + firstIndexOnCurrentSlope = false; + let currScaledValue = currentSlope === Infinity ? scaledYAccessor(data[indices[i]], indices[i], dataset) : + scaledXAccessor(data[indices[i]], indices[i], dataset); + if (currScaledValue > maxScaledValue) { + maxScaledValue = currScaledValue; + indexMax = indices[i]; + } + if (currScaledValue < minScaledValue) { + minScaledValue = currScaledValue; + indexMin = indices[i]; + } + } + + let indexLast = indices[i]; + + if (indexMin !== indexFirst) { + filteredIndices.push(indexMin); + } + if (indexMax !== indexMin && indexMax !== indexFirst) { + filteredIndices.push(indexMax); + } + if (indexLast !== indexFirst && indexLast !== indexMin && indexLast !== indexMax) { + filteredIndices.push(indexLast); + } + } + return filteredIndices; + } } } } diff --git a/src/plots/stackedAreaPlot.ts b/src/plots/stackedAreaPlot.ts index da4b4ffed5..e543433122 100644 --- a/src/plots/stackedAreaPlot.ts +++ b/src/plots/stackedAreaPlot.ts @@ -67,6 +67,27 @@ export module Plots { return this; } + /** + * Gets if downsampling is enabled + * + * When downsampling is enabled, two consecutive lines with the same slope will be merged to one line. + */ + public downsamplingEnabled(): boolean; + /** + * Sets if downsampling is enabled + * + * For now, downsampling is always disabled in stacked area plot + * @returns {Plots.StackedArea} The calling Plots.StackedArea + */ + public downsamplingEnabled(downsampling: boolean): Plots.Line; + public downsamplingEnabled(downsampling?: boolean): any { + if (downsampling == null) { + return super.downsamplingEnabled(); + } + Utils.Window.warn("Warning: Stacked Area Plot does not support downsampling"); + return this; + } + protected _additionalPaint() { let scaledBaseline = this.y().scale.scale(this._baselineValue); let baselineAttr: any = { diff --git a/src/utils/domUtils.ts b/src/utils/domUtils.ts index 2dd7817ec5..7c6225277f 100644 --- a/src/utils/domUtils.ts +++ b/src/utils/domUtils.ts @@ -111,10 +111,10 @@ export module Utils { * @returns {boolean} If the ClientRects overlap each other. */ export function clientRectsOverlap(clientRectA: ClientRect, clientRectB: ClientRect) { - if (clientRectA.right < clientRectB.left) { return false; } - if (clientRectA.left > clientRectB.right) { return false; } - if (clientRectA.bottom < clientRectB.top) { return false; } - if (clientRectA.top > clientRectB.bottom) { return false; } + if (nativeMath.floor(clientRectA.right) <= nativeMath.ceil(clientRectB.left)) { return false; } + if (nativeMath.ceil(clientRectA.left) >= nativeMath.floor(clientRectB.right)) { return false; } + if (nativeMath.floor(clientRectA.bottom) <= nativeMath.ceil(clientRectB.top)) { return false; } + if (nativeMath.ceil(clientRectA.top) >= nativeMath.floor(clientRectB.bottom)) { return false; } return true; } diff --git a/test/axes/numericAxisTests.ts b/test/axes/numericAxisTests.ts index 4dde2a63b0..3f99278e74 100644 --- a/test/axes/numericAxisTests.ts +++ b/test/axes/numericAxisTests.ts @@ -97,7 +97,7 @@ describe("NumericAxis", () => { let markCenter = (markBB.top + markBB.bottom) / 2; labelBB = tickLabels[0][i].getBoundingClientRect(); let labelCenter = (labelBB.top + labelBB.bottom) / 2; - assert.closeTo(labelCenter, markCenter, 1, "tick label is centered on mark"); + assert.closeTo(labelCenter, markCenter, 1.5, "tick label is centered on mark"); } // labels to top diff --git a/test/axes/timeAxisTests.ts b/test/axes/timeAxisTests.ts index c018c08548..cb764050f5 100644 --- a/test/axes/timeAxisTests.ts +++ b/test/axes/timeAxisTests.ts @@ -146,23 +146,63 @@ describe("TimeAxis", () => { svg.remove(); }); - it("tick labels do not overlap with tick marks", () => { - let svg = TestMethods.generateSVG(400, 100); - scale = new Plottable.Scales.Time(); - scale.domain([new Date("2009-12-20"), new Date("2011-01-01")]); - axis = new Plottable.Axes.Time(scale, "bottom"); - axis.renderTo(svg); - let tickRects = d3.selectAll("." + Plottable.Axis.TICK_MARK_CLASS)[0].map((mark: Element) => mark.getBoundingClientRect()); - let labelRects = d3.selectAll("." + Plottable.Axis.TICK_LABEL_CLASS) - .filter(function(d: Element, i: number) { - return d3.select(this).style("visibility") === "visible"; - })[0].map((label: Element) => label.getBoundingClientRect()); - labelRects.forEach(function(labelRect: ClientRect) { - tickRects.forEach(function(tickRect: ClientRect) { - assert.isFalse(Plottable.Utils.DOM.clientRectsOverlap(labelRect, tickRect), "visible label does not overlap with a tick"); + describe("tick labels and tick marks do not overlap", () => { + function assertTickMarksAndLabelsDoNotOverlap() { + let tickMarks = d3.selectAll(`.${Plottable.Axis.TICK_MARK_CLASS}:not(.${Plottable.Axis.END_TICK_MARK_CLASS})`); + assert.operator(tickMarks.size(), ">=", 1, "There is at least one tick mark in the test"); + let tickLabels = d3.selectAll(`.${Plottable.Axis.TICK_LABEL_CLASS}`).filter(function(d, i) { + return d3.select(this).style("visibility") !== "hidden"; + }); + assert.operator(tickLabels.size(), ">=", 1, "There is at least one tick label in the test"); + tickMarks.each(function(tickMark, i) { + let tickMarkRect = this.getBoundingClientRect(); + tickLabels.each(function(tickLabel, j) { + let tickLabelRect = this.getBoundingClientRect(); + let isOverlap = Plottable.Utils.DOM.clientRectsOverlap(tickMarkRect, tickLabelRect); + assert.isFalse(isOverlap, `Tick mark "${tickMark}" should not overlap with tick label "${this.textContent}"`); + }); }); + } + + it("tick labels do not overlap with tick marks in bottom orientation when tier label position is set to between", () => { + let svg = TestMethods.generateSVG(400, 100); + scale.domain([new Date("2010-01-01"), new Date("2014-01-01")]); + axis = new Plottable.Axes.Time(scale, "bottom"); + axis.tierLabelPositions(["between", "between"]); + axis.renderTo(svg); + assertTickMarksAndLabelsDoNotOverlap(); + svg.remove(); + }); + + it("tick labels do not overlap with tick marks in bottom orientation when tier label position is set to center", () => { + let svg = TestMethods.generateSVG(400, 100); + scale.domain([new Date("2010-01-01"), new Date("2014-01-01")]); + axis = new Plottable.Axes.Time(scale, "bottom"); + axis.tierLabelPositions(["center", "center"]); + axis.renderTo(svg); + assertTickMarksAndLabelsDoNotOverlap(); + svg.remove(); + }); + + it("tick labels do not overlap with tick marks in top orientation when tier label position is set to between", () => { + let svg = TestMethods.generateSVG(400, 100); + scale.domain([new Date("2010-01-01"), new Date("2014-01-01")]); + axis = new Plottable.Axes.Time(scale, "top"); + axis.tierLabelPositions(["between", "between"]); + axis.renderTo(svg); + assertTickMarksAndLabelsDoNotOverlap(); + svg.remove(); + }); + + it("tick labels do not overlap with tick marks in top orientation when tier label position is set to center", () => { + let svg = TestMethods.generateSVG(400, 100); + scale.domain([new Date("2010-01-01"), new Date("2014-01-01")]); + axis = new Plottable.Axes.Time(scale, "top"); + axis.tierLabelPositions(["center", "center"]); + axis.renderTo(svg); + assertTickMarksAndLabelsDoNotOverlap(); + svg.remove(); }); - svg.remove(); }); it("if the time only uses one tier, there should be no space left for the second tier", () => { diff --git a/test/components/legendTests.ts b/test/components/legendTests.ts index 22306f5a86..c05071807f 100644 --- a/test/components/legendTests.ts +++ b/test/components/legendTests.ts @@ -291,6 +291,15 @@ describe("Legend", () => { svg.remove(); }); + it("does not change the order of legend entries when using default comparator", () => { + let colorDomain = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"]; + color.domain(colorDomain); + legend.renderTo(svg); + let entryTexts = legend.content().selectAll(entrySelector).data(); + assert.deepEqual(colorDomain, entryTexts, "displayed texts should have the same order as the legend domain"); + svg.remove(); + }); + describe("entitiesAt()", () => { function computeExpectedSymbolPosition(legend: Plottable.Components.Legend, rowIndex: number, entryIndexWithinRow: number) { let row = d3.select(legend.content().selectAll(rowSelector)[0][rowIndex]); diff --git a/test/core/symbolFactoriesTests.ts b/test/core/symbolFactoriesTests.ts new file mode 100644 index 0000000000..ac547ad263 --- /dev/null +++ b/test/core/symbolFactoriesTests.ts @@ -0,0 +1,102 @@ +/// + +describe("SymbolFactory", () => { + describe("Generates correct path", () => { + let svg: d3.Selection; + let symbolSize = 5; + + beforeEach(() => { + svg = TestMethods.generateSVG(); + }); + + it("returns a circle factory that generates circle based on symbolSize", () => { + let circleFactory = Plottable.SymbolFactories.circle(); + let actualSize = Math.PI * Math.pow(symbolSize / 2, 2); + let d = circleFactory(symbolSize); + let expectedD = d3.svg.symbol().type("circle").size(actualSize)(null); + assert.strictEqual(d, expectedD, "a circle of set size is generated"); + let path = svg.append("path").attr("d", d); + let bbox = Plottable.Utils.DOM.elementBBox(path); + assert.strictEqual(bbox.height, symbolSize, "height is as set"); + assert.strictEqual(bbox.width, symbolSize, "width is as set"); + assert.strictEqual(bbox.x, -bbox.width / 2, "x is centered in the middle"); + assert.strictEqual(bbox.y, -bbox.height / 2, "y is centered in the middle"); + svg.remove(); + }); + + it("returns a square factory that generates square based on symbolSize", () => { + let squareFactory = Plottable.SymbolFactories.square(); + let actualSize = Math.pow(symbolSize, 2); + let d = squareFactory(symbolSize); + let expectedD = d3.svg.symbol().type("square").size(actualSize)(null); + assert.strictEqual(d, expectedD, "a square of set size is generated"); + let path = svg.append("path").attr("d", d); + let bbox = Plottable.Utils.DOM.elementBBox(path); + assert.strictEqual(bbox.height, symbolSize, " is as set"); + assert.strictEqual(bbox.width, symbolSize, "width is as set"); + assert.strictEqual(bbox.x, -bbox.width / 2, "x is centered in the middle"); + assert.strictEqual(bbox.y, -bbox.height / 2, "y is centered in the middle"); + svg.remove(); + }); + + it("returns a cross factory that generates cross based on symbolSize", () => { + let crossFactory = Plottable.SymbolFactories.cross(); + let actualSize = (5 / 9) * Math.pow(symbolSize, 2); + let d = crossFactory(symbolSize); + let expectedD = d3.svg.symbol().type("cross").size(actualSize)(null); + assert.strictEqual(d, expectedD, "a cross of set size is generated"); + let path = svg.append("path").attr("d", d); + let bbox = Plottable.Utils.DOM.elementBBox(path); + assert.strictEqual(bbox.height, symbolSize, "height is as set"); + assert.strictEqual(bbox.width, symbolSize, "width is as set"); + assert.strictEqual(bbox.x, -bbox.width / 2, "x is centered in the middle"); + assert.strictEqual(bbox.y, -bbox.height / 2, "y is centered in the middle"); + svg.remove(); + }); + + it("returns a diamond factory that generates diamond based on symbolSize", () => { + let diamondFactory = Plottable.SymbolFactories.diamond(); + let actualSize = Math.tan(Math.PI / 6) * Math.pow(symbolSize, 2) / 2; + let d = diamondFactory(symbolSize); + let expectedD = d3.svg.symbol().type("diamond").size(actualSize)(null); + assert.strictEqual(d, expectedD, "a diamond of set size is generated"); + let path = svg.append("path").attr("d", d); + let bbox = Plottable.Utils.DOM.elementBBox(path); + assert.strictEqual(bbox.height, symbolSize, "height is as set"); + assert.operator(bbox.width, "<", symbolSize, "width is as set"); + assert.strictEqual(bbox.x, -bbox.width / 2, "x is centered in the middle"); + assert.strictEqual(bbox.y, -bbox.height / 2, "y is centered in the middle"); + svg.remove(); + }); + + it("returns an up triangle factory that generates up triangle based on symbolSize", () => { + let triangleUpFactory = Plottable.SymbolFactories.triangleUp(); + let actualSize = Math.sqrt(3) * Math.pow(symbolSize / 2, 2); + let d = triangleUpFactory(symbolSize); + let expectedD = d3.svg.symbol().type("triangle-up").size(actualSize)(null); + assert.strictEqual(d, expectedD, "a up triangle of set size is generated"); + let path = svg.append("path").attr("d", d); + let bbox = Plottable.Utils.DOM.elementBBox(path); + assert.operator(bbox.height, "<", symbolSize, "height is as set"); + assert.strictEqual(bbox.width, symbolSize, "width is as set"); + assert.strictEqual(bbox.x, -bbox.width / 2, "x is centered in the middle"); + assert.strictEqual(bbox.y, -bbox.height / 2, "y is centered in the middle"); + svg.remove(); + }); + + it("returns a down triangle factory that generates down triangle based on symbolSize", () => { + let triangleDownFactory = Plottable.SymbolFactories.triangleDown(); + let actualSize = Math.sqrt(3) * Math.pow(symbolSize / 2, 2); + let d = triangleDownFactory(symbolSize); + let expectedD = d3.svg.symbol().type("triangle-down").size(actualSize)(null); + assert.strictEqual(d, expectedD, "a down triangle of set size is generated"); + let path = svg.append("path").attr("d", d); + let bbox = Plottable.Utils.DOM.elementBBox(path); + assert.operator(bbox.height, "<", symbolSize, "height is as set"); + assert.strictEqual(bbox.width, symbolSize, "width is as set"); + assert.strictEqual(bbox.x, -bbox.width / 2, "x is centered in the middle"); + assert.strictEqual(bbox.y, -bbox.height / 2, "y is centered in the middle"); + svg.remove(); + }); + }); +}); diff --git a/test/interactions/panZoomInteractionTests.ts b/test/interactions/panZoomInteractionTests.ts index 9c8afe9e0f..70a154f4a0 100644 --- a/test/interactions/panZoomInteractionTests.ts +++ b/test/interactions/panZoomInteractionTests.ts @@ -1,348 +1,584 @@ /// describe("Interactions", () => { - describe("PanZoomInteraction", () => { - let svg: d3.Selection; - let SVG_WIDTH = 400; - let SVG_HEIGHT = 500; - - let component: Plottable.Component; - let eventTarget: d3.Selection; - - let xScale: Plottable.QuantitativeScale; - let yScale: Plottable.QuantitativeScale; - let panZoomInteraction: Plottable.Interactions.PanZoom; - - beforeEach(() => { - svg = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT); - - component = new Plottable.Component(); - component.renderTo(svg); - - xScale = new Plottable.Scales.Linear(); - xScale.domain([0, SVG_WIDTH / 2]).range([0, SVG_WIDTH]); - yScale = new Plottable.Scales.Linear(); - yScale.domain([0, SVG_HEIGHT / 2]).range([0, SVG_HEIGHT]); - panZoomInteraction = new Plottable.Interactions.PanZoom(); - panZoomInteraction.addXScale(xScale); - panZoomInteraction.addYScale(yScale); - panZoomInteraction.attachTo(component); - - eventTarget = component.background(); + describe("PanZoom Interaction", () => { + + describe("Scale setting", () => { + let xScale: Plottable.QuantitativeScale; + let yScale: Plottable.QuantitativeScale; + let panZoomInteraction: Plottable.Interactions.PanZoom; + + beforeEach(() => { + xScale = new Plottable.Scales.Linear(); + yScale = new Plottable.Scales.Linear(); + + panZoomInteraction = new Plottable.Interactions.PanZoom(); + }); + + it("can set scales", () => { + assert.deepEqual(panZoomInteraction.xScales(), [], "no xScales exist by default"); + assert.deepEqual(panZoomInteraction.yScales(), [], "no yScales exist by default"); + + assert.strictEqual(panZoomInteraction.addXScale(xScale), panZoomInteraction, "setting the xScale returns the interaction"); + assert.strictEqual(panZoomInteraction.addYScale(yScale), panZoomInteraction, "setting the yScale returns the interaction"); + + assert.deepEqual(panZoomInteraction.xScales(), [xScale], "xScale has been added"); + assert.deepEqual(panZoomInteraction.yScales(), [yScale], "yScale has been added"); + }); + + it("can remove scales", () => { + panZoomInteraction.addXScale(xScale); + panZoomInteraction.addYScale(yScale); + + assert.deepEqual(panZoomInteraction.xScales(), [xScale], "xScale has been added"); + assert.deepEqual(panZoomInteraction.yScales(), [yScale], "yScale has been added"); + + assert.strictEqual(panZoomInteraction.removeXScale(xScale), panZoomInteraction, "removing the xScale returns the interaction"); + assert.strictEqual(panZoomInteraction.removeYScale(yScale), panZoomInteraction, "removing the yScale returns the interaction"); + + assert.deepEqual(panZoomInteraction.xScales(), [], "xScale has been removed"); + assert.deepEqual(panZoomInteraction.yScales(), [], "yScale has been removed"); + + }); + + it("can set the xScales in batch", () => { + let xScale2 = new Plottable.Scales.Linear(); + let expectedXScales = [xScale, xScale2]; + panZoomInteraction.addXScale(xScale); + panZoomInteraction.addXScale(xScale2); + assert.deepEqual(panZoomInteraction.xScales(), expectedXScales, "interaction contains the 2 xScales added"); + + assert.deepEqual(panZoomInteraction.xScales([]), panZoomInteraction, "returns the calling interaction"); + assert.deepEqual(panZoomInteraction.xScales(), [], "scales can be removed with the xScales call"); + + panZoomInteraction.xScales([xScale, xScale2]); + assert.deepEqual(panZoomInteraction.xScales(), expectedXScales, "setting and adding x scales result in the same behavior"); + }); + + it("can set the yScales in batch", () => { + let yScale2 = new Plottable.Scales.Linear(); + let expectedYScales = [yScale, yScale2]; + panZoomInteraction.addYScale(yScale); + panZoomInteraction.addYScale(yScale2); + assert.deepEqual(panZoomInteraction.yScales(), expectedYScales, "interaction contains the 2 yScales added"); + + assert.deepEqual(panZoomInteraction.yScales([]), panZoomInteraction, "returns the calling interaction"); + assert.deepEqual(panZoomInteraction.yScales(), [], "scales can be removed with the yScales call"); + + panZoomInteraction.yScales([yScale, yScale2]); + assert.deepEqual(panZoomInteraction.yScales(), expectedYScales, "setting and adding y scales result in the same behavior"); + }); + + it("does not create duplicate for an already existent xScale", () => { + panZoomInteraction.addXScale(xScale); + panZoomInteraction.addXScale(xScale); + assert.deepEqual(panZoomInteraction.xScales(), [xScale], "there is exactly one copy of xScale"); + }); + + it("does not create duplicate for an already existent yScale", () => { + panZoomInteraction.addYScale(yScale); + panZoomInteraction.addYScale(yScale); + assert.deepEqual(panZoomInteraction.yScales(), [yScale], "there is exactly one copy of yScale"); + }); }); describe("Panning", () => { + let svg: d3.Selection; + let SVG_WIDTH = 400; + let SVG_HEIGHT = 500; + + let eventTarget: d3.Selection; - it("dragging a certain amount will translate the scale correctly (mouse)", () => { + let xScale: Plottable.QuantitativeScale; + let yScale: Plottable.QuantitativeScale; + let panZoomInteraction: Plottable.Interactions.PanZoom; + + beforeEach(() => { + xScale = new Plottable.Scales.Linear(); + xScale.domain([0, SVG_WIDTH / 2]).range([0, SVG_WIDTH]); + yScale = new Plottable.Scales.Linear(); + yScale.domain([0, SVG_HEIGHT / 2]).range([0, SVG_HEIGHT]); + + svg = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT); + + let component = new Plottable.Component(); + component.renderTo(svg); + + panZoomInteraction = new Plottable.Interactions.PanZoom(); + panZoomInteraction.addXScale(xScale); + panZoomInteraction.addYScale(yScale); + panZoomInteraction.attachTo(component); + + eventTarget = component.background(); + }); + + it("translates the scale correctly on dragging (mouse)", () => { let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; let endPoint = { x: SVG_WIDTH / 2, y: SVG_HEIGHT * 3 / 4 }; + let expectedXDomain = domainAfterPan(startPoint, endPoint, xScale, true); + let expectedYDomain = domainAfterPan(startPoint, endPoint, yScale, false); TestMethods.triggerFakeMouseEvent("mousedown", eventTarget, startPoint.x, startPoint.y); TestMethods.triggerFakeMouseEvent("mousemove", eventTarget, endPoint.x, endPoint.y); TestMethods.triggerFakeMouseEvent("mouseend", eventTarget, endPoint.x, endPoint.y); - assert.deepEqual(xScale.domain(), [-SVG_WIDTH / 8, SVG_WIDTH * 3 / 8], "xScale pans to the correct domain via drag (mouse)"); - assert.deepEqual(yScale.domain(), [-SVG_HEIGHT / 4, SVG_HEIGHT / 4], "yScale pans to the correct domain via drag (mouse)"); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale pans to the correct domain via drag (mouse)"); + assert.deepEqual(yScale.domain(), expectedYDomain, "yScale pans to the correct domain via drag (mouse)"); svg.remove(); }); - it("dragging to outside the component will translate the scale correctly (mouse)", () => { + it("translates the scale correctly on dragging to outside of the component (mouse)", () => { let startPoint = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; let endPoint = { x: -SVG_WIDTH / 2, y: -SVG_HEIGHT / 2 }; + let expectedXDomain = domainAfterPan(startPoint, endPoint, xScale, true); + let expectedYDomain = domainAfterPan(startPoint, endPoint, yScale, false); TestMethods.triggerFakeMouseEvent("mousedown", eventTarget, startPoint.x, startPoint.y); TestMethods.triggerFakeMouseEvent("mousemove", eventTarget, endPoint.x, endPoint.y); TestMethods.triggerFakeMouseEvent("mouseend", eventTarget, endPoint.x, endPoint.y); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 2, SVG_WIDTH], "xScale pans to the correct domain via drag (mouse)"); - assert.deepEqual(yScale.domain(), [SVG_HEIGHT / 2, SVG_HEIGHT], "yScale pans to the correct domain via drag (mouse)"); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale pans to the correct domain via drag (mouse)"); + assert.deepEqual(yScale.domain(), expectedYDomain, "yScale pans to the correct domain via drag (mouse)"); svg.remove(); }); - it("dragging a certain amount will translate multiple scales correctly (mouse)", () => { + it("translates multiple scales correctly on dragging (mouse)", () => { let xScale2 = new Plottable.Scales.Linear(); xScale2.domain([0, 2 * SVG_WIDTH]).range([0, SVG_WIDTH]); panZoomInteraction.addXScale(xScale2); let startPoint = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; let endPoint = { x: -SVG_WIDTH / 2, y: -SVG_HEIGHT / 2 }; + let expectedXDomain = domainAfterPan(startPoint, endPoint, xScale, true); + let expectedXDomain2 = domainAfterPan(startPoint, endPoint, xScale2, true); TestMethods.triggerFakeMouseEvent("mousedown", eventTarget, startPoint.x, startPoint.y); TestMethods.triggerFakeMouseEvent("mousemove", eventTarget, endPoint.x, endPoint.y); TestMethods.triggerFakeMouseEvent("mouseend", eventTarget, endPoint.x, endPoint.y); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 2, SVG_WIDTH], "xScale pans to the correct domain via drag (mouse)"); - assert.deepEqual(xScale2.domain(), [SVG_WIDTH * 2, SVG_WIDTH * 4], "xScale2 pans to the correct domain via drag (mouse)"); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale pans to the correct domain via drag (mouse)"); + assert.deepEqual(xScale2.domain(), expectedXDomain2, "xScale2 pans to the correct domain via drag (mouse)"); svg.remove(); }); - it("dragging a certain amount will translate the scale correctly (touch)", () => { - // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents - // https://github.com/ariya/phantomjs/issues/11289 - if ( window.PHANTOMJS ) { - svg.remove(); - return; - } - + it("translates the scale correctly on dragging (touch)", () => { let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; let endPoint = { x: SVG_WIDTH / 2, y: SVG_HEIGHT * 3 / 4 }; + let expectedXDomain = domainAfterPan(startPoint, endPoint, xScale, true); + let expectedYDomain = domainAfterPan(startPoint, endPoint, yScale, false); TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint]); TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint]); TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint]); - assert.deepEqual(xScale.domain(), [-SVG_WIDTH / 8, SVG_WIDTH * 3 / 8], "xScale pans to the correct domain via drag (touch)"); - assert.deepEqual(yScale.domain(), [-SVG_HEIGHT / 4, SVG_HEIGHT / 4], "yScale pans to the correct domain via drag (touch)"); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale pans to the correct domain via drag (touch)"); + assert.deepEqual(yScale.domain(), expectedYDomain, "yScale pans to the correct domain via drag (touch)"); svg.remove(); }); - it("dragging to outside the component will translate the scale correctly (touch)", () => { + it("translates the scale correctly on dragging to outside of the component (touch)", () => { let startPoint = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; let endPoint = { x: -SVG_WIDTH / 2, y: -SVG_HEIGHT / 2 }; + let expectedXDomain = domainAfterPan(startPoint, endPoint, xScale, true); + let expectedYDomain = domainAfterPan(startPoint, endPoint, yScale, false); TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint]); TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint]); TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint]); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 2, SVG_WIDTH], "xScale pans to the correct domain via drag (touch)"); - assert.deepEqual(yScale.domain(), [SVG_HEIGHT / 2, SVG_HEIGHT], "yScale pans to the correct domain via drag (touch)"); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale pans to the correct domain via drag (touch)"); + assert.deepEqual(yScale.domain(), expectedYDomain, "yScale pans to the correct domain via drag (touch)"); svg.remove(); }); - it("dragging a certain amount will translate multiple scales correctly (touch)", () => { + it("translates multiple scales correctly on dragging (touch)", () => { let xScale2 = new Plottable.Scales.Linear(); xScale2.domain([0, 2 * SVG_WIDTH]).range([0, SVG_WIDTH]); panZoomInteraction.addXScale(xScale2); let startPoint = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; let endPoint = { x: -SVG_WIDTH / 2, y: -SVG_HEIGHT / 2 }; + let expectedXDomain = domainAfterPan(startPoint, endPoint, xScale, true); + let expectedXDomain2 = domainAfterPan(startPoint, endPoint, xScale2, false); TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint]); TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint]); TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint]); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 2, SVG_WIDTH], "xScale pans to the correct domain via drag (touch)"); - assert.deepEqual(xScale2.domain(), [SVG_WIDTH * 2, SVG_WIDTH * 4], "xScale2 pans to the correct domain via drag (touch)"); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale pans to the correct domain via drag (touch)"); + assert.deepEqual(xScale2.domain(), expectedXDomain2, "xScale2 pans to the correct domain via drag (touch)"); svg.remove(); }); + function domainAfterPan(startPoint: Plottable.Point, endPoint: Plottable.Point, + scale: Plottable.QuantitativeScale, isHorizontal: boolean) { + let delta = isHorizontal ? endPoint.x - startPoint.x : endPoint.y - startPoint.y; + let domain = scale.domain(); + let range = isHorizontal ? SVG_WIDTH : SVG_HEIGHT; + let diff = delta / range * (domain[1] - domain[0]); + return domain.map((v) => v - diff); + } }); - it("mousewheeling a certain amount will magnify the scale correctly", () => { - // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents - // https://github.com/ariya/phantomjs/issues/11289 - if ( window.PHANTOMJS ) { + describe("Zooming", () => { + let svg: d3.Selection; + let SVG_WIDTH = 400; + let SVG_HEIGHT = 500; + + let component: Plottable.Component; + let eventTarget: d3.Selection; + + let xScale: Plottable.QuantitativeScale; + let yScale: Plottable.QuantitativeScale; + let panZoomInteraction: Plottable.Interactions.PanZoom; + + beforeEach(() => { + xScale = new Plottable.Scales.Linear(); + xScale.domain([0, SVG_WIDTH / 2]).range([0, SVG_WIDTH]); + yScale = new Plottable.Scales.Linear(); + yScale.domain([0, SVG_HEIGHT / 2]).range([0, SVG_HEIGHT]); + + svg = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT); + + component = new Plottable.Component(); + component.renderTo(svg); + + panZoomInteraction = new Plottable.Interactions.PanZoom(); + panZoomInteraction.addXScale(xScale); + panZoomInteraction.addYScale(yScale); + panZoomInteraction.attachTo(component); + + eventTarget = component.background(); + }); + + it("magnifies the scale correctly (mousewheel)", () => { + // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents + // https://github.com/ariya/phantomjs/issues/11289 + if (window.PHANTOMJS) { + svg.remove(); + return; + } + + let scrollPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; + let deltaY = 500; + let expectedXDomain = domainAfterWheel(deltaY, scrollPoint, xScale, true); + let expectedYDomain = domainAfterWheel(deltaY, scrollPoint, yScale, true); + + TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY); + + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale zooms to the correct domain via scroll"); + assert.deepEqual(yScale.domain(), expectedYDomain, "yScale zooms to the correct domain via scroll"); svg.remove(); - return; - } + }); - let scrollPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; - let deltaY = 500; + it("magnifies multiple scales correctly (mousewheel)", () => { + // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents + // https://github.com/ariya/phantomjs/issues/11289 + if (window.PHANTOMJS) { + svg.remove(); + return; + } + let xScale2 = new Plottable.Scales.Linear(); + xScale2.domain([0, 2 * SVG_WIDTH]).range([0, SVG_WIDTH]); + panZoomInteraction.addXScale(xScale2); - TestMethods.triggerFakeWheelEvent( "wheel", svg, scrollPoint.x, scrollPoint.y, deltaY ); + let scrollPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; + let deltaY = 500; + let expectedXDomain = domainAfterWheel(deltaY, scrollPoint, xScale, true); + let expectedXDomain2 = domainAfterWheel(deltaY, scrollPoint, xScale2, true); - assert.deepEqual(xScale.domain(), [-SVG_WIDTH / 8, SVG_WIDTH * 7 / 8], "xScale zooms to the correct domain via scroll"); - assert.deepEqual(yScale.domain(), [-SVG_HEIGHT / 8, SVG_HEIGHT * 7 / 8], "yScale zooms to the correct domain via scroll"); - svg.remove(); - }); + TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY ); - it("mousewheeling a certain amount will magnify multiple scales correctly", () => { - // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents - // https://github.com/ariya/phantomjs/issues/11289 - if ( window.PHANTOMJS ) { + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale zooms to the correct domain via scroll"); + assert.deepEqual(xScale2.domain(), expectedXDomain2, "xScale2 zooms to the correct domain via scroll"); svg.remove(); - return; - } - let xScale2 = new Plottable.Scales.Linear(); - xScale2.domain([0, 2 * SVG_WIDTH]).range([0, SVG_WIDTH]); - panZoomInteraction.addXScale(xScale2); + }); + + it("magnifies the scale correctly (pinching)", () => { + let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; + let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; + let endPoint = { x: SVG_WIDTH * 3 / 4, y: SVG_HEIGHT * 3 / 4 }; + let expectedXDomain = domainAfterPinch(startPoint, startPoint2, startPoint, endPoint, xScale, true); + let expectedYDomain = domainAfterPinch(startPoint, startPoint2, startPoint, endPoint, yScale, true); - let scrollPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; - let deltaY = 500; + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale transforms to the correct domain via pinch"); + assert.deepEqual(yScale.domain(), expectedYDomain, "yScale transforms to the correct domain via pinch"); + svg.remove(); + }); - TestMethods.triggerFakeWheelEvent( "wheel", svg, scrollPoint.x, scrollPoint.y, deltaY ); + it("magnifies multiple scales correctly (pinching)", () => { + let xScale2 = new Plottable.Scales.Linear(); + xScale2.domain([0, 2 * SVG_WIDTH]).range([0, SVG_WIDTH]); + panZoomInteraction.addXScale(xScale2); + let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; + let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; + let endPoint = { x: SVG_WIDTH * 3 / 4, y: SVG_HEIGHT * 3 / 4 }; + let expectedXDomain = domainAfterPinch(startPoint, startPoint2, startPoint, endPoint, xScale, true); + let expectedXDomain2 = domainAfterPinch(startPoint, startPoint2, startPoint, endPoint, xScale2, true); - assert.deepEqual(xScale.domain(), [-SVG_WIDTH / 8, SVG_WIDTH * 7 / 8], "xScale zooms to the correct domain via scroll"); - assert.deepEqual(xScale2.domain(), [-SVG_WIDTH / 2, SVG_WIDTH * 7 / 2], "xScale2 zooms to the correct domain via scroll"); - svg.remove(); - }); + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale transforms to the correct domain via pinch"); + assert.deepEqual(xScale2.domain(), expectedXDomain2, "xScale2 transforms to the correct domain via pinch"); + svg.remove(); + }); - it("pinching a certain amount will magnify the scale correctly", () => { - let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; - let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; - TestMethods.triggerFakeTouchEvent( "touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); - - let endPoint = { x: SVG_WIDTH * 3 / 4, y: SVG_HEIGHT * 3 / 4 }; - TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); - TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 16, SVG_WIDTH * 5 / 16], "xScale transforms to the correct domain via pinch"); - assert.deepEqual(yScale.domain(), [SVG_HEIGHT / 16, SVG_HEIGHT * 5 / 16], "yScale transforms to the correct domain via pinch"); - svg.remove(); - }); + it("can pinch inside one component and not affect another component", () => { + let xScale2 = new Plottable.Scales.Linear(); + let initialDomain = [0, SVG_WIDTH / 2]; + xScale2.domain(initialDomain).range([0, SVG_WIDTH]); - it("pinching a certain amount will magnify multiple scales correctly", () => { - let xScale2 = new Plottable.Scales.Linear(); - xScale2.domain([0, 2 * SVG_WIDTH]).range([0, SVG_WIDTH]); - panZoomInteraction.addXScale(xScale2); - let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; - let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; - TestMethods.triggerFakeTouchEvent( "touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); - - let endPoint = { x: SVG_WIDTH * 3 / 4, y: SVG_HEIGHT * 3 / 4 }; - TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); - TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 16, SVG_WIDTH * 5 / 16], "xScale transforms to the correct domain via pinch"); - assert.deepEqual(xScale2.domain(), [SVG_WIDTH / 4, SVG_WIDTH * 5 / 4], "xScale2 transforms to the correct domain via pinch"); - svg.remove(); - }); + let component2 = new Plottable.Component(); - it("pinching inside one component does not affect another component", () => { - let component2 = new Plottable.Component(); - let table = new Plottable.Components.Table([[component], [component2]]); - table.renderTo(svg); - let xScale2 = new Plottable.Scales.Linear(); - const initialDomain = [0, SVG_WIDTH / 2]; - xScale2.domain(initialDomain).range([0, SVG_WIDTH]); - let panZoomInteraction2 = new Plottable.Interactions.PanZoom(); - panZoomInteraction2.addXScale(xScale2); - panZoomInteraction2.attachTo(component2); - - let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 2 }; - let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; - TestMethods.triggerFakeTouchEvent( "touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); - - let endPoint = { x: SVG_WIDTH * 3 / 4, y: SVG_HEIGHT / 2 }; - TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); - TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); - assert.deepEqual(xScale.domain(), [SVG_WIDTH / 16, SVG_WIDTH * 5 / 16], "xScale inside target component transforms via pinch"); - assert.deepEqual(xScale2.domain(), initialDomain, "xScale outside of target component does not transform via pinch"); - svg.remove(); - }); + let panZoomInteraction2 = new Plottable.Interactions.PanZoom(); + panZoomInteraction2.addXScale(xScale2); + panZoomInteraction2.attachTo(component2); - it("Setting the xScales in batch is the same as adding one at a time", () => { - let xScale2 = new Plottable.Scales.Linear(); - panZoomInteraction.addXScale(xScale2); - let xScales = panZoomInteraction.xScales(); - panZoomInteraction.xScales([xScale, xScale2]); - assert.deepEqual(xScales, panZoomInteraction.xScales(), "Setting and adding x scales result in the same behavior"); - svg.remove(); - }); + let table = new Plottable.Components.Table([[component, component2]]); + table.renderTo(svg); - it("Setting the yScales in batch is the same as adding one at a time", () => { - let yScale2 = new Plottable.Scales.Linear(); - panZoomInteraction.addYScale(yScale2); - let yScales = panZoomInteraction.yScales(); - panZoomInteraction.yScales([yScale, yScale2]); - assert.deepEqual(yScales, panZoomInteraction.yScales(), "Setting and adding y scales result in the same behavior"); - svg.remove(); - }); + let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 2 }; + let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; + let endPoint = { x: SVG_WIDTH * 3 / 4, y: SVG_HEIGHT / 2 }; + let expectedXDomain = domainAfterPinch(startPoint, startPoint2, startPoint, endPoint, xScale, true); - it("Adding an already existent xScale does nothing", () => { - let oldXScaleNumber = panZoomInteraction.xScales().length; - panZoomInteraction.addXScale(panZoomInteraction.xScales()[0]); - assert.lengthOf(panZoomInteraction.xScales(), oldXScaleNumber, "Number of x scales is maintained"); - svg.remove(); - }); + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); + assert.deepEqual(xScale.domain(), expectedXDomain, "xScale inside target component transforms via pinch"); + assert.deepEqual(xScale2.domain(), initialDomain, "xScale outside of target component does not transform via pinch"); + svg.remove(); + }); + + function domainAfterPinch(startPoint: Plottable.Point, startPoint2: Plottable.Point, + endPoint: Plottable.Point, endPoint2: Plottable.Point, + scale: Plottable.QuantitativeScale, isHorizontal: boolean) { + let oldDistance = isHorizontal ? startPoint2.x - startPoint.x : startPoint2.y - startPoint.y; + let newDistance = isHorizontal ? endPoint2.x - endPoint.x : endPoint2.y - endPoint.y; + let delta = isHorizontal ? endPoint2.x - startPoint2.x : endPoint2.y - startPoint2.y; + let zoomAmount = oldDistance / newDistance; + + let domain = scale.domain(); + let range = isHorizontal ? SVG_WIDTH : SVG_HEIGHT; + let diff = delta / range * (domain[1] - domain[0]); + return domain.map((v, i) => (v - domain[0] + diff) * zoomAmount + domain[0]); + } - it("Adding an already existent yScale does nothing", () => { - let oldYScaleNumber = panZoomInteraction.yScales().length; - panZoomInteraction.addYScale(panZoomInteraction.yScales()[0]); - assert.lengthOf(panZoomInteraction.yScales(), oldYScaleNumber, "Number of y scales is maintained"); - svg.remove(); + function domainAfterWheel(deltaY: number, scrollPoint: Plottable.Point, + scale: Plottable.QuantitativeScale, isHorizontal: boolean) { + let zoomAmount = Math.pow(2, deltaY * .002); + let domain = scale.domain(); + let diff = (isHorizontal ? scrollPoint.x / SVG_WIDTH : scrollPoint.y / SVG_HEIGHT) * (domain[1] - domain[0]); + return domain.map(function (v, i) { return (v - domain[0] - diff) * zoomAmount + domain[0] + diff; }); + } }); - describe("minDomainExtent", () => { + describe("Setting minDomainExtent", () => { + let svg: d3.Selection; + let SVG_WIDTH = 400; + let SVG_HEIGHT = 500; + + let eventTarget: d3.Selection; - let minimumDomainExtent: number; + let xScale: Plottable.QuantitativeScale; + let panZoomInteraction: Plottable.Interactions.PanZoom; beforeEach(() => { - minimumDomainExtent = SVG_WIDTH / 4; - panZoomInteraction.minDomainExtent(xScale, minimumDomainExtent); + xScale = new Plottable.Scales.Linear(); + xScale.domain([0, SVG_WIDTH / 2]); + + svg = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT); + + let component = new Plottable.Component(); + component.renderTo(svg); + + panZoomInteraction = new Plottable.Interactions.PanZoom(); + panZoomInteraction.addXScale(xScale); + panZoomInteraction.attachTo(component); + + eventTarget = component.background(); + }); + + it("can set minDomainExtent", () => { + let minimumDomainExtent = SVG_WIDTH / 4; + assert.strictEqual(panZoomInteraction.minDomainExtent(xScale, minimumDomainExtent), panZoomInteraction, + "setting the minDomainExtent returns the interaction"); + + assert.strictEqual(panZoomInteraction.minDomainExtent(xScale), minimumDomainExtent, + "returns the correct minDomainExtent"); + + svg.remove(); }); - it("Rejects negative extents", () => { - assert.throws(() => panZoomInteraction.minDomainExtent(xScale, -1), Error); + it("rejects negative extents", () => { + // HACKHACK #2661: Cannot assert errors being thrown with description + ( assert).throws(() => panZoomInteraction.minDomainExtent(xScale, -1), Error, "extent must be non-negative", + "Correctly rejects -1"); svg.remove(); }); - it("can't be larger than maxDomainExtent() for the same Scale", () => { - let maximumDomainExtent = minimumDomainExtent * 2; + it("can't set minDomainExtent() be larger than maxDomainExtent() for the same Scale", () => { + let maximumDomainExtent = SVG_WIDTH / 2; panZoomInteraction.maxDomainExtent(xScale, maximumDomainExtent); + let tooBigMinimumDomainExtent = maximumDomainExtent * 2; - assert.throws(() => panZoomInteraction.minDomainExtent(xScale, tooBigMinimumDomainExtent), Error); + // HACKHACK #2661: Cannot assert errors being thrown with description + ( assert).throws(() => panZoomInteraction.minDomainExtent(xScale, tooBigMinimumDomainExtent), Error, + "minDomainExtent must be smaller than maxDomainExtent for the same Scale", + "cannot have minDomainExtent larger than maxDomainExtent"); svg.remove(); }); - it("Mousewheeling in cannot go beyond the specified domainExtent", () => { + it("cannot go beyond the specified domainExtent (mousewheel)", () => { // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents // https://github.com/ariya/phantomjs/issues/11289 - if ( window.PHANTOMJS ) { + if (window.PHANTOMJS) { svg.remove(); return; } + let minimumDomainExtent = SVG_WIDTH / 4; let scrollPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; let deltaY = -3000; - - TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY ); + TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY); let domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); + assert.operator(domainExtent, "<", minimumDomainExtent, "there is no zoom limit before setting minimun extent via scroll"); + + panZoomInteraction.minDomainExtent(xScale, minimumDomainExtent); + xScale.domain([0, SVG_WIDTH / 2]); + TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY); + domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); assert.strictEqual(domainExtent, minimumDomainExtent, "xScale zooms to the correct domain via scroll"); svg.remove(); }); - it("Pinching in cannot go beyond the specified domainExtent", () => { + it("cannot go beyond the specified domainExtent (pinching)", () => { + let minimumDomainExtent = SVG_WIDTH / 4; + let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; - TestMethods.triggerFakeTouchEvent( "touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); + let zoomAmount = 6; + let endX = (startPoint2.x - startPoint.x) * zoomAmount + startPoint.x; + let endY = (startPoint2.y - startPoint.y) * zoomAmount + startPoint.y; + let endPoint = { x: endX, y: endY }; + + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1]); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1]); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1]); - let endPoint = { x: SVG_WIDTH, y: SVG_HEIGHT}; - TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); - TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); let domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); + assert.operator(domainExtent, "<", minimumDomainExtent, "there is no zoom limit before setting minimun extent via pinch"); + + panZoomInteraction.minDomainExtent(xScale, minimumDomainExtent); + xScale.domain([0, SVG_WIDTH / 2]); + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1]); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1]); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1]); + domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); assert.strictEqual(domainExtent, minimumDomainExtent, "xScale zooms to the correct domain via pinch"); svg.remove(); }); - }); - describe("maxDomainExtent", () => { - let maximumDomainExtent: number; + describe("Setting maxDomainExtent", () => { + let svg: d3.Selection; + let SVG_WIDTH = 400; + let SVG_HEIGHT = 500; + + let eventTarget: d3.Selection; + + let xScale: Plottable.QuantitativeScale; + let panZoomInteraction: Plottable.Interactions.PanZoom; beforeEach(() => { - maximumDomainExtent = SVG_WIDTH; - panZoomInteraction.maxDomainExtent(xScale, maximumDomainExtent); + xScale = new Plottable.Scales.Linear(); + xScale.domain([0, SVG_WIDTH / 2]); + + svg = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT); + + let component = new Plottable.Component(); + component.renderTo(svg); + + panZoomInteraction = new Plottable.Interactions.PanZoom(); + panZoomInteraction.addXScale(xScale); + panZoomInteraction.attachTo(component); + + eventTarget = component.background(); + }); + + it("can set maxDomainExtent", () => { + let maximumDomainExtent = SVG_WIDTH; + assert.strictEqual(panZoomInteraction.maxDomainExtent(xScale, maximumDomainExtent), panZoomInteraction, + "setting the maxDomainExtent returns the interaction"); + + assert.strictEqual(panZoomInteraction.maxDomainExtent(xScale), maximumDomainExtent, + "returns the correct maxDomainExtent"); + + svg.remove(); }); - it("Rejects non-positive extents", () => { - assert.throws(() => panZoomInteraction.maxDomainExtent(xScale, -1), Error); - assert.throws(() => panZoomInteraction.maxDomainExtent(xScale, 0), Error); + it("rejects non-positive extents", () => { + // HACKHACK #2661: Cannot assert errors being thrown with description + ( assert).throws(() => panZoomInteraction.maxDomainExtent(xScale, -1), Error, "extent must be positive", + "Correctly rejects -1"); + // HACKHACK #2661: Cannot assert errors being thrown with description + ( assert).throws(() => panZoomInteraction.maxDomainExtent(xScale, 0), Error, "extent must be positive", + "Correctly rejects 0"); svg.remove(); }); - it("can't be smaller than minDomainExtent() for the same Scale", () => { - let minimumDomainExtent = maximumDomainExtent / 2; + it("can't set maxDomainExtent() to be smaller than minDomainExtent() for the same Scale", () => { + let minimumDomainExtent = SVG_WIDTH / 2; panZoomInteraction.minDomainExtent(xScale, minimumDomainExtent); let tooSmallMaximumDomainExtent = minimumDomainExtent / 2; - assert.throws(() => panZoomInteraction.maxDomainExtent(xScale, tooSmallMaximumDomainExtent), Error); + // HACKHACK #2661: Cannot assert errors being thrown with description + ( assert).throws(() => panZoomInteraction.maxDomainExtent(xScale, tooSmallMaximumDomainExtent), Error, + "maxDomainExtent must be larger than minDomainExtent for the same Scale", + "cannot have maxDomainExtent smaller than minDomainExtent"); + svg.remove(); }); - it("Mousewheeling out cannot go beyond the specified domainExtent", () => { + it("cannot go beyond the specified domainExtent (mousewheel)", () => { // HACKHACK PhantomJS doesn't implement fake creation of WheelEvents // https://github.com/ariya/phantomjs/issues/11289 - if ( window.PHANTOMJS ) { + if (window.PHANTOMJS) { svg.remove(); return; } + let maximumDomainExtent = SVG_WIDTH; let scrollPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; let deltaY = 3000; - - TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY ); + TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY); let domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); + assert.operator(domainExtent, ">", maximumDomainExtent, "there is no zoom limit before setting maximun extent via scroll"); + + xScale.domain([0, SVG_WIDTH / 2]); + panZoomInteraction.maxDomainExtent(xScale, maximumDomainExtent); + + TestMethods.triggerFakeWheelEvent("wheel", svg, scrollPoint.x, scrollPoint.y, deltaY); + domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); assert.strictEqual(domainExtent, maximumDomainExtent, "xScale zooms to the correct domain via scroll"); svg.remove(); }); - it("Pinching in cannot go beyond the specified domainExtent", () => { + it("cannot go beyond the specified domainExtent (pinching)", () => { + let maximumDomainExtent = SVG_WIDTH; + let startPoint = { x: SVG_WIDTH / 4, y: SVG_HEIGHT / 4 }; let startPoint2 = { x: SVG_WIDTH / 2, y: SVG_HEIGHT / 2 }; - TestMethods.triggerFakeTouchEvent( "touchstart", eventTarget, [startPoint, startPoint2], [0, 1] ); - - let endPoint = { x: 5 * SVG_WIDTH / 16, y: 5 * SVG_HEIGHT / 16 }; - TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1] ); - TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1] ); + let zoomAmount = 1 / 6; + let endX = (startPoint2.x - startPoint.x) * zoomAmount + startPoint.x; + let endY = (startPoint2.y - startPoint.y) * zoomAmount + startPoint.y; + let endPoint = { x: endX, y: endY }; + + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1]); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1]); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1]); let domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); + assert.operator(domainExtent, ">", maximumDomainExtent, "there is no zoom limit before setting maximun extent via pinch"); + + xScale.domain([0, SVG_WIDTH / 2]); + panZoomInteraction.maxDomainExtent(xScale, maximumDomainExtent); + TestMethods.triggerFakeTouchEvent("touchstart", eventTarget, [startPoint, startPoint2], [0, 1]); + TestMethods.triggerFakeTouchEvent("touchmove", eventTarget, [endPoint], [1]); + TestMethods.triggerFakeTouchEvent("touchend", eventTarget, [endPoint], [1]); + + domainExtent = Math.abs(xScale.domain()[1] - xScale.domain()[0]); assert.strictEqual(domainExtent, maximumDomainExtent, "xScale zooms to the correct domain via pinch"); svg.remove(); }); - }); }); diff --git a/test/plots/barPlotTests.ts b/test/plots/barPlotTests.ts index a555c0adf6..2d10066a5f 100644 --- a/test/plots/barPlotTests.ts +++ b/test/plots/barPlotTests.ts @@ -1213,5 +1213,47 @@ describe("Plots", () => { assert.deepEqual(yScale.domain(), [-2.5, 2.5], "domain has been adjusted to visible points"); svg.remove(); }); + + it("updates the scale extent correctly when there is one bar (vertical)", () => { + let svg = TestMethods.generateSVG(); + + let xScale = new Plottable.Scales.Linear(); + let yScale = new Plottable.Scales.Linear(); + let xPoint = Math.max(xScale.domain()[0], xScale.domain()[1]) + 10; + let data = [{x: xPoint, y: 10}]; + let dataset = new Plottable.Dataset(data); + + let barPlot = new Plottable.Plots.Bar(); + barPlot.datasets([dataset]); + barPlot.x(function(d) { return d.x; }, xScale); + barPlot.y(function(d) { return d.y; }, yScale); + + barPlot.renderTo(svg); + let xScaleDomain = xScale.domain(); + assert.operator(xPoint, ">=", xScaleDomain[0], "x value greater than new domain min"); + assert.operator(xPoint, "<=", xScaleDomain[1], "x value less than new domain max"); + svg.remove(); + }); + + it("updates the scale extent correctly when there is one bar (horizontal)", () => { + let svg = TestMethods.generateSVG(); + + let xScale = new Plottable.Scales.Linear(); + let yScale = new Plottable.Scales.Linear(); + let yPoint = Math.max(yScale.domain()[0], yScale.domain()[1]) + 10; + let data = [{x: 10, y: yPoint}]; + let dataset = new Plottable.Dataset(data); + + let barPlot = new Plottable.Plots.Bar(Plottable.Plots.Bar.ORIENTATION_HORIZONTAL); + barPlot.datasets([dataset]); + barPlot.x(function(d) { return d.x; }, xScale); + barPlot.y(function(d) { return d.y; }, yScale); + + barPlot.renderTo(svg); + let yScaleDomain = yScale.domain(); + assert.operator(yPoint, ">=", yScaleDomain[0], "y value greater than new domain min"); + assert.operator(yPoint, "<=", yScaleDomain[1], "y value less than new domain max"); + svg.remove(); + }); }); }); diff --git a/test/plots/linePlotTests.ts b/test/plots/linePlotTests.ts index 5401ecb617..4d9e96879b 100644 --- a/test/plots/linePlotTests.ts +++ b/test/plots/linePlotTests.ts @@ -680,7 +680,6 @@ describe("Plots", () => { line.autorangeSmooth(true); assert.deepEqual(xScale.domain(), [-2, -1], "no changes for autoranging smooth with same edge points (smooth)"); }); - }); describe("Cropped Rendering Performance", () => { @@ -830,5 +829,138 @@ describe("Plots", () => { }); } }); + + describe("Downsampling Performance", () => { + let svg: d3.Selection; + let plot: Plottable.Plots.Line; + + let xScale: Plottable.Scales.Linear; + let yScale: Plottable.Scales.Linear; + + beforeEach(() => { + svg = TestMethods.generateSVG(50, 50); + xScale = new Plottable.Scales.Linear(); + yScale = new Plottable.Scales.Linear(); + plot = new Plottable.Plots.Line(); + plot.x((d) => d.x, xScale).y((d) => d.y, yScale); + }); + + it("can set the downsampling option", () => { + plot.renderTo(svg); + + assert.isFalse(plot.downsamplingEnabled(), "downsampling is not enabled by default"); + + assert.strictEqual(plot.downsamplingEnabled(true), plot, "enabling the downsampling option returns the plot"); + assert.isTrue(plot.downsamplingEnabled(), "can enable the downsampling option"); + + plot.downsamplingEnabled(false); + assert.isFalse(plot.downsamplingEnabled(), "can disable the downsampling option"); + + svg.remove(); + }); + + it("does not render points that should be removed in downsampling in horizontal line plots" , () => { + let data = [ + {x: -100, y: -1}, // last element in previous bucket + {x: 0, y: 2}, // first element in current bucket + {x: 0.5, y: 1.5}, // the point to be removed + {x: 1, y: 1}, // minimum y in current bucket + {x: 2, y: 4}, // maximum y in current bucket + {x: 3, y: 3}, // last elemnt in current bucket + {x: 100, y: 2}, // first element in next bucket + ]; + plot.addDataset(new Plottable.Dataset(data)); + xScale.domain([-100, 100]); + + plot.downsamplingEnabled(true); + plot.renderTo(svg); + + let lineScaledXValue = Math.floor(xScale.scale(data[1].x)); + assert.notStrictEqual(Math.floor(xScale.scale(data[0].x)), lineScaledXValue, + `point(${data[0].x},${data[0].y}) should not have the same scaled x value as the horizontal line`); + data.slice(1, 6).forEach((d, i) => { + assert.strictEqual(Math.floor(xScale.scale(d.x)), lineScaledXValue, + `point(${d.x},${d.y} should have the same scaled x value as the horizontal line`); + }); + assert.notStrictEqual(Math.floor(xScale.scale(data[6].x)), lineScaledXValue, + `point(${data[6].x},${data[6].y}) should not have the same scaled x value as the horizontal line`); + + let path = plot.content().select("path.line").attr("d"); + let expectedRenderedData = [0, 1, 4, 3, 5, 6].map((d) => data[d]); + TestMethods.assertLinePathEqualToDataPoints(path, expectedRenderedData, xScale, yScale); + + svg.remove(); + }); + + it("does not render points that should be removed in downsampling in vertical line plots", () => { + let data = [ + {x: -1, y: -50}, // last element in previous bucket + {x: 2, y: 1}, // first element in current bucket + {x: 1.5, y: 1.5}, // the point to be removed + {x: 1, y: 2}, // minimum x in current bucket + {x: 4, y: 3}, // maximum x in current bucket + {x: 3, y: 4}, // last elemnt in current bucket + {x: 2, y: 100}, // first element in next bucket + ]; + plot.addDataset(new Plottable.Dataset(data)); + + yScale.domain([-200, 200]); + + plot.downsamplingEnabled(true); + plot.renderTo(svg); + + let lineScaledYValue = Math.floor(yScale.scale(data[1].y)); + assert.notStrictEqual(Math.floor(yScale.scale(data[0].y)), lineScaledYValue, + `point(${data[0].x},${data[0].y}) should not have the same scaled y value as the vertical line`); + data.slice(1, 6).forEach((d, i) => { + assert.strictEqual(Math.floor(yScale.scale(d.y)), lineScaledYValue, + `point(${d.x},${d.y}) should have the same scaled y value as the vertical line`); + }); + assert.notStrictEqual(Math.floor(yScale.scale(data[6].y)), lineScaledYValue, + `point(${data[6].x},${data[6].y}) should not have the same scaled y value as the vertical line`); + + let path = plot.content().select("path.line").attr("d"); + let expectedRenderedData = [0, 1, 3, 4, 5, 6].map((d) => data[d]); + TestMethods.assertLinePathEqualToDataPoints(path, expectedRenderedData, xScale, yScale); + + svg.remove(); + }); + + it("does not render points that are on the same line except for the first, the last, the largest and the smallest points", () => { + let data = [ + {x: 3, y: 1}, // last element in previous bucket + {x: 2, y: 2}, // first element in the bucket + {x: 1, y: 1}, // minimum element in the bucket + {x: 10, y: 10}, // maximum element in the bucket + {x: 2.5, y: 2.5}, // the point to be removed + {x: 3, y: 3}, // last element in the bucket + {x: 3, y: 1}, // first element in next bucket + ]; + plot.addDataset(new Plottable.Dataset(data)); + + let expectedYValue = (p1: any, p2: any, slope: number) => { + return p1.y + (p2.x - p1.x) * slope; + }; + + let lineCurrentSlope = (data[2].y - data[1].y) / (data[2].x - data[1].x); + assert.notStrictEqual(Math.floor(expectedYValue(data[1], data[0], lineCurrentSlope)), Math.floor(data[0].y), + `point(${data[0].x},${data[0].y}) is not on the line with slope ${lineCurrentSlope}`); + data.slice(1, 6).forEach((d, i) => { + assert.strictEqual(Math.floor(expectedYValue(data[1], d, lineCurrentSlope)), Math.floor(d.y), + `point(${d.x},${d.y}) is on the line with slope ${lineCurrentSlope}`); + }); + assert.notStrictEqual(Math.floor(expectedYValue(data[1], data[6], lineCurrentSlope)), Math.floor(data[6].y), + `point(${data[6].x},${data[6].y}) is not on the line with slope ${lineCurrentSlope}`); + + plot.downsamplingEnabled(true); + plot.renderTo(svg); + + let path = plot.content().select("path.line").attr("d"); + let expectedRenderedData = [0, 1, 2, 3, 5, 6].map((d) => data[d]); + TestMethods.assertLinePathEqualToDataPoints(path, expectedRenderedData, xScale, yScale); + + svg.remove(); + }); + }); }); }); diff --git a/test/plots/stackedAreaPlotTests.ts b/test/plots/stackedAreaPlotTests.ts index a37673c379..35d1f00e9a 100644 --- a/test/plots/stackedAreaPlotTests.ts +++ b/test/plots/stackedAreaPlotTests.ts @@ -67,6 +67,13 @@ describe("Plots", () => { svg.remove(); }); + it("disables downsampling", () => { + assert.strictEqual(renderer.downsamplingEnabled(), false, "downsampling is disabled by default"); + renderer.downsamplingEnabled(true); + assert.strictEqual(renderer.downsamplingEnabled(), false, "downsampling will not be enabled by user"); + svg.remove(); + }); + }); describe("Stacked Area Plot no data", () => { diff --git a/test/plots/waterfallPlotTests.ts b/test/plots/waterfallPlotTests.ts index 0a16a60ba7..e2f88bdf75 100644 --- a/test/plots/waterfallPlotTests.ts +++ b/test/plots/waterfallPlotTests.ts @@ -1,123 +1,240 @@ /// describe("Plots", () => { - describe("Waterfall Plot", () => { - let svg: d3.Selection; - let dataset: Plottable.Dataset; - let xScale: Plottable.Scales.Category; - let yScale: Plottable.Scales.Linear; - let plot: Plottable.Plots.Waterfall; - let renderArea: d3.Selection; - let SVG_WIDTH = 600; - let SVG_HEIGHT = 400; - let data = [ - { x: "A", y: 20, t: "total" }, - { x: "B", y: -5, t: "delta" }, - { x: "C", y: 10, t: "delta" }, - { x: "D", y: 25, t: "total" }, - { x: "E", y: 5, t: "delta" }, - { x: "F", y: -15, t: "delta" }, - { x: "G", y: 15, t: "total" } - ]; - - beforeEach(() => { - svg = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT); - dataset = new Plottable.Dataset(data); - xScale = new Plottable.Scales.Category(); - yScale = new Plottable.Scales.Linear(); - plot = new Plottable.Plots.Waterfall(); - plot.x(function(d) { return d.x; }, xScale); - plot.y(function(d) { return d.y; }, yScale); - plot.total(function(d) { return d.t === "total" ? true : false; }); - plot.addDataset(dataset); - plot.renderTo(svg); - renderArea = ( plot)._renderArea; - }); + describe("Waterfall", () => { + describe("rendering growth bars", () => { + let numAttr = TestMethods.numAttr; + let svg: d3.Selection; + let dataset: Plottable.Dataset; + let xScale: Plottable.Scales.Category; + let yScale: Plottable.Scales.Linear; + let plot: Plottable.Plots.Waterfall; + let growthBarData = [ + { x: "A", y: 0 }, + { x: "B", y: 5 }, + { x: "C", y: 10 }, + { x: "D", y: 100} + ]; + let growthClass = "waterfall-growth"; - it("adjacent bars share correct edge", () => { - let bars = renderArea.selectAll("rect")[0]; - let data = dataset.data(); - let yAccessor = plot.y().accessor; - let totalAccessor = plot.total().accessor; - for (let currentIndex = 1; currentIndex < bars.length; currentIndex++) { - let currentBar = d3.select(bars[currentIndex]); - let currentTotal = totalAccessor(data[currentIndex], currentIndex, dataset); - let currentValue = yAccessor(data[currentIndex], currentIndex, dataset); - let previousIndex = currentIndex - 1; - let previousBar = d3.select(bars[previousIndex]); - let previousTotal = totalAccessor(data[previousIndex], previousIndex, dataset); - let previousValue = yAccessor(data[previousIndex], previousIndex, dataset); - if (previousTotal) { - if (currentTotal || currentValue < 0) { - assert.isTrue(+previousBar.attr("y") === +currentBar.attr("y"), "bars are top/top aligned"); - } else { - assert.closeTo(+previousBar.attr("y") - (+currentBar.attr("y") + +currentBar.attr("height")), 0, 1, - "bars are top/bottom aligned"); + beforeEach(() => { + svg = TestMethods.generateSVG(); + dataset = new Plottable.Dataset(growthBarData); + xScale = new Plottable.Scales.Category(); + yScale = new Plottable.Scales.Linear(); + plot = new Plottable.Plots.Waterfall(); + plot.x((d) => d.x, xScale); + plot.y((d) => d.y, yScale); + plot.total((d, i) => i === 0); + plot.addDataset(dataset); + plot.renderTo(svg); + }); + + it("classes growth bars", () => { + let bars = plot.content().selectAll("rect"); + assert.strictEqual(bars.size(), growthBarData.length, "same number of bars as data points"); + bars.each(function(d, i) { + if (i === 0) { + return; } - } else { - if (previousValue > 0) { - if (currentTotal || currentValue < 0) { - assert.isTrue(+previousBar.attr("y") === +currentBar.attr("y"), "bars are top/top aligned"); - } else { - assert.closeTo(+previousBar.attr("y") - (+currentBar.attr("y") + +currentBar.attr("height")), 0, 1, - "bars are top/bottom aligned"); - } - } else { - if (currentTotal || currentValue < 0) { - assert.closeTo(+previousBar.attr("y") + +previousBar.attr("height") - +currentBar.attr("y"), 0, 1, - "bars are bottom/top aligned"); - } else { - assert.closeTo((+previousBar.attr("y") + +previousBar.attr("height")) - - (+currentBar.attr("y") + +currentBar.attr("height")), 0, 1, "bars are bottom/bottom aligned"); - } + let bar = d3.select(this); + assert.isTrue(bar.classed(growthClass), "bar classed as growth bar"); + }); + plot.destroy(); + svg.remove(); + }); + + it("places bars at current sum", () => { + let bars = plot.content().selectAll(`rect.${growthClass}`); + assert.strictEqual(bars.size(), growthBarData.length - 1, "all bars are growth except for first"); + let yAccessor = plot.y().accessor; + let sum = 0; + bars.each(function(d, i) { + let dataY = yAccessor(d, i, dataset); + let bar = d3.select(this); + assert.closeTo(numAttr(bar, "y") + numAttr(bar, "height"), yScale.scale(sum), + window.Pixel_CloseTo_Requirement, "growth bar bottom at previous sum"); + sum += dataY; + assert.closeTo(numAttr(bar, "y"), yScale.scale(sum), + window.Pixel_CloseTo_Requirement, "growth bar top at final sum"); + }); + + plot.destroy(); + svg.remove(); + }); + }); + + describe("rendering decline bars", () => { + let numAttr = TestMethods.numAttr; + let svg: d3.Selection; + let dataset: Plottable.Dataset; + let xScale: Plottable.Scales.Category; + let yScale: Plottable.Scales.Linear; + let plot: Plottable.Plots.Waterfall; + let declineBarData = [ + { x: "A", y: 0 }, + { x: "B", y: -5 }, + { x: "C", y: -25 }, + { x: "D", y: -10 }, + { x: "E", y: -15 } + ]; + let declineClass = "waterfall-decline"; + + beforeEach(() => { + svg = TestMethods.generateSVG(); + dataset = new Plottable.Dataset(declineBarData); + xScale = new Plottable.Scales.Category(); + yScale = new Plottable.Scales.Linear(); + plot = new Plottable.Plots.Waterfall(); + plot.x((d) => d.x, xScale); + plot.y((d) => d.y, yScale); + plot.total((d, i) => i === 0); + plot.addDataset(dataset); + plot.renderTo(svg); + }); + + it("classes decline bars", () => { + let bars = plot.content().selectAll("rect"); + assert.strictEqual(bars.size(), declineBarData.length, "same number of bars as data points"); + bars.each(function(d, i) { + if (i === 0) { + return; } - } - } - svg.remove(); + let bar = d3.select(this); + assert.isTrue(bar.classed(declineClass), "bar classed as decline bars"); + }); + plot.destroy(); + svg.remove(); + }); + + it("places bars at current sum", () => { + let bars = plot.content().selectAll(`rect.${declineClass}`); + assert.strictEqual(bars.size(), declineBarData.length - 1, "all bars are decline except for first"); + let yAccessor = plot.y().accessor; + let sum = 0; + bars.each(function(d, i) { + let dataY = yAccessor(d, i, dataset); + let bar = d3.select(this); + assert.closeTo(numAttr(bar, "y"), yScale.scale(sum), + window.Pixel_CloseTo_Requirement, "growth bar top at previous sum"); + sum += dataY; + assert.closeTo(numAttr(bar, "y") + numAttr(bar, "height"), yScale.scale(sum), + window.Pixel_CloseTo_Requirement, "growth bar bottom at final sum"); + }); + + plot.destroy(); + svg.remove(); + }); + }); + + describe("denoting total bars", () => { + let svg: d3.Selection; + let dataset: Plottable.Dataset; + let xScale: Plottable.Scales.Category; + let yScale: Plottable.Scales.Linear; + let plot: Plottable.Plots.Waterfall; + let data = [ + { x: "A", y: 20, t: true }, + { x: "B", y: 5, t: false }, + { x: "C", y: 25, t: true }, + { x: "D", y: -10, t: false }, + { x: "E", y: 15, t: true } + ]; + let totalClass = "waterfall-total"; + + beforeEach(() => { + svg = TestMethods.generateSVG(); + dataset = new Plottable.Dataset(data); + xScale = new Plottable.Scales.Category(); + yScale = new Plottable.Scales.Linear(); + plot = new Plottable.Plots.Waterfall(); + plot.x((d) => d.x, xScale); + plot.y((d) => d.y, yScale); + }); + + it("can set the total property", () => { + let accessor = (d: any) => d.t; + assert.strictEqual(plot.total(accessor), plot, "setter returns calling object"); + + plot.addDataset(dataset); + plot.renderTo(svg); + let bars = plot.content().selectAll("rect").filter((d) => accessor(d)); + bars.each(function(d) { + let totalBar = d3.select(this); + assert.isTrue(totalBar.classed(totalClass)); + }); + plot.destroy(); + svg.remove(); + }); + + it("can get the total property", () => { + let accessor = (d: any) => d.t === "total"; + plot.total(accessor); + assert.strictEqual(plot.total().accessor, accessor, "can get if connectors are enabled"); + plot.destroy(); + svg.remove(); + }); }); - it("bars are classed correctly", () => { - let bars = renderArea.selectAll("rect")[0]; - let data = dataset.data(); - let totalAccessor = plot.total().accessor; - bars.forEach((bar, index) => { - let selection = d3.select(bar); - let isTotal = totalAccessor(data[index], index, dataset); - if (isTotal) { - assert.isTrue(selection.classed("waterfall-total")); - } else { - let yAccessor = plot.y().accessor; - if (yAccessor(data[index], index, dataset) > 0) { - assert.isTrue(selection.classed("waterfall-growth")); + describe("enabling connectors", () => { + let numAttr = TestMethods.numAttr; + let svg: d3.Selection; + let dataset: Plottable.Dataset; + let xScale: Plottable.Scales.Category; + let yScale: Plottable.Scales.Linear; + let plot: Plottable.Plots.Waterfall; + let data = [ + { x: "A", y: 20, t: true }, + { x: "B", y: 5, t: false }, + { x: "C", y: 25, t: true }, + { x: "D", y: -10, t: false }, + { x: "E", y: 15, t: true } + ]; + + beforeEach(() => { + svg = TestMethods.generateSVG(); + dataset = new Plottable.Dataset(data); + xScale = new Plottable.Scales.Category(); + yScale = new Plottable.Scales.Linear(); + plot = new Plottable.Plots.Waterfall(); + plot.x((d) => d.x, xScale); + plot.y((d) => d.y, yScale); + plot.total((d) => d.t); + plot.addDataset(dataset); + }); + + it("can set if connectors are enabled", () => { + assert.isFalse(plot.connectorsEnabled(), "no connectors by default"); + assert.strictEqual(plot.connectorsEnabled(true), plot, "setter returns calling object"); + plot.renderTo(svg); + let bars = plot.content().selectAll("rect"); + let connectors = plot.content().selectAll("line.connector"); + assert.strictEqual(bars.size(), connectors.size() + 1, "there is one more bar than number of connectors"); + connectors.each(function(datum, index) { + let connector = d3.select(this); + let bar = d3.select(bars[0][index]); + let connectorOnBottom = bar.classed("waterfall-decline"); + if (connectorOnBottom) { + assert.closeTo(numAttr(connector, "y1"), numAttr(bar, "y") + numAttr(bar, "height"), + window.Pixel_CloseTo_Requirement, "connector on declining bar at bottom"); } else { - assert.isTrue(selection.classed("waterfall-decline")); + assert.closeTo(numAttr(connector, "y1"), numAttr(bar, "y"), + window.Pixel_CloseTo_Requirement, "connector on non-declining bar at top"); } - } + assert.strictEqual(numAttr(connector, "y1"), numAttr(connector, "y2"), "connector stays at same height"); + }); + plot.destroy(); + svg.remove(); }); - svg.remove(); - }); - it("renders connector lines correctly", () => { - plot.connectorsEnabled(true); - plot.renderTo(svg); - let bars = renderArea.selectAll("rect")[0]; - let connectors = renderArea.selectAll("line.connector")[0]; - assert.isTrue(bars.length - 1 === connectors.length, "there is one more bar than number of connectors"); - connectors.forEach((connector, index) => { - let selection = d3.select(connector); - let firstBar = d3.select(bars[index]); - let secondBar = d3.select(bars[index + 1]); - let firstY = +firstBar.attr("y"); - let firstHeight = +firstBar.attr("height"); - let secondY = +secondBar.attr("y"); - let secondHeight = +secondBar.attr("height"); - if (firstY === secondY || Math.abs(secondY + secondHeight - firstY) < 1) { - assert.isTrue(firstY === +selection.attr("y1"), "connector is aligned to bars"); - } else { - assert.closeTo(firstY + firstHeight - +selection.attr("y1"), 0, 1, "connector is aligned to bars"); - } + it("can get if connectors are enabled", () => { + let connectorsEnabled = true; + plot.connectorsEnabled(connectorsEnabled); + assert.strictEqual(plot.connectorsEnabled(), connectorsEnabled, "can get if connectors are enabled"); + plot.destroy(); + svg.remove(); }); - svg.remove(); }); + }); }); diff --git a/test/testMethods.ts b/test/testMethods.ts index a6082b9e4a..3807bc4c6c 100644 --- a/test/testMethods.ts +++ b/test/testMethods.ts @@ -350,4 +350,18 @@ module TestMethods { assert.include(receivedWarning, warningMessage, assertMessage); } + export function assertLinePathEqualToDataPoints(path: string, data: {x: number, y: number}[], + xScale: Plottable.Scales.Linear, yScale: Plottable.Scales.Linear) { + let EPSILON = 0.0001; + let lineEdges = TestMethods.normalizePath(path).match(/(\-?\d+\.?\d*)(,|\s)(-?\d+\.?\d*)/g); + assert.strictEqual(lineEdges.length, data.length, "correct number of edges drawn"); + lineEdges.forEach((edge, i) => { + let coordinates = edge.split(/,|\s/); + assert.strictEqual(coordinates.length, 2, "There is an x coordinate and a y coordinate"); + assert.closeTo(xScale.invert(+coordinates[0]), data[i].x, EPSILON, + `Point ${i} drawn, has correct x coordinate`); + assert.closeTo(yScale.invert(+coordinates[1]), data[i].y, EPSILON, + `Point ${i} drawn, has correct y coordinate`); + }); + } } diff --git a/test/testReference.ts b/test/testReference.ts index 3c22a1d2c6..c06878612d 100644 --- a/test/testReference.ts +++ b/test/testReference.ts @@ -50,6 +50,7 @@ /// /// /// +/// /// ///