Commit 77f6449d by utkarshcmu

Added millisecond detection in series

parent 2db62a21
......@@ -168,4 +168,14 @@ export default class TimeSeries {
formatValue(value) {
return this.valueFormater(value, this.decimals, this.scaledDecimals);
}
isMsResolutionNeeded() {
for (var j = 0; j<this.datapoints.length; j++) {
var timestamp = this.datapoints[j][1].toString();
if (timestamp.length === 13 && parseInt(timestamp.substring(10,13)) !== 0) {
return true;
}
}
return false;
}
}
......@@ -109,7 +109,13 @@ function ($) {
var plot = elem.data().plot;
var plotData = plot.getData();
var seriesList = getSeriesFn();
var group, value, absoluteTime, relativeTime, hoverInfo, i, series, seriesHtml;
var group, value, absoluteTime, relativeTime, hoverInfo, i, series, seriesHtml, tooltipFormat;
if (panel.tooltip.msResolution) {
tooltipFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
} else {
tooltipFormat = 'YYYY-MM-DD HH:mm:ss';
}
if (dashboard.sharedCrosshair) {
ctrl.publishAppEvent('setCrosshair', { pos: pos, scope: scope });
......@@ -127,7 +133,7 @@ function ($) {
seriesHtml = '';
relativeTime = dashboard.getRelativeTime(seriesHoverInfo.time);
absoluteTime = dashboard.formatDate(seriesHoverInfo.time);
absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat);
for (i = 0; i < seriesHoverInfo.length; i++) {
hoverInfo = seriesHoverInfo[i];
......@@ -164,7 +170,7 @@ function ($) {
value = series.formatValue(value);
relativeTime = dashboard.getRelativeTime(item.datapoint[0]);
absoluteTime = dashboard.formatDate(item.datapoint[0]);
absoluteTime = dashboard.formatDate(item.datapoint[0], tooltipFormat);
group += '<div class="graph-tooltip-value">' + value + '</div>';
......
......@@ -69,6 +69,7 @@ var panelDefaults = {
tooltip : {
value_type: 'cumulative',
shared: true,
msResolution: false,
},
// time overrides
timeFrom: null,
......@@ -200,6 +201,8 @@ class GraphCtrl extends MetricsPanelCtrl {
}
this.datapointsCount += datapoints.length;
this.panel.tooltip.msResolution = this.panel.tooltip.msResolution || series.isMsResolutionNeeded();
}
return series;
......
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