[frontend] The stacked graph shouldn't have empty areas in the stacks
@@ -2573,16 +2573,6 @@ function togglePresentation(value) {};
}
}
});
- if (rawDatum.sorting == "asc") {
- _data.sort(function (a, b) {
- return a.y - b.y
- });
- }
- if (rawDatum.sorting == "desc") {
- _data.sort(function (a, b) {
- return b.y - a.y
- });
- }
_datum.push({
key: hueUtils.html2text(val),
values: _data
@@ -2590,26 +2580,53 @@ function togglePresentation(value) {};
});
}
});
+
// fills in missing values
- var longestSerie = 0;
+ var allXValues = [];
_datum.forEach(function (d) {
- if (d.values.length > longestSerie.length) {
- longestSerie = d.values;
+ d.values.forEach(function (val) {
+ if (allXValues.indexOf(val.x) === -1) {
+ allXValues.push(val.x);
}
});
+ });
+
_datum.forEach(function (d) {
- if (d.values.length < longestSerie.length) {
+ allXValues.forEach(function (val) {
+ if (!d.values.some(function (item) {
+ return item.x === val
+ })) {
var zeroObj = jQuery.extend({}, d.values[0]);
zeroObj.y = 0;
- for (var i = d.values.length; i < longestSerie.length; i++) {
- zeroObj.x = longestSerie[i].x;
+ zeroObj.x = val;
d.values.push(zeroObj)
}
- }
});
+ });
+
if (rawDatum.snippet.chartLimit()) {
_datum = _datum.slice(0, rawDatum.snippet.chartLimit());
}
+
+ if (rawDatum.sorting == "desc") {
+ _datum.forEach(function (d) {
+ d.values.sort(function (a, b) {
+ if (a.x > b.x) return -1;
+ if (a.x < b.x) return 1;
+ return 0;
+ });
+ });
+ }
+ else {
+ _datum.forEach(function (d) {
+ d.values.sort(function (a, b) {
+ if (a.x > b.x) return 1;
+ if (a.x < b.x) return -1;
+ return 0;
+ });
+ });
+ }
+
}
else {
rawDatum.snippet.result.meta().forEach(function (meta) {
