mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 01:16:31 -06:00
Fix 8706 (#8734)
* heatmap: fix incorrect time for UTC timezone, fixes #8706 * heatmap: fix tests for time format
This commit is contained in:
parent
8634c9d457
commit
97a7081b57
@ -100,10 +100,17 @@ export default function link(scope, elem, attrs, ctrl) {
|
||||
|
||||
let ticks = chartWidth / DEFAULT_X_TICK_SIZE_PX;
|
||||
let grafanaTimeFormatter = grafanaTimeFormat(ticks, timeRange.from, timeRange.to);
|
||||
let timeFormat;
|
||||
let dashboardTimeZone = ctrl.dashboard.getTimezone();
|
||||
if (dashboardTimeZone === 'utc') {
|
||||
timeFormat = d3.utcFormat(grafanaTimeFormatter);
|
||||
} else {
|
||||
timeFormat = d3.timeFormat(grafanaTimeFormatter);
|
||||
}
|
||||
|
||||
let xAxis = d3.axisBottom(xScale)
|
||||
.ticks(ticks)
|
||||
.tickFormat(d3.timeFormat(grafanaTimeFormatter))
|
||||
.tickFormat(timeFormat)
|
||||
.tickPadding(X_AXIS_TICK_PADDING)
|
||||
.tickSize(chartHeight);
|
||||
|
||||
|
@ -153,11 +153,11 @@ describe('grafanaHeatmap', function () {
|
||||
it('should draw correct X axis', function () {
|
||||
var xTicks = getTicks(ctx.element, ".axis-x");
|
||||
let expectedTicks = [
|
||||
formatLocalTime("01 Mar 2017 10:00:00"),
|
||||
formatLocalTime("01 Mar 2017 10:15:00"),
|
||||
formatLocalTime("01 Mar 2017 10:30:00"),
|
||||
formatLocalTime("01 Mar 2017 10:45:00"),
|
||||
formatLocalTime("01 Mar 2017 11:00:00")
|
||||
formatTime("01 Mar 2017 10:00:00"),
|
||||
formatTime("01 Mar 2017 10:15:00"),
|
||||
formatTime("01 Mar 2017 10:30:00"),
|
||||
formatTime("01 Mar 2017 10:45:00"),
|
||||
formatTime("01 Mar 2017 11:00:00")
|
||||
];
|
||||
expect(xTicks).to.eql(expectedTicks);
|
||||
});
|
||||
@ -261,7 +261,7 @@ function getTicks(element, axisSelector) {
|
||||
}).get();
|
||||
}
|
||||
|
||||
function formatLocalTime(timeStr) {
|
||||
function formatTime(timeStr) {
|
||||
let format = "HH:mm";
|
||||
return moment.utc(timeStr, 'DD MMM YYYY HH:mm:ss').local().format(format);
|
||||
return moment.utc(timeStr, 'DD MMM YYYY HH:mm:ss').format(format);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user