Google visualization 谷歌图表api的柱形图问题

Google visualization 谷歌图表api的柱形图问题,google-visualization,Google Visualization,我想用GoogleChartAPI显示柱状图,这是我的代码。 我想在底部的x轴上显示月份名称,在图表的左侧显示y轴的值,但我无法得到它 google.load("visualization", "1", { packages: ["corechart"] }); google.setOnLoadCallback(drawChart); function drawVisualization() { // Create and populate the data table. var JSO

我想用GoogleChartAPI显示柱状图,这是我的代码。 我想在底部的x轴上显示月份名称,在图表的左侧显示y轴的值,但我无法得到它

google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart);
function drawVisualization() {
// Create and populate the data table.
var JSONObject = { "cols": [
{ "id": "", "label": "Jan", "Pattern": "", "type": "number" },    
{ "id": "", "label": "Feb", "Pattern": "", "type": "number" },
{ "id": "", "label": "Mar", "Pattern": "", "type": "number" },
{ "id": "", "label": "Apr", "Pattern": "", "type": "number" },
          { "id": "", "label": "May", "Pattern": "", "type": "number" },
           { "id": "", "label": "Jun", "Pattern": "", "type": "number" },
            { "id": "", "label": "Jul", "Pattern": "", "type": "number" },
            { "id": "", "label": "Aug", "Pattern": "", "type": "number" },
            { "id": "", "label": "Sep", "Pattern": "", "type": "number" },
            { "id": "", "label": "Oct", "Pattern": "", "type": "number" },
            { "id": "", "label": "Nov", "Pattern": "", "type": "number" },
            { "id": "", "label": "Dec", "Pattern": "", "type": "number" }
            ], "rows":
            [{ "c": [
            { "v": "0"},
             { "v": "0", "f": null },
              { "v": "0", "f": null },
               { "v": "0", "f": null },
                { "v": "0", "f": null },
                 { "v": "0", "f": null },
                  { "v": "2000", "f": null },
                   { "v": "0", "f": null },
                   { "v": "0", "f": null },
                   { "v": "1000", "f": null },
                    { "v": "0", "f": null },
                    { "v": "0", "f": null }
                    ]
  }]
            };
            var data = new google.visualization.DataTable(JSONObject);

   // Create and draw the visualization.
   new google.visualization.ColumnChart(document.getElementById('visualization')).
   draw(data,
       {title:"Yearly Coffee Consumption by Country",
        width:600, height:400,
         hAxis: {title: "Year"}}
   );
  }

您需要更改数据的布局。可视化API柱形图(以及最类似的Viz API图)期望数据的域轴(柱形图的x轴)值位于第一列,每个数据系列的值位于以下列(其中每列为一个数据系列)。考虑到您的需求和现有数据,我认为您需要一个包含两列数据的DataTable:“月”和“值”(或者您决定将其命名为什么)。下面是一个可能的示例:

var JSONObject = {
    "cols": [
        {"type": "string", "label": "Month"},
        {"type": "number", "label": "Value"}
    ],
    "rows": [
        {"c":[{"v": "Jan"}, {"v": 0}]},
        {"c":[{"v": "Feb"}, {"v": 0}]},
        {"c":[{"v": "Mar"}, {"v": 0}]},
        {"c":[{"v": "Apr"}, {"v": 0}]},
        {"c":[{"v": "May"}, {"v": 0}]},
        {"c":[{"v": "Jun"}, {"v": 0}]},
        {"c":[{"v": "Jul"}, {"v": 2000}]},
        {"c":[{"v": "Aug"}, {"v": 0}]},
        {"c":[{"v": "Sep"}, {"v": 0}]},
        {"c":[{"v": "Oct"}, {"v": 1000}]},
        {"c":[{"v": "Nov"}, {"v": 0}]},
        {"c":[{"v": "Dec"}, {"v": 0}]}
    ]
};