diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index d263db3ad..729a650f7 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -37,6 +37,7 @@ import { IncomingTransactionsGraphComponent } from './components/incoming-transa import { TimeSpanComponent } from './components/time-span/time-span.component'; import { SeoService } from './services/seo.service'; import { MempoolGraphComponent } from './components/mempool-graph/mempool-graph.component'; +import { LbtcPegsGraphComponent } from './components/lbtc-pegs-graph/lbtc-pegs-graph.component'; import { AssetComponent } from './components/asset/asset.component'; import { AssetsComponent } from './assets/assets.component'; import { StatusViewComponent } from './components/status-view/status-view.component'; @@ -84,6 +85,7 @@ import { SponsorComponent } from './components/sponsor/sponsor.component'; FeeDistributionGraphComponent, IncomingTransactionsGraphComponent, MempoolGraphComponent, + LbtcPegsGraphComponent, AssetComponent, AssetsComponent, MinerComponent, diff --git a/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.html b/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.html new file mode 100644 index 000000000..6b5017785 --- /dev/null +++ b/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.html @@ -0,0 +1 @@ +
diff --git a/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts b/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts new file mode 100644 index 000000000..ca93be029 --- /dev/null +++ b/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts @@ -0,0 +1,137 @@ +import { Component, OnInit, Inject, LOCALE_ID, ChangeDetectionStrategy, Output, EventEmitter, Input, OnChanges } from '@angular/core'; +import { formatDate, formatNumber } from '@angular/common'; +import { EChartsOption } from 'echarts'; +import { ApiService } from 'src/app/services/api.service'; +import { map } from 'rxjs/operators'; +import { Observable } from 'rxjs'; + +@Component({ + selector: 'app-lbtc-pegs-graph', + templateUrl: './lbtc-pegs-graph.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class LbtcPegsGraphComponent implements OnChanges { + @Input() data: any; + pegsChartOptions: EChartsOption; + + height: number | string = '200'; + right: number | string = '10'; + top: number | string = '20'; + left: number | string = '50'; + template: ('widget' | 'advanced') = 'widget'; + + pegsChartOption: EChartsOption = {}; + pegsChartInitOption = { + renderer: 'svg' + }; + + constructor( + @Inject(LOCALE_ID) private locale: string, + ) { } + + ngOnChanges() { + this.pegsChartOptions = this.createChartOptions(this.data.series, this.data.labels); + } + + createChartOptions(series: number[], labels: string[]): EChartsOption { + return { + grid: { + height: this.height, + right: this.right, + top: this.top, + left: this.left, + }, + animation: false, + dataZoom: [{ + type: 'inside', + realtime: true, + zoomOnMouseWheel: (this.template === 'advanced') ? true : false, + maxSpan: 100, + minSpan: 10, + }, { + show: (this.template === 'advanced') ? true : false, + type: 'slider', + brushSelect: false, + realtime: true, + selectedDataBackground: { + lineStyle: { + color: '#fff', + opacity: 0.45, + }, + areaStyle: { + opacity: 0, + } + } + }], + tooltip: { + trigger: 'axis', + position: (pos, params, el, elRect, size) => { + const obj = { top: -20 }; + obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 80; + return obj; + }, + extraCssText: `width: ${(this.template === 'widget') ? '125px' : '135px'}; + background: transparent; + border: none; + box-shadow: none;`, + axisPointer: { + type: 'line', + }, + formatter: (params: any) => { + const colorSpan = (color: string) => ``; + let itemFormatted = '{{ liquidPegsMonth.series.slice(-1)[0] | number: '1.2-2' }} L-BTC
+