google.charts.load("current", {
callback: drawChart,
packages: ['corechart']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Metal", "Copper", "Silver", "Gold", "Platinum"],
["Copper", 8.94, null, null, null],
["Silver", null, 10.49, null, null],
["Gold", null, null, 19.30, null],
["Platinum", null, null, null, 21.45]
]);
var view = new google.visualization.DataView(data);
view.setColumns([
0,
1, {calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation"},
2, {calc: "stringify",
sourceColumn: 2,
type: "string",
role: "annotation"},
3, {calc: "stringify",
sourceColumn: 3,
type: "string",
role: "annotation"},
4, {calc: "stringify",
sourceColumn: 4,
type: "string",
role: "annotation"},
]);
var options = {
title: "Density of Precious Metals, in g/cm^3",
width: 600,
height: 400,
legend: {alignment: "right"},
colors: ['#b87333', 'silver', 'gold', '#e5e4e2']
};
var chart = new google.visualization.ColumnChart(document.getElementById("chart_div"));
chart.draw(view, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
ああ、私は行くために必要な場所私を得ています!私はデータテーブルを次のように変更しました: 'var data = google.visualization.arrayToDataTable( [" Metal "、" Copper "、" Silver "、" Gold "、" Platinum "]、 [" Metal " 8.94、10.49、19.30、21.45] ]); それは私の目的のために働いた。 –
よろしく!それはもっと意味をなさない... – WhiteHat