Skip to content

Commit

Permalink
Merge branch 'release-v0.45.0'
Browse files Browse the repository at this point in the history
Conflicts:
	plottable.zip
  • Loading branch information
Justin Lan committed Feb 20, 2015
2 parents f1613ae + b647fb8 commit 4e216ba
Show file tree
Hide file tree
Showing 49 changed files with 2,196 additions and 1,299 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plottable",
"description": "A library for creating charts out of D3",
"version": "0.44.0",
"version": "0.45.0",
"main": ["plottable.js", "plottable.css"],
"license": "MIT",
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plottable.js",
"description": "A library for creating charts out of D3",
"version": "0.44.0",
"version": "0.45.0",
"repository": {
"type": "git",
"url": "https://github.com/palantir/plottable.git"
Expand Down
260 changes: 97 additions & 163 deletions plottable.d.ts

Large diffs are not rendered by default.

638 changes: 342 additions & 296 deletions plottable.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions plottable.min.js

Large diffs are not rendered by default.

Binary file modified plottable.zip
Binary file not shown.
36 changes: 2 additions & 34 deletions src/components/abstractComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ export module Component {

this._interactionsToRegister.forEach((r) => this.registerInteraction(r));
this._interactionsToRegister = null;
if (this._isTopLevelComponent) {
this.autoResize(this._autoResize);
}
this._isSetup = true;
}

Expand Down Expand Up @@ -217,46 +214,18 @@ export module Component {
}

/**
* Causes the Component to recompute layout and redraw. If passed arguments, will resize the root SVG it lives in.
* Causes the Component to recompute layout and redraw.
*
* This function should be called when CSS changes could influence the size
* of the components, e.g. changing the font size.
*
* @param {number} [availableWidth] - the width of the container element
* @param {number} [availableHeight] - the height of the container element
* @returns {Component} The calling component.
*/
public resize(width?: number, height?: number): AbstractComponent {
if (!this._isTopLevelComponent) {
throw new Error("Cannot resize on non top-level component");
}
if (width != null && height != null && this._isAnchored) {
this._rootSVG.attr({width: width, height: height});
}
public redraw(): AbstractComponent {
this._invalidateLayout();
return this;
}

/**
* Enables or disables resize on window resizes.
*
* If enabled, window resizes will enqueue this component for a re-layout
* and re-render. Animations are disabled during window resizes when auto-
* resize is enabled.
*
* @param {boolean} flag Enable (true) or disable (false) auto-resize.
* @returns {Component} The calling component.
*/
public autoResize(flag: boolean): AbstractComponent {
if (flag) {
Core.ResizeBroadcaster.register(this);
} else {
Core.ResizeBroadcaster.deregister(this);
}
this._autoResize = flag; // if _setup were called by constructor, this var could be _removed #591
return this;
}

/**
* Sets the x alignment of the Component. This will be used if the
* Component is given more space than it needs.
Expand Down Expand Up @@ -498,7 +467,6 @@ export module Component {
public remove() {
this._removed = true;
this.detach();
Core.ResizeBroadcaster.deregister(this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/axes/categoryAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export module Axis {

return {
textFits: wrappingResults.every((t: SVGTypewriter.Wrappers.WrappingResult) =>
!SVGTypewriter.Utils.StringMethods.isNotEmptyString(t.truncatedText) && t.noLines === 1),
SVGTypewriter.Utils.StringMethods.isNotEmptyString(t.truncatedText) && t.noLines === 1),
usedWidth : widthFn<SVGTypewriter.Wrappers.WrappingResult, number>(wrappingResults,
(t: SVGTypewriter.Wrappers.WrappingResult) => this._measurer.measure(t.wrappedText).width, 0),
usedHeight: heightFn<SVGTypewriter.Wrappers.WrappingResult, number>(wrappingResults,
Expand Down
10 changes: 9 additions & 1 deletion src/components/axes/numericAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ export module Axis {
}

protected _getTickValues(): any[] {
return (<Scale.AbstractQuantitative<number>> this._scale).ticks();
var scale = (<Scale.AbstractQuantitative<number>> this._scale);
var domain = scale.domain();
var min = domain[0] <= domain[1] ? domain[0] : domain[1];
var max = domain[0] >= domain[1] ? domain[0] : domain[1];
if (min === domain[0]) {
return scale.ticks().filter((i: number) => i >= min && i <= max);
} else {
return scale.ticks().filter((i: number) => i >= min && i <= max).reverse();
}
}

protected _rescale() {
Expand Down
39 changes: 32 additions & 7 deletions src/components/plots/abstractPlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export module Plot {
datasetKey: string
}

export type PlotData = {
data: any[];
pixelPoints: Point[];
selection: D3.Selection;
}

export class AbstractPlot extends Component.AbstractComponent {
protected _dataChanged = false;
protected _key2PlotDatasetKey: D3.Map<PlotDatasetKey>;
Expand Down Expand Up @@ -415,16 +421,35 @@ export module Plot {
this._additionalPaint(maxTime);
}

public getAllSelections(): D3.Selection {
var allSelections = d3.select();
allSelections[0] = [];
this._getDrawersInOrder().forEach((drawer) => {
drawer._getRenderArea().selectAll(drawer._getSelector())[0].forEach((selection: EventTarget) => {
allSelections[0].push(selection);
/**
* Retrieves all of the selections of this plot for the specified dataset(s)
*
* @param {string | string[]} datasetKeys The dataset(s) to retrieve the selections from.
* If not provided, all selections will be retrieved.
* @returns {D3.Selection} The retrieved selections.
*/
public getAllSelections(datasetKeys?: string | string[]): D3.Selection {
var datasetKeyArray: string[] = [];
if (datasetKeys == null) {
datasetKeyArray = this._datasetKeysInOrder;
} else if (typeof(datasetKeys) === "string") {
datasetKeyArray = [<string> datasetKeys];
} else {
datasetKeyArray = <string[]> datasetKeys;
}

var allSelections: EventTarget[] = [];

datasetKeyArray.forEach((datasetKey) => {
var plotDatasetKey = this._key2PlotDatasetKey.get(datasetKey);
if (plotDatasetKey == null) { return; }
var drawer = plotDatasetKey.drawer;
drawer._getRenderArea().selectAll(drawer._getSelector()).each(function () {
allSelections.push(this);
});
});

return allSelections;
return d3.selectAll(allSelections);
}
}
}
Expand Down
17 changes: 15 additions & 2 deletions src/core/broadcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export module Core {
* Registers a callback to be called when the broadcast method is called. Also takes a key which
* is used to support deregistering the same callback later, by passing in the same key.
* If there is already a callback associated with that key, then the callback will be replaced.
* The callback will be passed the Broadcaster's "listenable" as the `this` context.
*
* @param key The key associated with the callback. Key uniqueness is determined by deep equality.
* @param {BroadcasterCallback<L>} callback A callback to be called.
Expand All @@ -58,7 +59,10 @@ export module Core {
* @returns {Broadcaster} The calling Broadcaster
*/
public broadcast(...args: any[]) {
this._key2callback.values().forEach((callback) => callback(this._listenable, args));
args.unshift(this._listenable);
this._key2callback.values().forEach((callback) => {
callback.apply(this._listenable, args);
});
return this;
}

Expand All @@ -74,7 +78,16 @@ export module Core {
}

/**
* Deregisters all listeners and callbacks associated with the broadcaster.
* Gets the keys for all listeners attached to the Broadcaster.
*
* @returns {any[]} An array of the keys.
*/
public getListenerKeys() {
return this._key2callback.keys();
}

/**
* Deregisters all listeners and callbacks associated with the Broadcaster.
*
* @returns {Broadcaster} The calling Broadcaster
*/
Expand Down
3 changes: 0 additions & 3 deletions src/core/renderController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ export module Core {
_animationRequested = false;
_isCurrentlyFlushing = false;
}

// Reset resize flag regardless of queue'd components
ResizeBroadcaster.clearResizing();
}
}

Expand Down
81 changes: 0 additions & 81 deletions src/core/resizeBroadcaster.ts

This file was deleted.

Loading

0 comments on commit 4e216ba

Please sign in to comment.