Browse Source

Cleanup and linting

pull/1886/head
Gabe Kangas 5 years ago
parent
commit
e3d6c2872e
  1. 12
      web/pages/components/chart.tsx

12
web/pages/components/chart.tsx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
import styles from '../../styles/styles.module.css';
import { LineChart } from 'react-chartkick'
import styles from '../../styles/styles.module.css';
import 'chart.js'
const defaultProps = {
@ -22,22 +22,22 @@ interface ChartProps { @@ -22,22 +22,22 @@ interface ChartProps {
}
function createGraphDataset(dataArray) {
var dataValues = {};
const dataValues = {};
dataArray.forEach(item => {
const dateObject = new Date(item.time);
const dateString = dateObject.getFullYear() + '-' + dateObject.getMonth() + '-' + dateObject.getDay() + ' ' + dateObject.getHours() + ':' + dateObject.getMinutes();
const dateString = `${dateObject.getFullYear() }-${ dateObject.getMonth() }-${ dateObject.getDay() } ${ dateObject.getHours() }:${ dateObject.getMinutes()}`;
dataValues[dateString] = item.value;
})
return dataValues;
}
export default function Chart({ data, title, color, unit, dataCollections }: ChartProps) {
var renderData = [];
const renderData = [];
if (data && data.length > 0) {
renderData.push({
name: title,
color: color,
color,
data: createGraphDataset(data)
});
}
@ -54,7 +54,7 @@ export default function Chart({ data, title, color, unit, dataCollections }: Cha @@ -54,7 +54,7 @@ export default function Chart({ data, title, color, unit, dataCollections }: Cha
xtitle="Time"
ytitle={title}
suffix={unit}
legend={"bottom"}
legend="bottom"
color={color}
data={renderData}
download={title}

Loading…
Cancel
Save