gpt4 book ai didi

javascript - 在 hAxis google 图表栏中显示所有标签

转载 作者:行者123 更新时间:2023-11-30 14:49:26 25 4
gpt4 key购买 nike

我正在学习如何使用 Google Charts API,更具体地说 Material cloumn charts .我想在 hAxis 中显示所有标签,例如 (1,2,3,4,5 [...]),但我的图表以 (5,10,15, [...]) 格式显示它们。我试过this question的建议, 但没有成功。

这是我当前的图表:this

这是我的代码:

desenharGrafico(data: Array<any>) {

var rows: Array<any> = [];

for (var item of data) {
var rua = item.rua;
var valor = item.valor;
var valorCortado = item.valorCortado;
var objeto = { c: [{ v: rua }, { v: valor }, { v: valorCortado }] };
rows.push(objeto);
}

var chartData = new google.visualization.DataTable({
cols: [
{ id: '', label: 'Rua', type: 'number' },
{ id: '', label: 'Faturado', type: 'number' },
{ id: '', label: 'Corte', type: 'number' }
],
rows: rows
});

var options =
{
title: "Período: " + this.data1 + ' á ' + this.data2,
hAxis: { slantedText: true, showTextEvery: 1 },
legend: "none",

};
var chart = new google.charts.Bar(document.getElementById('cortes-rua'));
chart.draw(chartData, google.charts.Bar.convertOptions(options));
}

最佳答案

Material 图表根本不支持许多选项,
包括 slantedText & showTextEvery
见 --> Tracking Issue for Material Chart Feature Parity

另一种解决方案是对 x 轴使用 'string'

这将导致离散轴,而不是连续

如果有足够的空间,离散轴将显示所有标签...

关于javascript - 在 hAxis google 图表栏中显示所有标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48404332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com