Skip to content

Commit

Permalink
[Vislib] Use timestamp on brush event instead of iso dates
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Feb 16, 2021
1 parent 52cd0d9 commit 208c416
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/plugins/vis_type_vislib/public/vislib/lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import d3 from 'd3';
import _ from 'lodash';
import MarkdownIt from 'markdown-it';
import moment from 'moment';

import { dispatchRenderComplete } from '../../../../kibana_utils/public';

Expand All @@ -26,6 +27,10 @@ const markdownIt = new MarkdownIt({
linkify: true,
});

const convertToTimestamp = (dateString) => {
return parseInt(moment(dateString).format('x'));
};

/**
* Handles building all the components of the visualization
*
Expand Down Expand Up @@ -80,11 +85,13 @@ export class Handler {
case 'brush':
const xRaw = _.get(eventPayload.data, 'series[0].values[0].xRaw');
if (!xRaw) return; // not sure if this is possible?
const [start, end] = eventPayload.range;
const range = [convertToTimestamp(start), convertToTimestamp(end)];
return self.vis.emit(eventType, {
name: 'brush',
data: {
table: xRaw.table,
range: eventPayload.range,
range,
column: xRaw.column,
},
});
Expand Down

0 comments on commit 208c416

Please sign in to comment.