Commit 76c8d4fb authored by Mike Greiling's avatar Mike Greiling

Merge branch 'adriel-reduce-complexity-earliest-datapoint' into 'master'

Remove datapoint sorting from area chart

See merge request gitlab-org/gitlab-ce!26515
parents 8f0ad134 55fb75b9
...@@ -125,17 +125,17 @@ export default { ...@@ -125,17 +125,17 @@ export default {
}, },
earliestDatapoint() { earliestDatapoint() {
return this.chartData.reduce((acc, series) => { return this.chartData.reduce((acc, series) => {
if (!series.data.length) { const { data } = series;
const { length } = data;
if (!length) {
return acc; return acc;
} }
const [[timestamp]] = series.data.sort(([a], [b]) => {
if (a < b) {
return -1;
}
return a > b ? 1 : 0;
});
return timestamp < acc || acc === null ? timestamp : acc; const [first] = data[0];
const [last] = data[length - 1];
const seriesEarliest = first < last ? first : last;
return seriesEarliest < acc || acc === null ? seriesEarliest : acc;
}, null); }, null);
}, },
isMultiSeries() { isMultiSeries() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment