Merge pull request #2009 from mempool/simon/bisq-graphs-resize
Auto resize graphs on window resize
This commit is contained in:
		
						commit
						8c45da7ac6
					
				@ -1,5 +1,5 @@
 | 
			
		||||
import { createChart, CrosshairMode, isBusinessDay } from 'lightweight-charts';
 | 
			
		||||
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
 | 
			
		||||
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-lightweight-charts-area',
 | 
			
		||||
@ -25,6 +25,15 @@ export class LightweightChartsAreaComponent implements OnInit, OnChanges, OnDest
 | 
			
		||||
    private element: ElementRef,
 | 
			
		||||
  ) { }
 | 
			
		||||
 | 
			
		||||
  @HostListener('window:resize', ['$event'])
 | 
			
		||||
  resizeCanvas(): void {
 | 
			
		||||
    this.width = this.element.nativeElement.parentElement.offsetWidth;
 | 
			
		||||
    this.chart.applyOptions({
 | 
			
		||||
      width: this.width,
 | 
			
		||||
      height: this.height,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
    this.width = this.element.nativeElement.parentElement.offsetWidth;
 | 
			
		||||
    this.container = document.createElement('div');
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { createChart, CrosshairMode } from 'lightweight-charts';
 | 
			
		||||
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
 | 
			
		||||
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-lightweight-charts',
 | 
			
		||||
@ -21,6 +21,14 @@ export class LightweightChartsComponent implements OnInit, OnChanges, OnDestroy
 | 
			
		||||
    private element: ElementRef,
 | 
			
		||||
  ) { }
 | 
			
		||||
 | 
			
		||||
  @HostListener('window:resize', ['$event'])
 | 
			
		||||
  resizeCanvas(): void {
 | 
			
		||||
    this.chart.applyOptions({
 | 
			
		||||
      width: this.element.nativeElement.parentElement.offsetWidth,
 | 
			
		||||
      height: this.height,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
    this.chart = createChart(this.element.nativeElement, {
 | 
			
		||||
      width: this.element.nativeElement.parentElement.offsetWidth,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user