我正在使用谷歌图表。
在附图中,我不想显示 100、50、0、-50、-100 数字。但我确实希望显示满意度标签。有谁知道如何在谷歌图表中实现这一点? vAxis 上有选项吗?
另一个(不太重要)问题是我只想要 100、0 和 -100 处的网格线。其他 6 个我不要了。
我目前设置了以下选项...
var options = {
chartArea: { width: '80%' },
colors: ['#00ff00', '#ff0000'],
vAxis: {
title: 'Satisfaction',
maxValue: 100,
minValue: -100,
gridlines: { count: 2 }
},
legend: { position: 'bottom' }
};
谢谢。
使用以下 vAxis 选项...
textPosition: 'none'
请参阅以下工作片段...
google.charts.load('current', {
packages: ['corechart']
}).then(function () {
var data = google.visualization.arrayToDataTable([
['x', 'y0', 'y1', 'y2'],
[0, 10, 12, 18],
[2, 16, 18, 19],
[4, 18, 19, 24],
[6, 26, 28, 22],
[8, 13, 15, 21],
[10, 32, 31, 33]
]);
var options = {
chartArea: { width: '80%' },
colors: ['#00ff00', '#ff0000'],
vAxis: {
textPosition: 'none',
title: 'Satisfaction',
maxValue: 100,
minValue: -100,
gridlines: { count: 2 }
},
legend: { position: 'bottom' }
};
var chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart"></div>