From 667d0f68daaa3916fac6653ef9994f6f2d05e177 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 22 Aug 2023 22:10:19 -0700 Subject: Fix chart X scale (fix #1167) --- modern/src/reports/ChartReportPage.jsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/modern/src/reports/ChartReportPage.jsx b/modern/src/reports/ChartReportPage.jsx index 2c33f0f5..643625df 100644 --- a/modern/src/reports/ChartReportPage.jsx +++ b/modern/src/reports/ChartReportPage.jsx @@ -1,3 +1,4 @@ +import moment from 'moment'; import React, { useState } from 'react'; import { FormControl, InputLabel, Select, MenuItem, @@ -51,7 +52,7 @@ const ChartReportPage = () => { const formattedPositions = positions.map((position) => { const data = { ...position, ...position.attributes }; const formatted = {}; - formatted.fixTime = formatTime(position.fixTime, 'time', hours12); + formatted.fixTime = moment(position.fixTime).valueOf(); Object.keys(data).filter((key) => !['id', 'deviceId'].includes(key)).forEach((key) => { const value = data[key]; if (typeof value === 'number') { @@ -122,10 +123,23 @@ const ChartReportPage = () => { top: 10, right: 40, left: 0, bottom: 10, }} > - - value.toFixed(2)} domain={[minValue - valueRange / 5, maxValue + valueRange / 5]} /> + formatTime(value, 'time', hours12)} + domain={['dataMin', 'dataMax']} + scale="time" + /> + value.toFixed(2)} + domain={[minValue - valueRange / 5, maxValue + valueRange / 5]} + /> - [value, positionAttributes[key]?.name || key]} /> + [value, positionAttributes[key]?.name || key]} + labelFormatter={(value) => formatTime(value, 'seconds', hours12)} + /> -- cgit v1.2.3