Commit adecec1c authored by Spark's avatar Spark
Browse files

3743011 default 값 두기

parent 46008734
...@@ -151,7 +151,7 @@ ul li .nav-link:active { ...@@ -151,7 +151,7 @@ ul li .nav-link:active {
} }
#chartTab { #chartTab {
width: 100%; width: 100%;
height: 70vh; height: 60vh;
display: flex; display: flex;
} }
......
...@@ -2,9 +2,29 @@ import axios from 'axios'; ...@@ -2,9 +2,29 @@ import axios from 'axios';
import { Swal } from 'sweetalert2'; import { Swal } from 'sweetalert2';
import { routesClient } from './../routesClient'; import { routesClient } from './../routesClient';
export function getTempEtc() {
callUserInfo().then((res) => {
const outs = axios.get(routesClient.outsideLoc + res['loc_code'])
return outs
.then((res) => {
const outWeather = res.data.contents.weather_out
console.log(res.data.contents.weather_out)
let i = 0;
// setTemp(res.data.contents.weather_out[0].temp)
const tempArray = []
for (i; i < 3; i++) {
console.log(i)
console.log(outWeather[i])
tempArray.push(outWeather[i].temp)
}
return tempArray
// setTemp(tempArray)
})
})
}
export async function callUserInfo() { export async function callUserInfo() {
const res = await axios.get(routesClient.userinfo) const res = await axios.get(routesClient.userinfo)
console.log(res.data.contents.user_info)
return res.data.contents.user_info return res.data.contents.user_info
} }
......
...@@ -18,7 +18,7 @@ function ChartPressure() { ...@@ -18,7 +18,7 @@ function ChartPressure() {
} }
}] }]
}, },
// maintainAspectRatio: false maintainAspectRatio: false
} }
const data = { const data = {
labels: ['1', '2', '3', '4', '5', '6', '77', '88', '99'], labels: ['1', '2', '3', '4', '5', '6', '77', '88', '99'],
...@@ -39,22 +39,7 @@ function ChartPressure() { ...@@ -39,22 +39,7 @@ function ChartPressure() {
<Col id='chartTab'> <Col id='chartTab'>
<Line <Line
data={data} data={data}
options={{ options={options}
legend: {
display: true, // label 보이기 여부
},
scales: {
yAxes: [{
display: true,
ticks: {
min: 900,
max: 1100,
stepSize: 20
}
}]
},
// maintainAspectRatio: false
}}
/> />
</Col> </Col>
) )
......
...@@ -22,6 +22,8 @@ function ChartTabs() { ...@@ -22,6 +22,8 @@ function ChartTabs() {
const [key, setKey] = useState('temp'); const [key, setKey] = useState('temp');
//3743011 default
return ( return (
<Row className='text-center w-100 my-2'> <Row className='text-center w-100 my-2'>
<Card style={cardstyled}> <Card style={cardstyled}>
......
import React from 'react' import React, { useState } from 'react'
import { Col } from 'react-bootstrap'; import { Col } from 'react-bootstrap';
import { Bar } from 'react-chartjs-2' import { Bar } from 'react-chartjs-2'
import { callUserInfo } from '../utils/CheckDB';
import { useEffect } from 'react';
import axios from 'axios';
import { routesClient } from './../routesClient';
function ChartTemp() { function ChartTemp() {
const [temp, setTemp] = useState([])
useEffect(() => {
callUserInfo().then((res) => {
const outs = axios.get(routesClient.outsideLoc + res['loc_code'])
return outs
.then((res) => {
const outWeather = res.data.contents.weather_out
console.log(res.data.contents.weather_out)
let i = 0;
// setTemp(res.data.contents.weather_out[0].temp)
const tempArray = []
for (i; i < 3; i++) {
console.log(i)
console.log(outWeather[i])
tempArray.push(outWeather[i].temp)
}
setTemp(tempArray)
})
})
}, [])
console.log(temp)
const options = { const options = {
legend: { legend: {
display: true, // label 보이기 여부 display: true, // label 보이기 여부
...@@ -12,7 +40,7 @@ function ChartTemp() { ...@@ -12,7 +40,7 @@ function ChartTemp() {
yAxes: [{ yAxes: [{
ticks: { ticks: {
min: 0, // y축 스케일에 대한 최소값 설정 min: 0, // y축 스케일에 대한 최소값 설정
stepSize: 1, // y축 그리드 한 칸당 수치 stepSize: 0.5, // y축 그리드 한 칸당 수치
} }
}] }]
}, },
...@@ -27,7 +55,7 @@ function ChartTemp() { ...@@ -27,7 +55,7 @@ function ChartTemp() {
{ {
label: '온도', label: '온도',
borderWidth: '2', borderWidth: '2',
data: [18, 22, 25, 31, 28, 25, 18, 6, -8], data: temp,
borderColor: [ borderColor: [
'rgba(75,192,192,1)', 'rgba(75,192,192,1)',
'rgba(75,192,192,1)', 'rgba(75,192,192,1)',
...@@ -54,6 +82,8 @@ function ChartTemp() { ...@@ -54,6 +82,8 @@ function ChartTemp() {
] ]
}; };
return ( return (
<Col id='chartTab'> <Col id='chartTab'>
<Bar <Bar
......
...@@ -45,7 +45,6 @@ function MainLayer() { ...@@ -45,7 +45,6 @@ function MainLayer() {
</Row> </Row>
<Row className='m-auto d-flex justify-content-center w-100'> <Row className='m-auto d-flex justify-content-center w-100'>
<TimeNow />
<UserInfo /> <UserInfo />
</Row> </Row>
...@@ -77,6 +76,7 @@ function MainLayer() { ...@@ -77,6 +76,7 @@ function MainLayer() {
} }
</ButtonGroup> </ButtonGroup>
<TimeNow />
</Row> </Row>
<Row className='m-auto justify-content-center w-100' id='contour'> <Row className='m-auto justify-content-center w-100' id='contour'>
......
...@@ -76,7 +76,7 @@ function UserInfo() { ...@@ -76,7 +76,7 @@ function UserInfo() {
}, []); }, []);
return ( return (
<Col className="text-center pb-2 px-0"> <Col className="text-center pt-2 px-0">
<Card style={cardstyled} id="localName"> <Card style={cardstyled} id="localName">
<Card.Title> <Card.Title>
<strong> <strong>
......
...@@ -4,9 +4,11 @@ export const routesClient = { ...@@ -4,9 +4,11 @@ export const routesClient = {
login: '/api/login', login: '/api/login',
edit: '/api/edit-profile', edit: '/api/edit-profile',
localdata: '/api/data/loccode', localdata: '/api/data/loccode',
outsideLoc: '/api/data/outside?loccode=',
usingAircon : '/api/toggle-aircon', usingAircon : '/api/toggle-aircon',
logout: '/api/logout', logout: '/api/logout',
userinfo : '/api/user-info' userinfo : '/api/user-info',
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment