ChartHumidity.js 2.18 KB
Newer Older
Spark's avatar
layout    
Spark committed
1
import React from 'react'
Spark's avatar
chartjs    
Spark committed
2
3
4
5
import { Col } from 'react-bootstrap';
import { Bar, Line } from 'react-chartjs-2'

function ChartHumidity() {
Spark's avatar
layout    
Spark committed
6

7
    const cardstyled = {
Spark's avatar
layout    
Spark committed
8
9
10
11
12
        margin: 'auto',
        padding: '1em',
        display: 'flex',
        justifyContent: 'center',
        width: '100%',
13
        borderWidth: '3px',
14
        borderRadius: '20px',
15
16
        borderColor: 'rgb(110, 189, 142)',
        color: '#04AB70'
Spark's avatar
layout    
Spark committed
17
    }
Spark's avatar
Spark committed
18

Spark's avatar
layout    
Spark committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    const options = {
        legend: {
            display: true, // label 보이기 여부
        },
        scales: {
            yAxes: [{
                ticks: {
                    min: 0, // y축 스케일에 대한 최소값 설정
                    stepSize: 1, // y축 그리드 한 칸당 수치
                }
            }]
        },

        // false : 사용자 정의 크기에 따라 그래프 크기가 결정됨.
        // true : 크기가 알아서 결정됨.
        maintainAspectRatio: false
    }
    const data = {
        labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        datasets: [
39
            {
Spark's avatar
chartjs    
Spark committed
40
41
                label: '습도',
                fill: true,
42
43
44
45
                lineTension: 0.1,
                backgroundColor: 'rgba(75,192,192,0.4)',
                borderColor: 'rgba(75,192,192,1)',
                borderCapStyle: 'butt',
Spark's avatar
chartjs    
Spark committed
46
                borderDash: [8, 8], //점선 ex [2,10]
47
48
49
50
                borderDashOffset: 0.0,
                borderJoinStyle: 'miter',
                pointBorderColor: 'rgba(75,192,192,1)',
                pointBackgroundColor: '#fff',
Spark's avatar
chartjs    
Spark committed
51
                pointBorderWidth: 6,
52
53
54
55
56
57
58
59
                pointHoverRadius: 5,
                pointHoverBackgroundColor: 'rgba(75,192,192,1)',
                pointHoverBorderColor: 'rgba(220,220,220,1)',
                pointHoverBorderWidth: 2,
                pointRadius: 1,
                pointHitRadius: 10,
                data: [-10, -2, 13, 18, 22, 25, 31, 28, 25, 18, 6, -8]
            }
Spark's avatar
layout    
Spark committed
60
        ]
61
    };
Spark's avatar
layout    
Spark committed
62
63

    return (
Spark's avatar
chartjs    
Spark committed
64
65
66
67
68
69
        <Col id='chartTab'>
            <Line
                data={data}
                options={options}
            />
        </Col>
Spark's avatar
layout    
Spark committed
70
    )
Spark's avatar
chartjs    
Spark committed
71
};
Spark's avatar
layout    
Spark committed
72

Spark's avatar
chartjs    
Spark committed
73
export default ChartHumidity;