2018-10-21 18:19:36 -04:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import * as $ from "jquery";
|
|
|
|
|
2021-09-01 19:01:01 -04:00
|
|
|
declare let TradingView: any;
|
2018-10-21 18:19:36 -04:00
|
|
|
|
|
|
|
@Component({
|
2021-09-01 19:29:24 -04:00
|
|
|
selector: "my-tradingview-widget-wrapper",
|
2018-10-21 18:19:36 -04:00
|
|
|
templateUrl: "tradingview.component.html",
|
|
|
|
styleUrls: ["tradingview.component.scss"],
|
|
|
|
})
|
|
|
|
export class TradingViewWidgetWrapperComponent implements OnInit {
|
|
|
|
private symbol: string;
|
|
|
|
private interval: string;
|
|
|
|
|
|
|
|
constructor(activatedRoute: ActivatedRoute) {
|
2021-09-01 19:01:01 -04:00
|
|
|
const params: any = activatedRoute.snapshot.queryParams;
|
2018-10-21 18:19:36 -04:00
|
|
|
|
|
|
|
this.symbol = params.pair;
|
|
|
|
this.interval = params.interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
$.getScript("https://s3.tradingview.com/tv.js", () => {
|
2018-10-22 02:47:42 -04:00
|
|
|
const widget = new TradingView.widget({
|
2021-09-01 19:01:01 -04:00
|
|
|
autosize: true,
|
|
|
|
symbol: this.symbol,
|
|
|
|
interval: this.interval,
|
|
|
|
timezone: "Etc/UTC",
|
|
|
|
theme: "Light",
|
|
|
|
style: "1",
|
|
|
|
locale: "en",
|
|
|
|
toolbar_bg: "#f1f3f6",
|
|
|
|
enable_publishing: false,
|
|
|
|
hide_top_toolbar: true,
|
|
|
|
hide_legend: true,
|
|
|
|
container_id: "tradingviewContainer",
|
2018-10-21 18:19:36 -04:00
|
|
|
});
|
2018-10-22 02:47:42 -04:00
|
|
|
console.log("Created widget: " + widget);
|
2018-10-21 18:19:36 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|