我有一个包含两列的融合表('TOTAL_ROOF'和'POTENTIAL_')。 'POTENTIAL_'是'TOTAL_ROOF'的子集。
现在我是:
1)显示由用户点击'
确定的格式化行数据2)试图绘制一个PieChart,即:drawVisualization.PieChart(e.row ['TOTAL_ROOF',“POTENTIAL _']。value);
我已经获得了#1的工作......但是,对于#2我有点迷失了...我看到的所有例子都显示PieChart已经被用户点击任何东西之前已经创建了。 / p>
点击后有没有办法创建PieChart?将空间留空(直到#1)?
此外,我看不到如何在我的文本框中调用它(例如:http://jsfiddle.net/fG5a5/1/)。
到目前为止,这是我的代码:
加载库:
google.load('maps', '3.5', {other_params:'sensor=false'});
google.load('jquery', '1.6.0');
google.load('visualization', '1', {packages:["corechart"]});
google.load('jqueryui', '1.8.12');
JS
var tableid = 1DGswslbC5ijqWHPJvOH1NH7vltkZIPURJun_L5I;
var location_column = 'geometry'
function drawVisualization() {
google.visualization.drawChart({
"chartType": "PieChart"
})};
// Draw Visualization of WHAT (the event listener has not been triggered??)
function initialize() {
google.maps.event.addListener(layer, 'click', function(e) {
$("#roof-panel-area").html(
'<p><strong>Total Roof Area (sqft)</strong>: ' + ' ' +
Math.round(e.row['TOTAL_ROOF'].value) +
'<br><strong> Potential Roof Area (sqft)</strong>:' + ' '
+ Math.round(e.row['POTENTIAL_'].value) +
'<br><strong> Pitched or Flat Roof (?)</strong>:'+ ' ' +
e.row['PITCHED_OR'].value +
'<br><strong> # of Panels per Roof Area :</strong>' + ' ' +
Math.round(e.row['NUMBER_OF_'].value) + '</p>');
});
// Click Listener on layer using jquery , searches for fields related to
// roof/panel,
google.maps.event.addListener(layer, 'click', function(e) {
drawVisualization.PieChart(e.row['TOTAL_ROOF','POTENTIAL_'].value);
});
// Click Listener - updates graph
layer.setMap(map);
}
HTML:
<div id="sidebarItem">
<br>
<h1> Hatfield Solar Map</h1>
<!---Create a text box input for the user to enter the street address-->
Address: <input type="text" id="inputTextAddress" style=" width:200px" title="Address to Geocode" />
<!--Create a button input for the user to click to geocode the address-->
<input type="button" onclick="codeAddress()" id="inputButtonGeocode" style="width:200px" title="Click to Find Address" value="Click to Find Address" />
<h3>Select a building outline or search for an address to identify buildings that you'd like to select.</h3>
<!---Content from Click-->
<hr/>
<div id="sidebar-content-area" style="padding:5px;">
<div id="intro" style="text-align: center; margin-top: 20px; display: none;">
<p><i>Buildings are symbolized according to roof size, and the possibility of increased panel placement.</i><p>
</div>
<div id="overview" style:"">
<h3>Building Overview:</h3>
<p id ="roof-panel-area"></p>
</div>
</div>
答案 0 :(得分:0)
你想用这条线做什么:
...
drawVisualization.PieChart(e.row['TOTAL_ROOF','POTENTIAL_'].value);
也许你应该只做一个函数:
....
var whateverClicked = function(){
//do something;
};
并将其附加到侦听器:
google.maps.event.addListener(layer, 'click', whateverClicked);
答案 1 :(得分:0)
好的 - 得到了......
js功能1:
function drawVisualization(e) {
var data = google.visualization.arrayToDataTable([
['Area', 'Potential', 'Total'],
['Building', Math.round(e.row['POTENTIAL_'].value), Math.round(e.row['TOTAL_ROOF'].value)],
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('visualization_div'));
chart.draw(data, options);
};
js功能2:
google.maps.event.addListener(layer, 'click', function(e) {
$("#roof-panel-area").html(
'<p><strong>Total Roof Area (sqft)</strong>: ' + ' ' + Math.round(e.row['TOTAL_ROOF'].value) +
'<br><strong> Potential Roof Area (sqft)</strong>:' + ' ' + Math.round(e.row['POTENTIAL_'].value) +
'<br><strong> Pitched or Flat Roof (?)</strong>:'+ ' ' + e.row['PITCHED_OR'].value +
'<br><strong> # of Panels per Roof Area :</strong>' + ' ' + Math.round(e.row['NUMBER_OF_'].value) +
'</p>');
drawVisualization(e);
});
layer.setMap(map);
}
HTML
<div id="overview" style:"">
<h3>Building Overview:</h3>
<p id ="roof-panel-area"></p>
<div id = "visualization_div" style="align: center; width: 230px; height: 260px;"></div>
</div>