html - 不等长的柱状图(谷歌图表)
问题描述
我在 mat-grid-tile 中有一个谷歌图表。一列的值为 ,50
另一列的值为30
。这些值来自服务 myService 并且它们是正确的。当我将鼠标悬停在这些栏上时,会在工具提示上显示正确的值。但是柱高看起来不像 50 和 30。那个 30 看起来比它应该的要短。我怎样才能使它正确?
这是我尝试过的
TS 文件
ysData: any;
options = {
backgroundColor: '#fafafa',
legend: { position: 'none' },
hAxis: {
baselineColor: 'none',
ticks: []
},
vAxis: {
baselineColor: 'none',
ticks: []
},
colors: ['ffc000']
}
constructor()
{
this.ysData = [["Growth", this.myService.growth], ["Health", this.myService.health]];
}
HTML
<mat-grid-tile [colspan]="2" [rowspan]="12">
<google-chart #chart
[type]="'ColumnChart'"
[data]="ysData"
[options]="options"
[dynamicResize]="true"
[width]="200" [height]="400">
</google-chart>
</mat-grid-tile>
解决方案
对于经典,在using 选项ColumnChart
上设置范围vAxis
viewWindow
添加到您的图表选项...
vAxis: {
baselineColor: 'none',
ticks: [],
viewWindow: { // <-- add view window
min: 0
}
},
推荐阅读
- java - WkHtmlToPdf 库阿拉伯字符平方与斜体字体
- python - 持续的 python/django 错误
- python - 使用 Sticky 时无法调整 Tkinter 按钮的大小
- java - 什么是实现套接字的好方法?
- c# - 使用 WEB/API 进行 C# 依赖注入
- c - 如何使用 for 循环打印存储在变量中的多个值
- php - PHP:将小数点后的数字四舍五入到最接近的5
- swift - 在 SwiftUI 中使用 UIActivityView 分享到 Instagram
- c# - 尝试查找导致回发的控件时使用 Request.Params 返回错误的控件
- r - ggplot中日期X轴标签的精细控制