0

x 轴上的值不断重复出现,我只希望出现三个值:Rural、Peri Urban 和 Urban。下面是我的 Javascript 代码,显示了drawChar用于可视化图表的 t 函数。可能是什么问题呢?

     function drawVisualization(County) {
    google.visualization.drawChart({
      containerId: "visualization",
      dataSourceUrl: "http://www.google.com/fusiontables/gvizdata?tq=",
      query: "SELECT Environment,'BoyPupils','GirlPupils' " +
          "FROM 1eC4sIAgVXfFj01mOM2cDiyW2nly7TcFeIXj1G3s" +
          "WHERE Environment IN ('Rural','Urban'.'Peri Urban')",
      chartType: "ColumnChart",
      options: {
        title: County,
        height: 750,
        width: 1100
      }
    });
  }

我只希望三个值出现与图像中不同

4

1 回答 1

2

您需要一个GROUP BY子句Environment并且必须SUM用于其他列

"SELECT Environment, \
          SUM('BoyPupils') as BoyPupils, \
          SUM('GirlPupils') as GirlPupils \
       FROM 1eC4sIAgVXfFj01mOM2cDiyW2nly7TcFeIXj1G3s \
       GROUP BY Environment"

http://jsfiddle.net/doktormolle/L6Yqp/

于 2013-10-03T17:35:49.857 回答