대시 보드에서 클릭 가능한 차트를 구현하려고합니다. 사용자가 클릭 한 원형 차트의 세그먼트를 기반으로 다른 웹 페이지로 리디렉션됩니다. 그러나 ChartWrapper 개체에서 getChart() 사용할 때 chartObject NULL입니다. ChartWrapper에서 DataTable을 꺼내는 데 아무런 문제가 없습니다.ChartWrapper.getChart()가 null을 반환합니다.
내 코드에서 '선택'이벤트 전에 '준비'이벤트를 사용하려고했지만 여전히 NULL을 얻습니다. 어떤 충고?
당신은 당신의 차 문제는 당신이 각는, PieChart 데이터의 1 열을 전달하는 것입니다 코드 here
// Define a Pie chart 3
pie3 = new google.visualization.ChartWrapper({
'chartType': 'PieChart',
'containerId': 'chart3',
'options': {
//'width': 400,
'height': 300,
'legend': {'position':'right', 'textStyle': {fontSize: 9}},
'title': 'Audit Type',
'chartArea': {'left': 80, 'top': 30, 'right': 0, 'bottom': 0, 'height':300, 'widith':200},
'pieSliceText': 'value',
'slices': {0: {color: '#9fbfdf'}, 1: {color: '#6699cc'}, 2: {color: '#3973ac'}, 3: {color: '#738b28'}, 4: {color: '#a4c639'}, 5: {color: '#bfd774'}},
'fontSize': 11
},
// from the 'data' DataTable.
'view': {'columns': [6]}
});
google.visualization.events.addListener(pie3, 'ready', onReady);
// Create a dashboard
new google.visualization.Dashboard(document.getElementById('dashboard')).
// Establish bindings, declaring the both the slider and the category
// picker will drive both charts.
bind([yearPicker, slider2, categoryPicker], [pie, pie2, pie3]).
// Draw the entire dashboard.
draw(data);
function onReady() {
google.visualization.events.addListener(pie3.getChart(), 'select', handler);
}
function handler() {
chartObject = pie3.getChart().getSelection();
alert(chartObject);
}
}
google.setOnLoadCallback(drawVisualization);
코드를 기반으로 작성한 필인은 http://jsfiddle.net/asgallant/hKj7g/입니다. 전체 자바 스크립트 코드 또는 문제를 보여주는 예제에 대한 jsfiddle 링크로 게시물을 업데이트 할 수 있습니까? – asgallant
jsfiddle을 전체 코드로 업데이트했습니다. 세 번째 원형 차트를 클릭하십시오. null를 돌려줍니다. –
새로운 jsfiddle 링크는 무엇입니까? – asgallant