如何获得谷歌api图表柱形图中的vaxis行? [英] How to get the vaxis line in column chart of google api chart?

查看:95
本文介绍了如何获得谷歌api图表柱形图中的vaxis行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在google api图表中使用corechart包的柱形图。在这个图表中我需要垂直轴线(yaxis线)。如何在列表中获得垂直轴线。



我回答了这个链接创建此图表

实际





预计



解决方案

使Y轴数字不为字符串。



这里是代码:复制并粘贴这个是Google Code Playground。

  function drawVisualization(){
//创建并填充数据表。
var data = google.visualization.arrayToDataTable([
['Year','Austria','Bulgaria'],
[12,133,400],
[21 ,153,366],
[20,155,240],
[27,160,134],
[10,196,393],
[8,190 ,232]
]);

//创建并绘制可视化文件。
new google.visualization.ColumnChart(document.getElementById('visualization'))。
draw(data,
{title:按国家分列的每年咖啡消费量,
width:600,height:400,
vAxis:{title:Year,ticks: [{v:100,f:100 $},{v:150,f:150 $},{v:200,f:200 $},{v:300,f:300 $ }}},
hAxis:{title:Cups,ticks:[{v:4,f:3-4},{v:8,f:5-9},{ v:10,f:9-13},{v:14,f:13-14},{v:20,f:15-20}]}}
);
}


I am using column chart of corechart package in google api chart. In this chart i need for vertical axis line(yaxis line). How to get vertical axis line in columnchart.

I reffered this link for creating this chart

Actual

Expected

解决方案

Make Y-axis number not String.

here is the code : Copy and paste this is google Code Playground.

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['Year', 'Austria', 'Bulgaria' ],
    [12,  133,    400],
    [21,  153,    366],
    [20,  155,    240],
    [27,  160,    134],
    [10,  196,    393],
    [8,  190,    232]
  ]);

  // Create and draw the visualization.
  new google.visualization.ColumnChart(document.getElementById('visualization')).
      draw(data,
           {title:"Yearly Coffee Consumption by Country",
            width:600, height:400,
            vAxis: {title: "Year",ticks: [{v:100, f:"100$"},{v:150, f:"150$"},{v:200, f:"200$"},{v:300, f:"300$"}]},
            hAxis: {title: "Cups",ticks: [{v:4, f:"3-4"},{v:8, f:"5-9"},{v:10, f:"9-13"},{v:14, f:"13-14"},{v:20, f:"15-20"}]} }
      );
}

这篇关于如何获得谷歌api图表柱形图中的vaxis行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆