Fine, use a string instead of date object
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { LineChart } from 'react-chartkick'
|
import { LineChart } from 'react-chartkick'
|
||||||
import styles from '../../styles/styles.module.scss';
|
import styles from '../../styles/styles.module.scss';
|
||||||
import 'chart.js';
|
import 'chart.js';
|
||||||
|
import format from 'date-fns/format'
|
||||||
|
|
||||||
interface TimedValue {
|
interface TimedValue {
|
||||||
time: Date;
|
time: Date;
|
||||||
@@ -19,7 +20,8 @@ function createGraphDataset(dataArray) {
|
|||||||
const dataValues = {};
|
const dataValues = {};
|
||||||
dataArray.forEach(item => {
|
dataArray.forEach(item => {
|
||||||
const dateObject = new Date(item.time);
|
const dateObject = new Date(item.time);
|
||||||
dataValues[dateObject] = item.value;
|
const dateString = format(dateObject, 'p P');
|
||||||
|
dataValues[dateString] = item.value;
|
||||||
})
|
})
|
||||||
return dataValues;
|
return dataValues;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user