2013-02-14 4 views
1

이것은 작업 한 코드입니다. 조각을 클릭하여 다른 페이지로 리디렉션해야합니다.Google 원형 차트 조각에 링크를 추가하는 방법

<script type='text/javascript' src='https://www.google.com/jsapi'></script> 
<script type='text/javascript'> 

    // Load the Visualization API and the piechart package. 
    google.load('visualization', '1.0', {'packages':['corechart']}); 

    // Set a callback to run when the Google Visualization API is loaded. 
    google.setOnLoadCallback(drawChart); 

    // Callback that creates and populates a data table, 
    // instantiates the pie chart, passes in the data and 
    // draws it. 
    function drawChart() { 

    // Create the data table. 
    var data = new google.visualization.DataTable(); 
    data.addColumn('string', 'Topping');  
    data.addColumn('number', 'Slices'); 
    data.addRows([ 
     ['Cleaning Completed', $co1], 
    ['Denied At Client Place', $co2], 
    ['Denied', $co3], 
    ['Postponed', $co4], 
    ['Careless Driver', $co5], 
    ['Cleaning Started', $co6], 
    ['Emptyspace', $co22], 
    ['Assigned to Vehicle', $co23], 
    ['Select', $co24], 
    ['Call Not Picked', $co25], 
    ['Asked to Call Back', $co26], 
    ]); 


     // Instantiate and draw our chart, passing in some options. 
      var chart = new google.visualization.PieChart(document.getElementById('chart_div')); 
     chart.draw(data, options); 
    } 
     </script> 

답변

3

Google 시각화를 사용하면 클릭 핸들러를 설정할 수 있다고 생각합니다. 그래서 drawChart 함수에 이것을 추가하십시오. (chart.draw AFTER)

google.visualization.events.addListener(chart, 'select', function() { 
    var selection = chart.getSelection(); 
    console.log(selection); 
}); 

"선택"거기에 무슨 확인하고 그 브라우저로 리디렉션 할 위치 설정하기에 충분한 정보를 가지고 있는지 확인합니다.

자세한 정보 : https://developers.google.com/chart/interactive/docs/reference#addlistener

관련 문제