Skip to content
This repository has been archived by the owner on Dec 17, 2017. It is now read-only.

Commit

Permalink
Correct issues with nose dive data, NaN data on stacked graphs
Browse files Browse the repository at this point in the history
For a metric with σ = 0, it would appear as having no y-axis. This is corrected.
For a metric with σ = 0 and x̄ = 0, it would appear as having no value nor axis.
This is corrected.

Logic regarding how to handle a lack of data in descartes dataset padding is
corrected, and handled in rickshaw: the nil value is used in the controller,
which is explicitly handled in rickshaw to cast back to a NaN
  • Loading branch information
glasnt committed May 2, 2014
1 parent 04ba733 commit 71edfeb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/graphs/stacked.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ function renderStacked(data) {
}
}
if (isRight(n)) {
right_range = [ Math.min(min, right_range[0]) , Math.max(max, right_range[1]) ];
right_range = [ Math.min(min, right_range[0]) - 1 , Math.max(max, right_range[1]) + 1 ];
} else {
left_range = [ Math.min(min, left_range[0]) , Math.max(max, left_range[1]) ];
left_range = [ Math.min(min, left_range[0]) - 1, Math.max(max, left_range[1]) + 1 ];
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/backend/descartes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_metric m, start, stop, step
if points.length == 1 then
padded << points.first
elsif points.length == 0 then
padded << {x: i, y: (0.0/0.0)}
padded << {x: i, y: nil} # (0.0/0.0)}
end
end

Expand Down
4 changes: 3 additions & 1 deletion vendor/assets/javascripts/rickshaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,9 @@ Rickshaw.Graph = function(args) {
var seriesData = data[index];
if(seriesData) {
seriesData.forEach( function(d) {
d.y = series.scale(d.y);
// Want to handle NaN as no points - JSON won't accept these as NaN, so use null instead, and put back here.
if (d.y === null) { d.y = NaN; } else {
d.y = series.scale(d.y); }
} );
}
}
Expand Down

0 comments on commit 71edfeb

Please sign in to comment.