Skip to content

Commit

Permalink
fix min/max values for non-stacked charts
Browse files Browse the repository at this point in the history
  • Loading branch information
selaux committed Jun 13, 2014
1 parent 4a9ca81 commit f0b354d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/modules/miners/aggregated.js
Expand Up @@ -41,7 +41,7 @@ module.exports = Module.extend({
return module.id === id;
});
minerTitles[id] = module ? module.title : id;
individualHashrates['currentHashrate.' + module.id] = module ? module.get('currentHashrate') : 0;
individualHashrates['currentHashrate.' + module.id] = module && module.get('currentHashrate') ? module.get('currentHashrate') : 0;
currentHashrate += module.get('currentHashrate') || 0;
});

Expand Down
18 changes: 9 additions & 9 deletions lib/views/mixins/renderHistoricalDataGraph.js
Expand Up @@ -10,19 +10,19 @@ if (typeof window !== 'undefined') {
}

function getValueRange(series, stacked) {
var values = _(series).map(function (ser) {
var values = _.map(series, function (ser) {
return _.pluck(ser.data, 'y');
});

if (stacked) {
return _(values).zip().map(function (ser) {
return _.reduce(ser, function (a, b) { return a + b; });
});
values = _.map(_.zip(values), (function (ser) {
return _.reduce(ser, function (a, b) { return a + b; }, 0);
}));
} else {
return _(values).map(function (ser) {
return _.max(ser);
});
values = _.flatten(values);
}

return values;
}

module.exports = function (attributes, element, graphOptions, hoverOptions) {
Expand Down Expand Up @@ -83,8 +83,8 @@ module.exports = function (attributes, element, graphOptions, hoverOptions) {
updateGraph: function () {
var series = this.getSeries();

this.graph.min = _.min(getValueRange(series, this.graph.config.stack)) * 0.99;
this.graph.min = _.max(getValueRange(series, this.graph.config.stack)) * 1.01;
this.graph.min = (this.graph.config.stack ? 0 : _.min(getValueRange(series, this.graph.config.stack))) *0.99;
this.graph.max = _.max(getValueRange(series, this.graph.config.stack)) * 1.01;
_.each(this.graph.series, function (graphSeries, index) {
graphSeries.data = series[index].data;
});
Expand Down

0 comments on commit f0b354d

Please sign in to comment.