From f6c7839524c7b19ae7536b649b79441fd4559dd3 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Thu, 23 Feb 2023 10:46:18 +0900 Subject: [PATCH] Show historical price on transaction bowtie chart --- .../tx-bowtie-graph-tooltip.component.html | 2 +- .../tx-bowtie-graph-tooltip.component.ts | 17 ++++++++++++++--- .../tx-bowtie-graph.component.ts | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.html b/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.html index 25e9ccc1f..395c38f88 100644 --- a/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.html +++ b/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.html @@ -56,7 +56,7 @@

Confidential

-

+

diff --git a/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.ts b/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.ts index 54c58ffab..a27885c1e 100644 --- a/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.ts +++ b/frontend/src/app/components/tx-bowtie-graph-tooltip/tx-bowtie-graph-tooltip.component.ts @@ -1,5 +1,6 @@ -import { Component, ElementRef, ViewChild, Input, OnChanges, ChangeDetectionStrategy } from '@angular/core'; -import { TransactionStripped } from '../../interfaces/websocket.interface'; +import { Component, ElementRef, ViewChild, Input, OnChanges, OnInit } from '@angular/core'; +import { tap } from 'rxjs'; +import { Price, PriceService } from 'src/app/services/price.service'; interface Xput { type: 'input' | 'output' | 'fee'; @@ -14,6 +15,7 @@ interface Xput { pegin?: boolean; pegout?: string; confidential?: boolean; + timestamp?: number; } @Component({ @@ -27,12 +29,21 @@ export class TxBowtieGraphTooltipComponent implements OnChanges { @Input() isConnector: boolean = false; tooltipPosition = { x: 0, y: 0 }; + blockConversion: Price; @ViewChild('tooltip') tooltipElement: ElementRef; - constructor() {} + constructor(private priceService: PriceService) {} ngOnChanges(changes): void { + if (changes.line?.currentValue) { + this.priceService.getBlockPrice$(changes.line?.currentValue.timestamp).pipe( + tap((price) => { + this.blockConversion = price; + }) + ).subscribe(); + } + if (changes.cursorPosition && changes.cursorPosition.currentValue) { let x = Math.max(10, changes.cursorPosition.currentValue.x - 50); let y = changes.cursorPosition.currentValue.y + 20; diff --git a/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts b/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts index 49d97dd40..6be475243 100644 --- a/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts +++ b/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts @@ -29,6 +29,7 @@ interface Xput { pegin?: boolean; pegout?: string; confidential?: boolean; + timestamp?: number; } @Component({ @@ -152,6 +153,7 @@ export class TxBowtieGraphComponent implements OnInit, OnChanges { index: i, pegout: v?.pegout?.scriptpubkey_address, confidential: (this.isLiquid && v?.value === undefined), + timestamp: this.tx.status.block_time } as Xput; }); @@ -171,6 +173,7 @@ export class TxBowtieGraphComponent implements OnInit, OnChanges { coinbase: v?.is_coinbase, pegin: v?.is_pegin, confidential: (this.isLiquid && v?.prevout?.value === undefined), + timestamp: this.tx.status.block_time } as Xput; });