diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000000..26d33521af1
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/jpmc-task-2.iml b/.idea/jpmc-task-2.iml
new file mode 100644
index 00000000000..d6ebd480598
--- /dev/null
+++ b/.idea/jpmc-task-2.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000000..639900d13c6
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000000..c9be9638e35
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000000..35eb1ddfbbc
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 0728518c0d8..4d2897e3230 100755
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,6 +8,7 @@ import './App.css';
*/
interface IState {
data: ServerRespond[],
+ showGraph: boolean,
}
/**
@@ -22,6 +23,7 @@ class App extends Component<{}, IState> {
// data saves the server responds.
// We use this state to parse data down to the child element (Graph) as element property
data: [],
+ showGraph:false,
};
}
@@ -29,18 +31,29 @@ class App extends Component<{}, IState> {
* Render Graph react component with state.data parse as property data
*/
renderGraph() {
- return ()
+ if(this.state.showGraph) {
+ return ()
+ }
}
/**
* Get new data from server and update the state with the new data
*/
getDataFromServer() {
- DataStreamer.getData((serverResponds: ServerRespond[]) => {
- // Update the state by creating a new array of data that consists of
- // Previous data in the state and the new data from server
- this.setState({ data: [...this.state.data, ...serverResponds] });
- });
+ let x=0;
+ const interval = setInterval(() => {
+ DataStreamer.getData((serverResponds: ServerRespond[]) => {
+ this.setState({
+ data: serverResponds,
+ showGraph: true,
+ });
+ });
+ x++;
+ if (x > 1000){
+ clearInterval(interval);
+ }
+ },100);
+
}
/**
diff --git a/src/Graph.tsx b/src/Graph.tsx
index 3b2a7da1a38..fc8a7e53627 100644
--- a/src/Graph.tsx
+++ b/src/Graph.tsx
@@ -13,8 +13,9 @@ interface IProps {
/**
* Perspective library adds load to HTMLElement prototype.
* This interface acts as a wrapper for Typescript compiler.
+ * extending HTMLELEMENT class as to make graph a html elemnt
*/
-interface PerspectiveViewerElement {
+interface PerspectiveViewerElement extends HTMLElement {
load: (table: Table) => void,
}
@@ -31,8 +32,7 @@ class Graph extends Component {
}
componentDidMount() {
- // Get element to attach the table from the DOM.
- const elem: PerspectiveViewerElement = document.getElementsByTagName('perspective-viewer')[0] as unknown as PerspectiveViewerElement;
+ const elem = document.getElementsByTagName('perspective-viewer')[0] as PerspectiveViewerElement;
const schema = {
stock: 'string',
@@ -49,6 +49,11 @@ class Graph extends Component {
// Add more Perspective configurations here.
elem.load(this.table);
+ elem.setAttribute('view', 'y_line');
+ elem.setAttribute('column-pivots', '["stock"]');
+ elem.setAttribute('row-pivots', '["timestamp"]');
+ elem.setAttribute('columns','["top_ask_price"]');
+ elem.setAttribute('aggregates',' {"stock":"distinct count","top_ask_price":"avg","timestamp":"distinct count"}');
}
}