Analy.js 2.72 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, { useState, useEffect } from 'react';
import { View, Text, StyleSheet, Dimensions } from 'react-native';
import {
  LineChart,
  BarChart,
  PieChart,
  ProgressChart,
  ContributionGraph,
  StackedBarChart
} from "react-native-chart-kit";
const screenWidth = Dimensions.get("window").width;
const screenHeight = Dimensions.get("window").height;
const data1 = [
  {
    name: "Seoul",
    population: 21500000,
    color: "rgba(131, 167, 234, 1)",
    legendFontColor: "#7F7F7F",
    legendFontSize: 15
  },
  {
    name: "Toronto",
    population: 2800000,
    color: "#d8bfd8",
    legendFontColor: "#7F7F7F",
    legendFontSize: 15
  },
  {
    name: "Beijing",
    population: 1276120,
    color: "#87ceeb",
    legendFontColor: "#7F7F7F",
    legendFontSize: 15
  },
  {
    name: "New York",
    population: 8538000,
    color: "#fff5ee",
    legendFontColor: "#7F7F7F",
    legendFontSize: 15
  },
  {
    name: "Moscow",
    population: 11920000,
    color: "#b0c4de",
    legendFontColor: "#7F7F7F",
    legendFontSize: 15
  }
];
const data2 = {
  labels: ["Jan", "Feb", "Mar", "April", "May", "June"],
  datasets: [
    {
      data: [20, 45, 28, 80, 99, 43]
    }
  ]
};

const Analy = () => {
  const chartConfig = {
    backgroundGradientFrom: "#abbcd6", //좌측 색
    backgroundGradientFromOpacity: 0.5, 
    backgroundGradientTo: "#E6DDC5", // 우측 색
    backgroundGradientToOpacity: 0.2,
    backgroundColor: "#ffffff", // 어디에 적용된건지 잘 모르겠음
    color: (opacity = 1) => `rgba(0, 93, 232, ${opacity})`, // data의 색상 계산할 때 사용하는 함수
    //color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
    strokeWidth: 2, // optional, default 3
    barPercentage: 0.5, // 그래프 width
    useShadowColorFromDataset: false,// optional, default is false
    //fillShadowGradient: 'blue',
    fillShadowGradientOpacity: 1, // 좀 더 진하게만 할 뿐 단색 설정은 못하는 것 같음
Choi Ga Young's avatar
Choi Ga Young committed
73

Choi Ga Young's avatar
Choi Ga Young committed
74
75
76
  };
  const [state, SetState] = useState([]);
  return (
Choi Ga Young's avatar
Choi Ga Young committed
77
    <View>
Choi Ga Young's avatar
Choi Ga Young committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      <Text style={style.Font}>여기는 분석 페이지/ 차트 테스트</Text>
      <PieChart
        data={data1}
        width={screenWidth}
        height={screenHeight / 3} //그래프의 높이가 커지기만
        chartConfig={chartConfig}
        accessor={"population"}
        backgroundColor={"#ffffff"}
        // paddingLeft={"15"}
        // center={[10, 50]}
        absolute
      />
      <BarChart 
        //style={graphStyle}
        data={data2}
        width={screenWidth}
        height={screenHeight / 3}
        //yAxisLabel="$"
        chartConfig={chartConfig}
      //verticalLabelRotation={30}
      />
Choi Ga Young's avatar
Choi Ga Young committed
99
100
101
102
103
    </View>
  )
}
const style = StyleSheet.create({
  Font: {
Choi Ga Young's avatar
Choi Ga Young committed
104
    fontSize: 24
Choi Ga Young's avatar
Choi Ga Young committed
105
106
107
108
  }
});

export default Analy;