简体   繁体   English

如何使 GoogleChart 在 mat-grid 中灵活?

[英]How to make GoogleChart flexible in mat-grid?

I have google chart in the mat-grid list which I generated for element alignment on the page.But when I change the width of browser that chart isn't getting smaller as expected.There's overflow in the grid-tile and its not good.Usually all images,text etc. is being flex in the mat-grid but I didn't understand why this is not for googleChart.我在为页面上的元素 alignment 生成的 mat-grid 列表中有 google 图表。但是当我更改浏览器的宽度时,该图表并没有像预期的那样变小。grid-tile 中有溢出并且它不好。通常所有图像、文本等都在 mat-grid 中灵活调整,但我不明白为什么这不适用于 googleChart。

Demo: https://stackblitz.com/edit/angular-pt2kha?file=app/grid-list-overview-example.html演示: https://stackblitz.com/edit/angular-pt2kha?file=app/grid-list-overview-example.html

You can see the behavior here:您可以在此处查看行为:

在此处输入图像描述

You have to use percentages to set the size of the chart together with the dynamicResize atrribute.您必须使用百分比来设置图表的大小以及 dynamicResize 属性。 Set the height and width as a style with percentage and enable dynamicResizing.将高度和宽度设置为带有百分比的样式并启用动态调整大小。

Example:例子:

 <google-chart #chart  
          style="border-style:solid;border-width:1px;width:90%;height:90%" 
          [title]="title"
          [type]="type"
          [data]="data"
          [columnNames]="columnNames"
          [options]="options"
          [dynamicResize]="true"              
          >

See the StackblitzStackblitz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM