Commit 51a9797d authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Restored the timeScaleFormat for the prometheus dashboard

parent 4e0e2fd9
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
import MonitoringMixin from '../mixins/monitoring_mixins'; import MonitoringMixin from '../mixins/monitoring_mixins';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import measurements from '../utils/measurements'; import measurements from '../utils/measurements';
import { bisectDate } from '../utils/date_time_formatters'; import { bisectDate, timeScaleFormat } from '../utils/date_time_formatters';
import createTimeSeries from '../utils/multiple_time_series'; import createTimeSeries from '../utils/multiple_time_series';
import bp from '../../breakpoints'; import bp from '../../breakpoints';
...@@ -171,7 +171,8 @@ ...@@ -171,7 +171,8 @@
axisYScale.domain([0, d3.max(allValues.map(d => d.value))]); axisYScale.domain([0, d3.max(allValues.map(d => d.value))]);
const xAxis = d3.axisBottom() const xAxis = d3.axisBottom()
.scale(axisXScale); .scale(axisXScale)
.tickFormat(timeScaleFormat);
const yAxis = d3.axisLeft() const yAxis = d3.axisLeft()
.scale(axisYScale) .scale(axisYScale)
......
import { timeFormat as time } from 'd3-time-format'; import { timeFormat as time } from 'd3-time-format';
import { timeSecond, timeMinute, timeHour, timeDay, timeMonth, timeYear } from 'd3-time';
import { bisector } from 'd3-array'; import { bisector } from 'd3-array';
export const dateFormat = time('%b %-d, %Y'); const d3 = { time, bisector, timeSecond, timeMinute, timeHour, timeDay, timeMonth, timeYear };
export const timeFormat = time('%-I:%M%p');
export const dateFormatWithName = time('%a, %b %-d'); export const dateFormat = d3.time('%b %-d, %Y');
export const bisectDate = bisector(d => d.time).left; export const timeFormat = d3.time('%-I:%M%p');
export const dateFormatWithName = d3.time('%a, %b %-d');
export const bisectDate = d3.bisector(d => d.time).left;
const formatMillisecond = d3.time('.%L');
const formatSecond = d3.time(':%S');
const formatMinute = d3.time('%-I:%M');
const formatHour = d3.time('%-I %p');
const formatDay = d3.time('%a %d');
const formatWeek = d3.time('%b %d');
const formatMonth = d3.time('%B');
const formatYear = d3.time('%Y');
export function timeScaleFormat(date) {
let formatFunction;
if (d3.timeSecond(date) < date) {
formatFunction = formatMillisecond;
} else if (d3.timeMinute(date) < date) {
formatFunction = formatSecond;
} else if (d3.timeHour(date) < date) {
formatFunction = formatMinute;
} else if (d3.timeDay(date) < date) {
formatFunction = formatHour;
} else if (d3.timeWeek(date) < date) {
formatFunction = formatDay;
} else if (d3.timeMonth(date) < date) {
formatFunction = formatWeek;
} else if (d3.timeYear(date) < date) {
formatFunction = formatMonth;
} else {
formatFunction = formatYear;
}
return formatFunction(date);
}
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