0

我有一个包含两列(“TOTAL_ROOF”和“POTENTIAL_”)的融合表。“POTENTIAL_”是“TOTAL_ROOF”的子集。

现在我是:

1)显示由用户“点击”确定的格式化行数据

2) 尝试绘制饼图,即:drawVisualization.PieChart(e.row['TOTAL_ROOF', "POTENTIAL_'].value);

我已经让#1 开始工作了……但是,对于#2,我有点不知所措……我看到的所有示例都显示在用户单击任何内容之前已经创建了 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>: ' + '&nbsp;&nbsp;' + 
      Math.round(e.row['TOTAL_ROOF'].value) + 
  '<br><strong> Potential Roof Area (sqft)</strong>:' + '&nbsp;&nbsp;' 
       +  Math.round(e.row['POTENTIAL_'].value) + 
  '<br><strong> Pitched or Flat Roof (?)</strong>:'+ '&nbsp;&nbsp;' +     
       e.row['PITCHED_OR'].value + 
  '<br><strong> # of Panels per Roof Area :</strong>' + '&nbsp;&nbsp;' + 
       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>
4

2 回答 2

0

好的,我知道了...

js功能一:

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>: ' + '&nbsp;&nbsp;' + Math.round(e.row['TOTAL_ROOF'].value) + 
         '<br><strong> Potential Roof Area (sqft)</strong>:' + '&nbsp;&nbsp;' + Math.round(e.row['POTENTIAL_'].value) + 
         '<br><strong> Pitched or Flat Roof (?)</strong>:'+ '&nbsp;&nbsp;' +  e.row['PITCHED_OR'].value + 
         '<br><strong> # of Panels per Roof Area :</strong>' + '&nbsp;&nbsp;' + 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>
于 2013-05-03T19:30:17.270 回答
0

你想用这条线做什么:

...
drawVisualization.PieChart(e.row['TOTAL_ROOF','POTENTIAL_'].value);

也许你应该做一个像这样的功能:

....
var whateverClicked = function(){
    //do something;
};

并将其附加到侦听器:

google.maps.event.addListener(layer, 'click', whateverClicked);
于 2013-04-29T04:04:18.217 回答