1
如何爲我的Google餅圖設置圖例和標籤?如何將圖例和標籤添加到我的Google餅圖?
已被廢棄的方法具有這種能力:https://developers.google.com/chart/image/docs/gallery/pie_charts
另外,我怎樣才能讓這個的onclick所選切片被從餅一點點爆炸?
這是我到目前爲止有:
<div id="pie_chart_div" style="width: 940px; height: 500px;"></div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(render_applicant_sources);
function render_applicant_sources() {
var data = new google.visualization.arrayToDataTable([["Source","Number of Applicants"],["Hospitality Online",222],["Indeed",22]]);
data.addColumn('string', 'Geocoder');
data.addColumn('number', 'Geocodes');
var chart = new google.visualization.PieChart(document.getElementById('pie_chart_div'));
var options = {
title: 'Scottsdale Resort & Conference Center from December 1, 2012 to December 1, 2013',
is3D: true,
colors: [ '#2483b3', '#AAC789', '#1E4147', '#437356', '#F34A53', '#FAE3B4' ],
titleTextStyle: { bold: false },
legend: { position: 'labeled' }
};
chart.draw(data, options);
google.visualization.events.addListener(chart, 'click', function(e){
var data = chart.getSelection();
if(data.length > 0) {
chart.setSelection([]);
}
});
}
</script>
謝謝!我將如何使它在雙擊事件中移回切片?現在,它在點擊時爆炸一個切片,但隨後單擊另一個切片會移動整個圖表... –
您可以執行一些檢測以查看切片是否已經爆炸,並在必要時對其進行爆炸。查看更新的帖子。 – asgallant
謝謝!你有什麼想法如何添加圖例與標籤? –