首页 \ 问答 \ 谷歌融合表的PieChart / Listener事件(PieChart / Listener event of a google fusion table)

谷歌融合表的PieChart / Listener事件(PieChart / Listener event of a google fusion table)

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

现在我是:

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

2)尝试绘制一个PieChart即:drawVisualization.PieChart(e.row ['TOTAL_ROOF',“POTENTIAL _']。value);

我已经获得了#1的工作......然而,对于#2我有点迷失了...我看到的所有例子都显示PieChart已经被用户点击任何东西之前已经创建了。

有没有办法在点击后创建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>

I have a fusion table with two columns ('TOTAL_ROOF' & 'POTENTIAL_'). 'POTENTIAL_' is a subset of 'TOTAL_ROOF'.

Right now I am:

1) Showing formated row data determined by the users 'click'

2) trying to draw a PieChart i.e.: drawVisualization.PieChart(e.row['TOTAL_ROOF', "POTENTIAL_'].value);

I've gotten #1 to work... However, for #2 I am a bit lost on what to do...all the examples I see show the PieChart already being created BEFORE the user has clicked anything.

Is there a way to create the PieChart after the click? Leaving the space blank until (like it is for #1)?

Also I don't see how to call it in a into my text-box (ex: http://jsfiddle.net/fG5a5/1/).

Here is my code so far:

load libraries:

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>

原文:https://stackoverflow.com/questions/16270726
更新时间:2023-11-24 10:11

最满意答案

要捕获命令的输出,请使用for /f循环。 有关更多信息,请参阅help for

练习1

要将%var%的值设置为findstr的输出,请执行以下操作:

for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"

然后,如果你想要该行的最后一个单词,你可以使用一个基本的for循环来循环遍历%var%每个单词。

for %%I in (%var%) do set "lastword=%%I"
set "var=%lastword%"

练习2

或者,如果你知道包含“name”的行总是4个令牌长(例如,“我的名字是等等”),你可以像这样简单地捕获findstr输出的第四个标记。

for /f "tokens=4" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"

就是这样。 %var%将包含findstr匹配的第四个单词。


练习3

如果您知道该行将始终以“我的名字是”开头,但您想要名字的可能性,或许多名称如“John Jacob Jingleheimer-Schmidt”,您可以使用tokens来捕获您想要的类似内容练习2。

for /f "tokens=3*" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%J"

请注意,这次我捕获了%%J而不是%%I 那是因为%%I将是令牌3(第三个单词),而%%J就是其后的一切( tokens=3*的通配符tokens=3* )。


练习4

或者,如果名称可能是名字和姓氏,但您知道它的前面是“我的名字是”,您可以通过变量子字符串替换删除“我的名字是”部分。

for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
set "var=%var:My name is =%"

这将从%var%的值中删除“我的名字是”,留下你的“约翰史密斯”。


练习5

如果你不能指望包含“name”的行是相同数量的单词(例如,“你好!我的名字是”或“你好!我的名字是”,你可以使用带有通配符的变量子串替换剥离变量内容。无论名称是一个字还是更多,无论“名称”之前的内容是否有所不同,这都应该有效。

for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
set "var=%var:*name is =%"

To capture the output of a command, use a for /f loop. See help for for more information.

Exercise 1

To set the value of %var% to the output of findstr, do it something like this:

for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"

Then if you want the last word of the line, you can use a basic for loop to loop through each word of %var%.

for %%I in (%var%) do set "lastword=%%I"
set "var=%lastword%"

Exercise 2

Alternatively, if you know that the line containing "name" will always be 4 tokens long (as in, "My name is blah"), you can simply capture the fourth token of the output of findstr like this.

for /f "tokens=4" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"

And that's it. %var% will contain the fourth word of the line matched by findstr.


Exercise 3

If you know that the line will always begin with "My name is" but you want the possibility of a first and last name, or lots of names like "John Jacob Jingleheimer-Schmidt", you can use tokens to capture what you want similar to Exercise 2.

for /f "tokens=3*" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%J"

Notice that I captured %%J instead of %%I this time. That's because %%I would be token 3 (the third word), while %%J is everything thereafter (the wildcard in tokens=3*).


Exercise 4

Or if it's possible that the name could be a first and last name, but you know it will be preceded by "My name is", you can remove the "My name is" part via variable substring substitution.

for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
set "var=%var:My name is =%"

which will strip "My Name is " from the value of %var%, leaving you with "John Smith".


Exercise 5

If you can't count on the line containing "name" to be the same number of words (for instance, "Hi there! My name is" or "Hello! My name is", you can use variable substring substitution with a wildcard to strip out variable content. This should work regardless of whether the name is one word or more, and regardless of whether the content before "name is" varies.

for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
set "var=%var:*name is =%"

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。