import { Component, AfterViewInit } from '@angular/core';
declare const tableau: any;
@Component({ selector: 'app-tableau', template: '
', }) export class TableauComponent implements AfterViewInit {constructor() { }
ngAfterViewInit() {
const vizUrl = 'https://YOUR_TABLEAU_URL';
const vizDiv = document.getElementById('tableauViz');
const options = {
hideToolbar: true,
width: '100%',
height: '500px'
};
const viz = new tableau.Viz(vizDiv, vizUrl, options);
}
}
将YOUR_TABLEAU_URL替换为你自己的Tableau URL。
这将在页面加载时自动初始化Tableau仪表板,并且在页面刷新时仍然能够正确地渲染。