我想用谷歌图表 api 显示柱形图,这是我的代码。我想在底部的 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"}}
);
}
</p>