-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.js
More file actions
142 lines (121 loc) · 3.95 KB
/
Copy pathApp.js
File metadata and controls
142 lines (121 loc) · 3.95 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import React, { useState } from 'react';
import DataTables from './components/DataTables';
import { SidePlane } from './components/SidePlanes'
import ChartsViz from './components/ChartsViz'
import ChartPlane from './components/ChartPlane'
import { read_csv } from 'danfojs/src/io/reader'
function App() {
const [file, setFile ] = useState()
const [dataComp, setDataComp] = useState([])
const [showSidePlane, setSidePlane] = useState(false)
const [compIndex, setCompIndex] = useState()
const [chartType, setChartType] = useState()
const [dfOpsType, setDfOpsType] = useState()
const [chartComp, setChartComp] = useState([])
const changeHandler = function(event) {
const content = event.target.files[0]
const url = URL.createObjectURL(content)
read_csv(url, {start: 0, end: 20}).then(df => {
const columns = df.columns
const values = df.values
setDataComp(prev => {
let new_data = prev.slice()
let key = new_data.length +1
let dict = {
columns: columns,
values: values,
df: df,
keys: "df" + key
}
new_data.push(dict)
return new_data
})
setFile(true);
})
}
const charts = ["BarChart", "LineChart", "PieChart"]
const dataFrameOps = ["Arithemtic","Describe", "Df2df", "Query"]
const handleChart = (e) => {
const value = e.target.innerHTML
setChartType(value)
setSidePlane("chart")
}
const handleDfops = (e) =>{
const value = e.target.value
setDfOpsType(value)
setSidePlane("datatable")
}
return (
<div className="max-w-full mx-auto border-2 mt-10">
<div className="flex flex-col">
<div className="border-2 mb-10 flex flex-row">
<input type="file" name="file" onChange={changeHandler} />
<div className="mr-4">
{
charts.map((chart, i)=>{
return <button
className="bg-blue-500 p-2 text-white rounded-sm mr-2"
onClick={handleChart}
>
{chart}
</button>
})
}
</div>
<div>
<span className="mr-2">DataFrame Operations</span>
<select className="border" onChange={handleDfops}>
<option value="None" >None</option>
{
dataFrameOps.map((dfops, i)=>{
return <option value={dfops} key={i}>{dfops}</option>
})
}
</select>
</div>
</div>
<div className="flex flex-row justify-between border-2">
<div className="border-2 w-full">
<div>
{ file &&
<DataTables
datacomp={dataComp}
setSidePlane={setSidePlane}
setCompIndex={setCompIndex}
/>
}
{ (chartComp.length > 0) &&
<ChartsViz
chartComp={chartComp}
/>
}
</div>
</div>
{showSidePlane
&&
(
showSidePlane === "datatable" ?
<div className="border-2 w-1/3">
<SidePlane
dataComp={dataComp[compIndex]}
dataComps={dataComp}
df_index={compIndex}
setDataComp={setDataComp}
dfOpsType={dfOpsType}
/>
</div> :
<div className="border-2 w-1/3">
<ChartPlane
dataComp={dataComp[compIndex]}
setChartComp={setChartComp}
chartType={chartType}
/>
</div>
)
}
</div>
</div>
</div>
)
}
export default App