Skip to content

Commit

Permalink
Merge pull request #1696 from palantir/release-v0.45.2
Browse files Browse the repository at this point in the history
Release v0.45.2
  • Loading branch information
rcchen committed Feb 27, 2015
2 parents 8db3718 + 4ea8bd5 commit 268c023
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 26 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.45.1",
"version": "0.45.2",
"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.45.1",
"version": "0.45.2",
"repository": {
"type": "git",
"url": "https://github.com/palantir/plottable.git"
Expand Down
47 changes: 38 additions & 9 deletions plottable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Plottable 0.45.1 (https://github.com/palantir/plottable)
Plottable 0.45.2 (https://github.com/palantir/plottable)
Copyright 2014 Palantir Technologies
Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -990,7 +990,7 @@ var Plottable;
///<reference path="../reference.ts" />
var Plottable;
(function (Plottable) {
Plottable.version = "0.45.1";
Plottable.version = "0.45.2";
})(Plottable || (Plottable = {}));

///<reference path="../reference.ts" />
Expand Down Expand Up @@ -5034,16 +5034,45 @@ var Plottable;
var _this = this;
var wrappingResults = ticks.map(function (s) {
var bandWidth = scale.stepWidth();
var width = _this._isHorizontal() ? bandWidth : axisWidth - _this._maxLabelTickLength() - _this.tickLabelPadding();
var height = _this._isHorizontal() ? axisHeight - _this._maxLabelTickLength() - _this.tickLabelPadding() : bandWidth;
// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
var width = axisWidth - _this._maxLabelTickLength() - _this.tickLabelPadding(); // default for left/right
if (_this._isHorizontal()) {
width = bandWidth; // defaults to the band width
if (_this._tickLabelAngle !== 0) {
width = axisHeight - _this._maxLabelTickLength() - _this.tickLabelPadding(); // use the axis height
}
// HACKHACK: Wrapper fails under negative circumstances
width = Math.max(width, 0);
}
// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
var height = bandWidth; // default for left/right
if (_this._isHorizontal()) {
height = axisHeight - _this._maxLabelTickLength() - _this.tickLabelPadding();
if (_this._tickLabelAngle !== 0) {
height = axisWidth - _this._maxLabelTickLength() - _this.tickLabelPadding();
}
// HACKHACK: Wrapper fails under negative circumstances
height = Math.max(height, 0);
}
return _this._wrapper.wrap(_this.formatter()(s), _this._measurer, width, height);
});
var widthFn = this._isHorizontal() ? d3.sum : Plottable._Util.Methods.max;
var heightFn = this._isHorizontal() ? Plottable._Util.Methods.max : d3.sum;
// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
var widthFn = (this._isHorizontal() && this._tickLabelAngle === 0) ? d3.sum : Plottable._Util.Methods.max;
var heightFn = (this._isHorizontal() && this._tickLabelAngle === 0) ? Plottable._Util.Methods.max : d3.sum;
var textFits = wrappingResults.every(function (t) { return !SVGTypewriter.Utils.StringMethods.isNotEmptyString(t.truncatedText) && t.noLines === 1; });
var usedWidth = widthFn(wrappingResults, function (t) { return _this._measurer.measure(t.wrappedText).width; }, 0);
var usedHeight = heightFn(wrappingResults, function (t) { return _this._measurer.measure(t.wrappedText).height; }, 0);
// If the tick labels are rotated, reverse usedWidth and usedHeight
// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
if (this._tickLabelAngle !== 0) {
var tempHeight = usedHeight;
usedHeight = usedWidth;
usedWidth = tempHeight;
}
return {
textFits: wrappingResults.every(function (t) { return SVGTypewriter.Utils.StringMethods.isNotEmptyString(t.truncatedText) && t.noLines === 1; }),
usedWidth: widthFn(wrappingResults, function (t) { return _this._measurer.measure(t.wrappedText).width; }, 0),
usedHeight: heightFn(wrappingResults, function (t) { return _this._measurer.measure(t.wrappedText).height; }, 0)
textFits: textFits,
usedWidth: usedWidth,
usedHeight: usedHeight
};
};
Category.prototype._doRender = function () {
Expand Down
10 changes: 5 additions & 5 deletions plottable.min.js

Large diffs are not rendered by default.

Binary file modified plottable.zip
Binary file not shown.
54 changes: 44 additions & 10 deletions src/components/axes/categoryAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,55 @@ export module Axis {
private _measureTicks(axisWidth: number, axisHeight: number, scale: Scale.Ordinal, ticks: string[]) {
var wrappingResults = ticks.map((s: string) => {
var bandWidth = scale.stepWidth();
var width = this._isHorizontal() ? bandWidth : axisWidth - this._maxLabelTickLength() - this.tickLabelPadding();
var height = this._isHorizontal() ? axisHeight - this._maxLabelTickLength() - this.tickLabelPadding() : bandWidth;

// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
var width = axisWidth - this._maxLabelTickLength() - this.tickLabelPadding(); // default for left/right
if (this._isHorizontal()) { // case for top/bottom
width = bandWidth; // defaults to the band width
if (this._tickLabelAngle !== 0) { // rotated label
width = axisHeight - this._maxLabelTickLength() - this.tickLabelPadding(); // use the axis height
}
// HACKHACK: Wrapper fails under negative circumstances
width = Math.max(width, 0);
}

// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
var height = bandWidth; // default for left/right
if (this._isHorizontal()) { // case for top/bottom
height = axisHeight - this._maxLabelTickLength() - this.tickLabelPadding();
if (this._tickLabelAngle !== 0) { // rotated label
height = axisWidth - this._maxLabelTickLength() - this.tickLabelPadding();
}
// HACKHACK: Wrapper fails under negative circumstances
height = Math.max(height, 0);
}

return this._wrapper.wrap(this.formatter()(s), this._measurer, width, height);
});

var widthFn = this._isHorizontal() ? d3.sum : _Util.Methods.max;
var heightFn = this._isHorizontal() ? _Util.Methods.max : d3.sum;
// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
var widthFn = (this._isHorizontal() && this._tickLabelAngle === 0) ? d3.sum : _Util.Methods.max;
var heightFn = (this._isHorizontal() && this._tickLabelAngle === 0) ? _Util.Methods.max : d3.sum;

var textFits = wrappingResults.every((t: SVGTypewriter.Wrappers.WrappingResult) =>
!SVGTypewriter.Utils.StringMethods.isNotEmptyString(t.truncatedText) && t.noLines === 1);
var usedWidth = widthFn<SVGTypewriter.Wrappers.WrappingResult, number>(wrappingResults,
(t: SVGTypewriter.Wrappers.WrappingResult) => this._measurer.measure(t.wrappedText).width, 0);
var usedHeight = heightFn<SVGTypewriter.Wrappers.WrappingResult, number>(wrappingResults,
(t: SVGTypewriter.Wrappers.WrappingResult) => this._measurer.measure(t.wrappedText).height, 0);

// If the tick labels are rotated, reverse usedWidth and usedHeight
// HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
if (this._tickLabelAngle !== 0) {
var tempHeight = usedHeight;
usedHeight = usedWidth;
usedWidth = tempHeight;
}

return {
textFits: wrappingResults.every((t: SVGTypewriter.Wrappers.WrappingResult) =>
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,
(t: SVGTypewriter.Wrappers.WrappingResult) => this._measurer.measure(t.wrappedText).height, 0)
textFits: textFits,
usedWidth : usedWidth,
usedHeight: usedHeight
};
}

Expand Down

0 comments on commit 268c023

Please sign in to comment.