Skip to content

Commit

Permalink
Merge pull request #731 from palantir/slate-quickfix
Browse files Browse the repository at this point in the history
fix _getParsedStyle() and Label._requestedSpace
  • Loading branch information
bmalehorn committed Jul 22, 2014
2 parents af33ff1 + 08c1079 commit bd6bbaa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions plottable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,10 +1017,11 @@ var Plottable;

function _getParsedStyleValue(style, prop) {
var value = style.getPropertyValue(prop);
if (value == null) {
var parsedValue = parseFloat(value);
if (parsedValue !== parsedValue) {
return 0;
}
return parseFloat(value);
return parsedValue;
}

//
Expand Down Expand Up @@ -5403,6 +5404,14 @@ var Plottable;

Legend.prototype._requestedSpace = function (offeredWidth, offeredY) {
var textHeight = this.measureTextHeight();
if (textHeight === 0) {
return {
width: 0,
height: 0,
wantsWidth: false,
wantsHeight: false
};
}
var totalNumRows = this.colorScale.domain().length;
var rowsICanFit = Math.min(totalNumRows, Math.floor(offeredY / textHeight));

Expand Down
8 changes: 8 additions & 0 deletions src/components/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ export module Component {

public _requestedSpace(offeredWidth: number, offeredY: number): ISpaceRequest {
var textHeight = this.measureTextHeight();
if (textHeight === 0) {
return {
width: 0,
height: 0,
wantsWidth: false,
wantsHeight: false
};
}
var totalNumRows = this.colorScale.domain().length;
var rowsICanFit = Math.min(totalNumRows, Math.floor(offeredY / textHeight));

Expand Down
7 changes: 4 additions & 3 deletions src/utils/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ export module Util {

function _getParsedStyleValue(style: CSSStyleDeclaration, prop: string): number {
var value: any = style.getPropertyValue(prop);
if (value == null){
return 0;
var parsedValue = parseFloat(value);
if (parsedValue !== parsedValue) {
return 0;
}
return parseFloat(value);
return parsedValue;
}

//
Expand Down

0 comments on commit bd6bbaa

Please sign in to comment.