2つのGoogleグラフを1つのページに表示しようとすると、他のソリューションが投稿されていますが、私にとってはうまくいかないようです - 私は何のエラーもしていません信じられないほど知っておくと便利です。ページ上に2つのgooglechartがありますか?ソリューションが動作しない
<script type="text/javascript">
google.load("visualization", "1.0", {packages: ["bar"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
//Various Data Tables
var data = google.visualization.arrayToDataTable([
['Country', 'Premarital Sex', 'Homosexuality', 'Divorce', 'Abortion', 'Euthanasia', 'Prostitution', 'General Violence', 'Beating Children', 'Stealing Benefits', 'Bribery', 'Stealing', 'Beating Wife'],
['West', 0.27, 0.34, 0.35, 0.43, 0.43, 0.67, 0.92, 0.93, 0.93, 0.94, 0.95, 0.96],
['Eastern Europe', 0.75, 0.89, 0.69, 0.77, 0.83, 0.92, 0.97, 0.90, 0.90, 0.97, 0.97, 0.92],
['MENA', 0.95, 0.92, 0.78, 0.92, 0.93, 0.95, 0.92, 0.77, 0.87, 0.95, 0.94, 0.86],
['South Asia', 0.76, 0.77, 0.75, 0.81, 0.77, 0.82, 0.81, 0.79, 0.75, 0.80, 0.82, 0.83],
['East Asia', 0.68, 0.75, 0.67, 0.79, 0.65, 0.84, 0.88, 0.68, 0.67, 0.91, 0.93, 0.92],
['Latin America', 0.58, 0.69, 0.60, 0.85, 0.80, 0.79, 0.92, 0.84, 0.77, 0.92, 0.93, 0.95],
['Sub Saharan Africa', 0.62, 0.75, 0.69, 0.74, 0.74, 0.76, 0.74, 0.56, 0.74, 0.75, 0.77, 0.77]
]);
var data2 = google.visualization.arrayToDataTable([
['Country', 'Egalitarian Values', 'Premarital Sex', 'Abortion'],
['West',0.76,0.27,0.43],
['Eastern Europe',0.53,0.75,0.77],
['MENA',0.38,0.95,0.92],
['South Asia',0.45,0.76,0.81,],
['East Asia', 0.55,0.68,0.79,],
['Latin America',0.70,0.58,0.85],
['Sub Saharan Africa',0.51,0.62,0.74,]
]);
var options = {
colors: ['#ebf1f5', '#5e82a6'],
chart: {
title: 'Regional Means on Dependent and Independent Variables',
subtitle: 'On a scale of 0 - 1',
},
vAxis: {
viewWindowMode: 'explicit',
viewWindow: {
max: 1,
min: 0
}
},
bars: 'vertical', // Required for Material Bar Charts.
width: 800,
height: 350,
};
var chart = new google.visualization.BarChart(document.getElementById('regionalmeans'));
chart.draw(data, options);
var chart2 = new google.visualization.BarChart(document.getElementById('depind'));
chart.draw(data2, options);
}
draw(chart);
draw(chart2);
}
</script>
</head>
<body>
<div id="regionalmeans"></div>
<div id="depind"></div>
ありがとうございます!私は自分でそれを理解しただけですが、あなたの方がずっときれいです – megelo