GoogleChartのカスタマイズ
-
上記トピックを開始したものです。
皆様のおかげで無事解決することができました。<?php $sex_count_men = get_comments ( array ( 'post_id' => $post->ID, 'meta_key' => 'sex', 'meta_value' => 'men', 'count' => true )); $sex_count_women = get_comments ( array ( 'post_id' => $post->ID, 'meta_key' => 'sex', 'meta_value' => 'women', 'count' => true )); $sex_count_other = get_comments ( array ( 'post_id' => $post->ID, 'meta_key' => 'sex', 'meta_value' => 'other', 'count' => true )); $sex_count_noselect = get_comments ( array ( 'post_id' => $post->ID, 'meta_key' => 'sex', 'meta_value' => '選択してください', 'count' => true )); $sex_count_private = $sex_count_other+$sex_count_noselect; <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChartSexPie); function drawChartSexPie() { var data = google.visualization.arrayToDataTable([ ['男女比', '(%)'], ['男性', <?php echo $sex_count_men;?>], ['女性', <?php echo $sex_count_women;?>], ['非公開', <?php echo $sex_count_private;?>], ]); var options = { 'title': '【口コミの男女比】', is3D: true, legend: { position: 'bottom'}, }; var chart = new google.visualization.PieChart(document.getElementById('sex_pie')); chart.draw(data, options); } </script> <div id="sex_pie" style="width: 100%;"></div>
Google Chartのコードにコメントから取得した数値を動的に組み込み
問題無くグラフが表示されたのですが、コメントが無いページに関しては
グラフのタイトルのみ表示され、グラフは表示されず隙間ができてしまいます。そこでご相談ですが、コメントが0件の場合、グラフの領域自体を非表示に
する方法はございますでしょうか。質問ばかりで申し訳ございません。
何卒よろしくお願い申し上げます。
5件の返信を表示中 - 1 - 5件目 (全5件中)
5件の返信を表示中 - 1 - 5件目 (全5件中)
- トピック「GoogleChartのカスタマイズ」には新たに返信することはできません。