From 39e6ff24677162da002400a4810c55eaf110e3d0 Mon Sep 17 00:00:00 2001 From: shrishti-gli Date: Sun, 15 Sep 2024 00:37:40 +0530 Subject: [PATCH] Update Graph.tsx --- src/Graph.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Graph.tsx b/src/Graph.tsx index 3b2a7da1a38..e31dc081a6f 100644 --- a/src/Graph.tsx +++ b/src/Graph.tsx @@ -14,7 +14,7 @@ interface IProps { * Perspective library adds load to HTMLElement prototype. * This interface acts as a wrapper for Typescript compiler. */ -interface PerspectiveViewerElement { +interface PerspectiveViewerElement extends HTMLElement { load: (table: Table) => void, } @@ -32,7 +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 unknown as PerspectiveViewerElement; const schema = { stock: 'string', @@ -49,6 +49,15 @@ class Graph extends Component { // Add more Perspective configurations here. elem.load(this.table); + elem.setAttribute('view','y_line'); + elem.setAttribute('column-pivotes','["stock"]'); + elem.setAttribute('row-pivotes','["timestamp"]'); + elem.setAttribute('aggregates', + {"stock":"distint count", + "top_ask_price":"avg", + "top_bid_price":"avg", + "timestamp":"distinct count" + } } }