charts - How to remove y-axis values from google chart
问题描述
I am using google charts.
In the attached image I do not want the 100, 50, 0, -50, -100 numbers to show. But I do want the Satisfaction label to show. Does anyone know how this can be achieved in google charts? Is there and option on vAxis?
Another (less important) issue is that I only want the grid lines at 100, 0 and -100. I do not want the other 6.
I currently have the following options set...
var options = {
chartArea: { width: '80%' },
colors: ['#00ff00', '#ff0000'],
vAxis: {
title: 'Satisfaction',
maxValue: 100,
minValue: -100,
gridlines: { count: 2 }
},
legend: { position: 'bottom' }
};
Thanks.
解决方案
使用以下 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>
推荐阅读
- java - java.lang.NoClassDefFoundError: java/sql/Driver
- javascript - P5.js 中的步进音序器时序错误
- javascript - 如何在 VueJS 路由器中使用道具发送此语言环境数据
- azure - 创建新版本时,如何使用 API、az devops cli 或任何其他替代方法取消版本中的阶段?
- mongodb - MongoDB 版本 3.2.17 分片集群停止平衡器
- c++ - CUDA 减少查找最大值
- dns - DHCPD DDNS 问题
- python - pytest:在捕获输出时从标准输入读取!考虑使用`-s`。建议不起作用
- php - 在查询中以逗号分隔后元字段字符串
- php - 如何在特定条件下执行 Foreach 循环和 Mysql?