0

x軸中的值持續反覆出現,我只希望出現三個值:Rural,Peri Urban和Urban。以下是我的JavaScript代碼,顯示用於可視化圖表的drawChart函數。可能是什麼問題呢?減少Javascript中的遞歸,Fusion Tables API

 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 
     } 
    }); 
    } 

I want only three values to appear unlike in the image

回答

1

您需要爲Environment一個GROUP BY條款,必須使用SUM其它列

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

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

+0

它的工作,謝謝 – 1088