简体   繁体   English

vAxis 值在条形图中不可见:谷歌图表

[英]vAxis Values not visible in bar chart : Google Charts

My values in the vertical axis are not visible as shown in the image:如图所示,我在垂直轴上的值不可见:

在此处输入图片说明 . .

What could be the problem with my code?我的代码可能有什么问题?

      function drawVisualization() {
    google.visualization.drawChart({
      containerId: 'visualization',
      dataSourceUrl: 'http://www.google.com/fusiontables/gvizdata?tq=',
      query: 'SELECT Environment, GirlPupils, BoyPupils, FemaleTeachers, MaleTeachers FROM 1eC4sIAgVXfFj01mOM2cDiyW2nly7TcFeIXj1G3s',
      chartType: 'BarChart',
      options: {
        title: 'Number of Students and Teachers',
        vAxis: {
          title: 'Environment'
        },
        hAxis: {
          title: 'Number'
        }
      }
    });
  }

As I can tell from the image the vertical values is actually shown!正如我从图像中可以看出的,实际上显示了垂直值! The issues is问题是

  1. You have a very little height set for the chart-container, trying to show a lot of bars您为图表容器设置的高度很小,试图显示很多条形

  2. The fontSize for vAxis is to the opposit relatively large vAxis 的 fontSize 相对较大

  3. There can often be problems with lack of space to the left通常会出现左侧空间不足的问题

Change the height of the <div> -container to something that actually can hold the many bars :<div>容器的高度更改为实际上可以容纳许多条的高度:

<div id="visualization" style="height:1000px;"></div>

Change fontSize for the vAxis and add some space to the left by chartArea更改 vAxis 的 fontSize 并在 chartArea 左侧添加一些空间

options: {
   title: 'Number of Students and Teachers',
   vAxis: {
      title: 'Environment',
      textStyle : { fontSize : 7 }
   },
      hAxis: {
      title: 'Number'
   },
   chartArea: {left: "150",top: 0 }
}

在此处输入图片说明


Edit :编辑 :

In order to only select columns where Environment is Rural, Urban or Peri Urban, change your query to为了仅选择Environment为 Rural、Urban 或 Peri Urban 的列,请将查询更改为

SELECT Environment, GirlPupils, BoyPupils, FemaleTeachers, MaleTeachers 
FROM 1eC4sIAgVXfFj01mOM2cDiyW2nly7TcFeIXj1G3s 
WHERE Environment IN ('Rural', 'Urban','Peri Urban')

note that normal SQL syntax OR is not supported by FusionTables, you must use IN .请注意,FusionTables 不支持普通 SQL 语法OR ,您必须使用IN Also strings must be in single quotes '' .字符串也必须用单引号''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM