andrea.nieves7 1 year ago
parent
commit
56ef9c7345
4 changed files with 2505 additions and 103 deletions
  1. 70
    88
      App.js
  2. 1754
    2
      package-lock.json
  3. 1
    0
      package.json
  4. 680
    13
      yarn.lock

+ 70
- 88
App.js View File

1
 import { StatusBar } from 'expo-status-bar';
1
 import { StatusBar } from 'expo-status-bar';
2
 import React, {useState, useEffect} from 'react';
2
 import React, {useState, useEffect} from 'react';
3
 import { View, Image, StyleSheet, Text, Button, ScrollView, Pressable} from 'react-native';
3
 import { View, Image, StyleSheet, Text, Button, ScrollView, Pressable} from 'react-native';
4
-import data from './transfer.json' 
5
 import DropDownPicker from 'react-native-dropdown-picker';
4
 import DropDownPicker from 'react-native-dropdown-picker';
5
+//import JSON;
6
+//import { Dataframe, readJSON } from "danfojs";
6
 
7
 
7
 //where data will be put
8
 //where data will be put
8
 var organizedData
9
 var organizedData
11
 var information = "data goes here"
12
 var information = "data goes here"
12
 
13
 
13
 //organize data make it pretty
14
 //organize data make it pretty
15
+
16
+//add loading thing while this organizes all the data !!!
17
+
14
 function organize(){
18
 function organize(){
15
 	
19
 	
20
+	var stringDiv = JSON.stringify(information)
21
+	stringDiv = stringDiv.replace('[[', '');
22
+	stringDiv = stringDiv.replace(']]', '');
23
+	stringDiv = stringDiv.split(',')
24
+	//create smaller array variables
25
+	let variables = []
26
+	let value = []
27
+	let est = []
28
+	
29
+	
30
+	//theres a better way to do this but im not fixing it rn
31
+	for(let i = 0; i<stringDiv.length; i++){
32
+		if(i<stringDiv.length/3)
33
+		{variables.push(stringDiv[i])}
34
+		else if(i<stringDiv.length/3*2)
35
+		{value.push(stringDiv[i])}
36
+		else{est.push(stringDiv[i])}
37
+	}
16
 	
38
 	
39
+	//anyways this to format it
17
 	
40
 	
41
+	console.log("vars:",variables)
42
+	console.log("val:",value)
43
+	console.log("est:",est)
44
+	//organizedData = JSON.parse(information)
45
+	//console.log(stringDiv)
18
 	
46
 	
19
 }
47
 }
20
 
48
 
44
   xhttp.onreadystatechange = function() {
72
   xhttp.onreadystatechange = function() {
45
     if (this.readyState == 4 && this.status == 200) {
73
     if (this.readyState == 4 && this.status == 200) {
46
          information = this.responseText;
74
          information = this.responseText;
47
-		 //organize()
75
+		 organize()
48
   }
76
   }
49
   };
77
   };
50
   xhttp.open("GET", query, true);
78
   xhttp.open("GET", query, true);
63
 	
91
 	
64
 	var query = queryBase + "(" + table + ")&for=county:" + pueblo + queryEnd 
92
 	var query = queryBase + "(" + table + ")&for=county:" + pueblo + queryEnd 
65
 	
93
 	
66
-	console.log(query)
67
-	
68
-	loadDoc(query)
94
+	if(pueblo && table)
95
+	{loadDoc(query)}
96
+	else
97
+	{Alert.alert("Please fill every parameter before calling!")}
69
 	
98
 	
70
 }
99
 }
71
 
100
 
154
 
183
 
155
 
184
 
156
 //data parsing goes here
185
 //data parsing goes here
157
-
158
-function importJSON() {
159
-	var stuff = JSON.stringify(data)
160
-	return stuff
186
+function getInfo(){
187
+	//console.log(information[6])
188
+	return information
161
 }
189
 }
162
 
190
 
163
-
164
 //data display
191
 //data display
165
 
192
 
166
-function DataDisplay({valueTable, valuePueblo}) {
167
-  const [tableValue, setTableValue] = useState(null);
168
-  const [puebloValue, setPuebloValue] = useState(null);
169
-  
170
-  console.log("tableOption:",valueTable)
171
-  console.log("puebloOption:",valuePueblo)
193
+class DataButton extends React.Component{
172
 	
194
 	
173
-//theres something wrong with this, its applying the previous value of valueTable and valuePueblo instead of the actual value
174
-
175
-  useEffect(() => {
176
-    setTableValue(valueTable);
177
-	console.log("tableValue:",tableValue)
178
-	//if not undefined
179
-	if(tableValue){updateTable(tableValue);}   
180
-  }, [valueTable]); // add props as dependencies
181
-  
182
-  useEffect(() => {
183
-    setPuebloValue(valuePueblo);
184
-	console.log("puebloValue:",puebloValue)
185
-    if(puebloValue){updatePueblo(puebloValue)};
186
-  }, [valuePueblo]); // add props as dependencies
195
+	state = {
196
+		click: false
197
+	}
187
 	
198
 	
188
-
189
-  return (
190
-  <View>
191
-    <Text style={styles.sub}>{information}</Text>
192
-	<Button
193
-		onPress = {fetchData()}
194
-		title = "Fetch Data"
195
-		color = "black"
196
-		/>
197
-   </View>	  
198
-  );
199
-}
200
-
201
-//data pick
202
-/*
203
-function Parent() {
204
-  const [parentOption, setParentOption] = useState(0);
205
-
206
-  return (
207
-    <View>
208
-		<Pressable onPress = {() => setParentOption(current => 1)}>
209
-			<Text style = {styles.listItem}> DP02PR </Text>
210
-		</Pressable>
211
-			
212
-		<Pressable onPress = {() => setParentOption(current => 2)}>
213
-			<Text style = {styles.listItem}> DP03PR </Text>
214
-		</Pressable>
215
-			
216
-		<Pressable onPress = {() => setParentOption(current => 3)}>
217
-			<Text style = {styles.listItem}> DP04PR </Text>
218
-		</Pressable>
219
-			
220
-		<Pressable onPress = {() => setParentOption(current => 4)}>
221
-			<Text style = {styles.listItem}> DP05PR </Text>
222
-		</Pressable>
223
-
224
-		<DataDisplay parentOption={parentOption} />
225
-    </View>
226
-  );
199
+	pullData = () => {fetchData(); this.setState({click: true})}
200
+	
201
+	
202
+	render() {
203
+		return(
204
+		<View>
205
+			<Button
206
+			onPress = {this.pullData}
207
+			title = "Fetch Data"
208
+			color = "black"
209
+			/>
210
+			<Text style={styles.sub}>{getInfo()}</Text> 
211
+		</View>
212
+	);}	
227
 }
213
 }
228
-*/
229
 
214
 
230
 
215
 
231
 //picker test
216
 //picker test
236
   
221
   
237
   
222
   
238
   const [openTable, setOpenTable] = useState(false);
223
   const [openTable, setOpenTable] = useState(false);
239
-  //const [tableOption, setTableOption] = useState(0);
240
   const [valueTable, setValueTable] = useState(null);
224
   const [valueTable, setValueTable] = useState(null);
241
   const [table, setTable] = useState([
225
   const [table, setTable] = useState([
242
     {label:'DP02PR', value: 'DP02PR'},
226
     {label:'DP02PR', value: 'DP02PR'},
250
   
234
   
251
   //pueblo
235
   //pueblo
252
   const [openPueblo, setOpenPueblo] = useState(false);
236
   const [openPueblo, setOpenPueblo] = useState(false);
253
-  //const [puebloOption, setPuebloOption] = useState(0);
254
   const [valuePueblo, setValuePueblo] = useState(null);
237
   const [valuePueblo, setValuePueblo] = useState(null);
255
   const [pueblo, setPueblo] = useState([
238
   const [pueblo, setPueblo] = useState([
256
     {label: 'Adjuntas', value: '001'},
239
     {label: 'Adjuntas', value: '001'},
333
 	{label: 'Yauco', value: '153'}
316
 	{label: 'Yauco', value: '153'}
334
   ]);
317
   ]);
335
   
318
   
336
-  
337
-  //make sure pickers are closed when another opens
338
-  
339
 
319
 
340
   return (
320
   return (
341
   <View>
321
   <View>
346
       setOpen={setOpenTable}
326
       setOpen={setOpenTable}
347
       setValue={setValueTable}
327
       setValue={setValueTable}
348
       setItems={setTable}
328
       setItems={setTable}
349
-	  //onChangeValue={(valueTable) => {
350
-	//	setTableOption(current => valueTable);
351
-	//	}}
329
+	  onChangeValue = {(valueTable) => {
330
+		updateTable(valueTable);
331
+		}}
352
 	  onOpen = {() => {setOpenPueblo(false)}}
332
 	  onOpen = {() => {setOpenPueblo(false)}}
353
 	  zIndex={3000}
333
 	  zIndex={3000}
354
 	  zIndexInverse={1000}
334
 	  zIndexInverse={1000}
363
       setOpen={setOpenPueblo}
343
       setOpen={setOpenPueblo}
364
       setValue={setValuePueblo}
344
       setValue={setValuePueblo}
365
       setItems={setPueblo}
345
       setItems={setPueblo}
366
-	  //onChangeValue={(valuePueblo) => {
367
-	//	setPuebloOption(current => valuePueblo);
368
-	//	}}
346
+	  onChangeValue = {(valuePueblo) => {
347
+		updatePueblo(valuePueblo);
348
+		}}
369
 	  onOpen = {() => {setOpenTable(false)}}
349
 	  onOpen = {() => {setOpenTable(false)}}
370
 	  zIndex={1000}
350
 	  zIndex={1000}
371
       zIndexInverse={3000}
351
       zIndexInverse={3000}
373
 	  searchPlaceholder="Busqueda..."
353
 	  searchPlaceholder="Busqueda..."
374
     />
354
     />
375
 	
355
 	
376
-	<DataDisplay valueTable={valueTable} valuePueblo={valuePueblo} />
377
-	
378
 	</View>
356
 	</View>
379
   );
357
   );
380
 }
358
 }
385
 
363
 
386
 class App extends React.Component {
364
 class App extends React.Component {
387
 
365
 
388
-
366
+//the text at the end of a page gets cut off if anyone knows how to fix that?
389
 vars = {
367
 vars = {
390
 		welcome:
368
 		welcome:
391
 		  
369
 		  
428
 		 <View style = {styles.container}>
406
 		 <View style = {styles.container}>
429
 			
407
 			
430
 		  
408
 		  
431
-			<Text style={styles.intro}>DATA VIEWING</Text>		
432
-			
409
+			<Text style={styles.intro}>DATA VIEWING PROJECT</Text>		
410
+				
433
 			<Picker />
411
 			<Picker />
434
 			
412
 			
435
 			<Image source={require('./testimg.gif')} />
413
 			<Image source={require('./testimg.gif')} />
414
+				
415
+			<DataButton />
416
+			
417
+			<Text style={styles.sub}>blehhhhhh bleh bleh bleh bleh bleh blehhhhhhhhhhhhhhhhh </Text>
436
 			
418
 			
437
 		 </View>
419
 		 </View>
438
 		</ScrollView></View>
420
 		</ScrollView></View>
469
 			 		 			<Button
451
 			 		 			<Button
470
 								onPress = {this.setNews}
452
 								onPress = {this.setNews}
471
 				 				title = "Noticias"
453
 				 				title = "Noticias"
472
-				 				color = "white"
454
+				 				color = "rgba(255, 0, 0, 0)"
473
 			  					/>
455
 			  					/>
474
 			  
456
 			  
475
 			  					<Button
457
 			  					<Button
476
 								 onPress = {this.setData}
458
 								 onPress = {this.setData}
477
 								 title = "Datos"
459
 								 title = "Datos"
478
-								 color = "white"
460
+								 color = "rgba(255, 0, 0, 0)"
479
 			  					/>
461
 			  					/>
480
 							</View>
462
 							</View>
481
 						
463
 						

+ 1754
- 2
package-lock.json
File diff suppressed because it is too large
View File


+ 1
- 0
package.json View File

11
   "dependencies": {
11
   "dependencies": {
12
     "@expo/webpack-config": "^0.17.2",
12
     "@expo/webpack-config": "^0.17.2",
13
     "@react-native-picker/picker": "^2.4.8",
13
     "@react-native-picker/picker": "^2.4.8",
14
+    "danfojs": "^1.1.2",
14
     "expo": "^47.0.6",
15
     "expo": "^47.0.6",
15
     "expo-font": "~11.0.1",
16
     "expo-font": "~11.0.1",
16
     "expo-splash-screen": "~0.17.5",
17
     "expo-splash-screen": "~0.17.5",

+ 680
- 13
yarn.lock
File diff suppressed because it is too large
View File