NgxCharts调整数据变化

Mat*_*ton 7 typescript angular ngx-charts

我建设使用泳道的NRX个图表的图形数据表示的应用程序,但我发现了奇怪的行为,当我通过更新的刷新按钮,数据重新调用get函数来更新数据阵列.我正在使用@ angular/flex-layout作为"类似瓦片"的视图,但即使不使用它,我仍然遇到这个问题 - 它只是增长了父容器.我不想在[view]属性中使用硬编码的px值,因为我希望它可以使用任何大小的图形/磁贴.

我使用了一个非常基本的垂直条形图:

<div>
    <div>
        <ngx-charts-bar-vertical [results]="dataArray"
                                 [legend]="true"
                                 [xAxis]="true"
                                 [yAxis]="true"
                                 [xAxisLabel]="'Date'"
                                 [yAxisLabel]="'# tickets Raised'"
                                 [showXAxisLabel]="true"
                                 [showYAxisLabel]="true"></ngx-charts-bar-vertical>
    </div>
    <div>
        <!-- Got a table here -->
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

要更新我dataArray正在做的事情:

export class DashboardComponent implements AfterViewInit {
    constructor(private httpClient: HttpClient, private datePipe: DatePipe, private dataService: DataService) { }

    dataArray: any[] = [];

    getData(): void {

        this.dataService.getSomeData<any[]>().subscribe(d => {
                this.dataArray = d;
        });
    }

    // Init
    ngAfterViewInit(): void {
        this.getData();
    }
}
Run Code Online (Sandbox Code Playgroud)

在初始加载时,它很好并将填充容器(它可以在哪里)但是当我点击刷新按钮时,这是我得到的行为: 在此输入图像描述

感谢您的时间.

dri*_*u16 5

我们使用图表周围的 div 并使用 CSS 添加了 40 或 50vh 的高度来解决这个问题。

更新时图表的高度不再变化。