From a356c53fee0690eae281c19d2b527817c2271b21 Mon Sep 17 00:00:00 2001 From: Sourabh songara <127713864+SourabhSongara@users.noreply.github.com> Date: Tue, 3 Sep 2024 08:36:00 +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..bf97a518962 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('columns','["top_ask_price"]'); + elem.setAttribute('aggregates',` + {"stock":"distinct count", + "top_ask_prices":"avg", + "top_bid_price":"avg", + "timestamp":"distinct count"}`); } }