ChartPressure.js 1.71 KB
Newer Older
Spark's avatar
Spark committed
1
2
3
4
5
6
7
import axios from 'axios';
import React, { useEffect, useState } from 'react'
import { Col } from 'react-bootstrap';
import { Line } from 'react-chartjs-2'
import { callUserInfo } from '../utils/CheckDB';
import { isLogined } from './../utils/Auth';
import { routesClient } from './../routesClient';
Spark's avatar
chartjs    
Spark committed
8

Spark's avatar
Spark committed
9
function ChartPressure({press, newLabel}) {
Spark's avatar
Spark committed
10

Spark's avatar
chartjs    
Spark committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    const options = {
        legend: {
            display: true, // label 보이기 여부
        },
        scales: {
            yAxes: [{
                display: true,
                ticks: {
                    min: 900,
                    max: 1100,
                    stepSize: 20
                }
            }]
        },
Spark's avatar
Spark committed
25
        maintainAspectRatio: false
Spark's avatar
chartjs    
Spark committed
26
27
    }
    const data = {
Spark's avatar
Spark committed
28
        labels: newLabel,
Spark's avatar
chartjs    
Spark committed
29
30
31
        datasets: [
            {
                label: '기압',
Spark's avatar
Spark committed
32
33
                data: press,
                lineTension: 0.1,
Spark's avatar
chartjs    
Spark committed
34
35
                borderWidth: '2',
                fill: true,
Spark's avatar
Spark committed
36
37
38
39
40
41
42
43
44
45
46
47
                backgroundColor: 'rgba(75,192,192,0.1)',
                borderColor: 'rgba(75,192,192,1)',
                borderCapStyle: 'round',
                pointBorderColor: 'rgba(75,192,192,1)',
                pointBackgroundColor: '#fff',
                pointBorderWidth: 5,
                pointHoverRadius: 5,
                pointHoverBackgroundColor: 'rgba(75,192,192,1)',
                pointHoverBorderColor: 'rgba(220,220,220,1)',
                pointHoverBorderWidth: 2,
                pointRadius: 1,
                pointHitRadius: 10,
Spark's avatar
chartjs    
Spark committed
48
49
50
51
52
53
54
55
            }
        ]
    };

    return (
        <Col id='chartTab'>
            <Line
                data={data}
Spark's avatar
Spark committed
56
                options={options}
Spark's avatar
chartjs    
Spark committed
57
58
59
60
61
62
            />
        </Col>
    )
};

export default ChartPressure;