在 Google 图表中的条形上方显示标题
我有一个简单的谷歌柱形图,其中包含一系列数据。我需要在每个栏上方显示标题,因为工具提示还不够。 但没有标准选项可以做到这一点。你看到这个了吗?
google.load('visualization', '1', {packages: ['corechart']});
$(document).ready(function() {
var data = new google.visualization.DataTable()
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
new google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data, {width: 500, height: 440, legend: 'none',
enableInteractivity: false});
});
您也可以在 jsfiddle 中使用此代码
I have simple Google Column Chart with one series of data. And i need to show captions above each bar, because tooltip not enough.
But there are no standart options to do it. You seen this?
google.load('visualization', '1', {packages: ['corechart']});
$(document).ready(function() {
var data = new google.visualization.DataTable()
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
new google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data, {width: 500, height: 440, legend: 'none',
enableInteractivity: false});
});
also you can play with this code at jsfiddle
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案与所问的内容差不多。下面的代码演示了如何创建每个条形具有不同颜色并在每个条形上方具有不同标签的条形图。
将其粘贴到 Google Playground 中并自行检查。
This answer is little more than what been asked. The code below demonstrates how to create bar chart with different colors for each bar, and with different labels above each bar.
Paste it in google playground and check yourself.