Skip to content

Commit 0cbba91

Browse files
TSVB offsets (#83051) (#84421)
Closes: #40299 Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 5dc26e5 commit 0cbba91

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series

src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import _ from 'lodash';
20+
import { startsWith } from 'lodash';
2121
import moment from 'moment';
2222

2323
export function timeShift(resp, panel, series) {
@@ -26,13 +26,15 @@ export function timeShift(resp, panel, series) {
2626
const matches = series.offset_time.match(/^([+-]?[\d]+)([shmdwMy]|ms)$/);
2727

2828
if (matches) {
29-
const offsetValue = Number(matches[1]);
29+
const offsetValue = matches[1];
3030
const offsetUnit = matches[2];
31-
const offset = moment.duration(offsetValue, offsetUnit).valueOf();
3231

3332
results.forEach((item) => {
34-
if (_.startsWith(item.id, series.id)) {
35-
item.data = item.data.map(([time, value]) => [time + offset, value]);
33+
if (startsWith(item.id, series.id)) {
34+
item.data = item.data.map((row) => [
35+
moment.utc(row[0]).add(offsetValue, offsetUnit).valueOf(),
36+
row[1],
37+
]);
3638
}
3739
});
3840
}

0 commit comments

Comments
 (0)