Skip to content

Commit

Permalink
Fixes histogram plot disappears when time range is too small (issue e…
Browse files Browse the repository at this point in the history
…lastic#733)

This fixes rounding behaviour in interval_to_ms. The interval_to_ms
function will round any fractional component of an interval to 0 because
it tries to parse it as an integer.

I've fixed it by trying by parsing as a float but then trying to preserve
the existing behaviour of returning integer results in the callers.

closes elasticsearch/kibana/elastic#733
  • Loading branch information
kuwerty committed Feb 24, 2014
1 parent 2c2a0aa commit 1c2d0c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/app/components/kbn.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,19 @@ function($, _, moment) {
return {
sec: kbn.intervals_in_seconds[matches[2]],
type: matches[2],
count: parseInt(matches[1], 10)
count: parseFloat(matches[1])
};
}
};

kbn.interval_to_ms = function(string) {
var info = kbn.describe_interval(string);
return info.sec * 1000 * info.count;
return Math.ceil(info.sec * 1000 * info.count);
};

kbn.interval_to_seconds = function (string) {
var info = kbn.describe_interval(string);
return info.sec * info.count;
return Math.ceil(info.sec * info.count);
};

// This should go away, moment.js can do this
Expand Down
2 changes: 1 addition & 1 deletion src/app/panels/histogram/interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function (kbn) {

var info = kbn.describe_interval(interval_string);
this.type = info.type;
this.ms = info.sec * 1000 * info.count;
this.ms = Math.ceil(info.sec * 1000 * info.count);

// does the length of the interval change based on the current time?
if (this.type === 'y' || this.type === 'M') {
Expand Down
2 changes: 1 addition & 1 deletion src/app/panels/sparklines/interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function (kbn) {

var info = kbn.describe_interval(interval_string);
this.type = info.type;
this.ms = info.sec * 1000 * info.count;
this.ms = Math.ceil(info.sec * 1000 * info.count);

// does the length of the interval change based on the current time?
if (this.type === 'y' || this.type === 'M') {
Expand Down

0 comments on commit 1c2d0c6

Please sign in to comment.