1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 02:12:53 +00:00

more chart

This commit is contained in:
2016-09-16 20:39:41 +00:00
parent d00d069744
commit 11a91412c1
6 changed files with 22 additions and 42 deletions

View File

@@ -25,7 +25,6 @@ h5,
h6 { h6 {
margin: 0; margin: 0;
font-weight: 400; font-weight: 400;
line-height: 1em;
} }
p { p {

View File

@@ -1,15 +0,0 @@
.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 */

View File

@@ -1,7 +0,0 @@
{
"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"
}

View File

@@ -3,8 +3,8 @@ import Loading from '../utils/Loading';
import _chartjs from 'chart.js'; import _chartjs from 'chart.js';
import Chart from 'react-chartjs'; import Chart from 'react-chartjs';
import { import {
Options, ChartOptions,
Data DataTemplate
} }
from './chartOptions'; from './chartOptions';
@@ -62,8 +62,9 @@ export default class SensorInfo extends React.Component {
} }
filterData(data) { filterData(data) {
let temp = JSON.parse(JSON.stringify(Data)); let temp = JSON.parse(JSON.stringify(DataTemplate));
console.log(temp);
for (let d of data) { for (let d of data) {
let label = `${d.month}/${d.day}`; let label = `${d.month}/${d.day}`;
temp.labels.push(label); temp.labels.push(label);
@@ -77,11 +78,11 @@ export default class SensorInfo extends React.Component {
render() { render() {
let sensor = this.props.sensor; let sensor = this.props.sensor;
let data = this.filterData(sensor.info); let data = this.filterData(sensor.info);
return ( return (
<div class="SensorInfo"> <div class="SensorInfo">
{sensor.fetchedUniqueDates ? {sensor.fetchedUniqueDates ?
<div class="selector-row"> <div class="selector-row">
<h2>{this.props.params.location}</h2>
<select onChange={(e) => {this.onChange(e, 'year')}}> <select onChange={(e) => {this.onChange(e, 'year')}}>
{sensor.uniqueDates.map(this.loadYearOptions)} {sensor.uniqueDates.map(this.loadYearOptions)}
</select> </select>
@@ -92,7 +93,9 @@ export default class SensorInfo extends React.Component {
</div> </div>
: <Loading/>} : <Loading/>}
{sensor.fetchedUniqueDates ? <LineChart data={data} options={Options}/> : null} {sensor.fetchedUniqueDates && sensor.fetchedInfo
? <LineChart data={data} options={ChartOptions} redraw/>
: null}
</div> </div>
); );
} }

View File

@@ -6,10 +6,10 @@
min-width: 0; min-width: 0;
width: 80%; width: 80%;
.selector-row{ .selector-row{
margin-left: auto; display: flex;
margin-right: auto; justify-content: center;
margin-bottom: 1em; margin-bottom: 1em;
select+select{ select{
margin-left: 5px; margin-left: 5px;
} }
} }

View File

@@ -1,21 +1,21 @@
export const Options = { export const ChartOptions = {
responsive: true, responsive: true,
scaleOverride: true, // scaleOverride: true,
scaleSteps: 20, //scaleSteps: 20,
scaleStartValue: 0, // scaleStartValue: 0,
scaleStepWidth: 5 //scaleStepWidth: 5
}; };
export let Data = { export let DataTemplate = {
labels: [], labels: [],
datasets: [{ datasets: [{
label: "Max Temperature °F", label: "Max Temperature °F",
fillColor: "rgba(255,100,100,0)", fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(255,100,100,1)", strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(255,100,100,1)", pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff", pointStrokeColor: "#fff",
pointHighlightFill: "#fff", pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(255,100,100,1)", pointHighlightStroke: "rgba(220,220,220,1)",
data: [] data: []
}, { }, {
label: "Min Temperature °F", label: "Min Temperature °F",