diff --git a/client/assets/scss/Content.scss b/client/assets/scss/Content.scss index fa8132f..9c41fdf 100644 --- a/client/assets/scss/Content.scss +++ b/client/assets/scss/Content.scss @@ -2,7 +2,6 @@ flex: 1; flex-wrap: wrap; min-width: 0; - min-height: 500px; .post+ .post { margin-top: 2em; } diff --git a/client/assets/scss/main.scss b/client/assets/scss/main.scss index 25b126c..7095df4 100644 --- a/client/assets/scss/main.scss +++ b/client/assets/scss/main.scss @@ -55,6 +55,19 @@ hr { border-top: 1px solid #eee; } +select{ + background-color: #fff; + border: 1px solid #ccc; + border-radius: 0.2em; + height: 35px; + color: #555; + &:focus{ + border-color: #66afe9; + outline: 0; + box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6); + } +} + .Footer, .Main { display: flex; diff --git a/client/js/components/sensors/SensorInfo.css b/client/js/components/sensors/SensorInfo.css new file mode 100644 index 0000000..fa108b7 --- /dev/null +++ b/client/js/components/sensors/SensorInfo.css @@ -0,0 +1,15 @@ +.SensorInfo { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + flex-wrap: wrap; + min-width: 0; + width: 80%; } + .SensorInfo .selector-row { + margin-left: auto; + margin-right: auto; } + .SensorInfo .selector-row select + select { + margin-left: 5px; } + +/*# sourceMappingURL=SensorInfo.css.map */ diff --git a/client/js/components/sensors/SensorInfo.css.map b/client/js/components/sensors/SensorInfo.css.map new file mode 100644 index 0000000..fdb5015 --- /dev/null +++ b/client/js/components/sensors/SensorInfo.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,WAAW;EACP,IAAI,EAAE,CAAC;EACP,OAAO,EAAE,IAAI;EACb,cAAc,EAAE,MAAM;EACtB,WAAW,EAAE,MAAM;EACnB,SAAS,EAAE,IAAI;EACf,SAAS,EAAE,CAAC;EACZ,KAAK,EAAE,GAAG;EACV,yBAAa;IACT,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,yCAAa;MACT,WAAW,EAAE,GAAG", +"sources": ["SensorInfo.scss"], +"names": [], +"file": "SensorInfo.css" +} \ No newline at end of file diff --git a/client/js/components/sensors/SensorInfo.js b/client/js/components/sensors/SensorInfo.js index 2f8663e..7265edb 100644 --- a/client/js/components/sensors/SensorInfo.js +++ b/client/js/components/sensors/SensorInfo.js @@ -1,18 +1,17 @@ import React from 'react'; import Loading from '../utils/Loading'; +import _chartjs from 'chart.js'; +import Chart from 'react-chartjs'; import { - LineChart, - Line, - XAxis, - YAxis, - CartesianGrid, - Tooltip, - Legend + Options, + Data } -from 'recharts'; +from './chartOptions'; import './SensorInfo.scss'; +const LineChart = Chart.Line; + export default class SensorInfo extends React.Component { componentDidMount() { @@ -20,6 +19,13 @@ export default class SensorInfo extends React.Component { this.props.sensorActions.fetchUniqueDates(location); } + componentWillReceiveProps(nextProps) { + let currentLocation = this.props.params.location, + nextLocation = nextProps.params.location; + + currentLocation !== nextLocation ? this.props.sensorActions.fetchUniqueDates(nextLocation) : null; + } + loadYearOptions = (date, index) => { return ( @@ -56,54 +62,37 @@ export default class SensorInfo extends React.Component { } filterData(data) { - let filteredData = []; + let temp = JSON.parse(JSON.stringify(Data)); for (let d of data) { - filteredData.push({ - name: d.day, - max: d.maxtemp, - min: d.mintemp - }); + let label = `${d.month}/${d.day}`; + temp.labels.push(label); + temp.datasets[0].data.push(d.maxtemp); + temp.datasets[1].data.push(d.mintemp); } - - return filteredData; + + return temp; } - + render() { let sensor = this.props.sensor; let data = this.filterData(sensor.info); - + return (