小编Mad*_*ess的帖子

如何使用Chart.js将单击事件添加到我的折线图中

我正在尝试使用Chart.js将单击事件添加到我的折线图中.我已经启用了我的工具提示以显示来自折线图的信息,但我还想添加一个点击方法,让我知道用户点击x轴的位置.现在我只想弹出警报,给我用户点击的x轴上的值.

研究:

我查看了Chart.js文档,我遇到了这个方法:.getPointsAtEvent(event)

在Chart实例上调用getPointsAtEvent(event)传递事件或jQuery事件的参数将返回该事件的相同位置的点元素.

canvas.onclick = function(evt){
    var activePoints = myLineChart.getPointsAtEvent(evt);
    // => activePoints is an array of points on the canvas that are at the same position as the click event. };
Run Code Online (Sandbox Code Playgroud)

我只是无法弄清楚如何使用或在我的代码中将函数放在何处.如果有人可以帮我弄清楚我可以将其添加到我的代码中,我们将不胜感激!

我的代码:(在javascript中)

  //NOTE: the div 'roomForChart' has been already declared as <div id="roomForChart"></div>


 //creating html code inside of javascript to display the canvas used for the graph
 htmlForGraph = "<canvas id='myChart' width ='500' height='400'>";
 document.getElementById('roomForChart').innerHTML += htmlForGraph;

 //NOW TO CREATE DATA …
Run Code Online (Sandbox Code Playgroud)

javascript charts linechart onclick chart.js

13
推荐指数
4
解决办法
4万
查看次数

如何知道Parse.initialize()何时被调用?

现在我使用静态布尔值来判断初始化是什么时候发生的.有没有更简单的方法来知道我已经调用了初始化?

谢谢!!!

解决了!!!!非常感谢你的评论.您需要在扩展应用程序的类中初始化解析,然后将其作为应用程序(而不是其他活动)添加到清单文件中.

:)


这是我使用Parse的类:

package com.example.myapp;

import com.parse.Parse;

import android.app.Application;

public class UseParse extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "id", "key");
 }
}   
Run Code Online (Sandbox Code Playgroud)

这是我的android清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" 
 >


 <uses-sdk android:minSdkVersion="11"
      android:targetSdkVersion="14"/>


 <supports-screens 
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>



<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE" android:required="false" />


<permission android:protectionLevel="signature"
android:name="com.example.myapp.permission.C2D_MESSAGE" …
Run Code Online (Sandbox Code Playgroud)

java parse-platform

9
推荐指数
2
解决办法
7988
查看次数

如何调用文本输入功能输入键按下?

我用表格格式创建了一个div,用于过滤数据选项.我在文本框内按Enter键时遇到问题.当我按Enter键时,会出现警报,但页面只是重新加载,并且没有使用任何选项正确过滤.任何人都可以向我解释发生了什么事吗?

如果我不清楚或需要解释任何事情,请告诉我!

这是我的过滤器选项栏的样子:

在此输入图像描述

HTML:

<form name="myform">

   <center><table id="mykeyTable" border="1" cellspacing="10" cellpadding="10">
   <center></center>

</td>


<!--Search bar -->
   <tr>
    <td colspan="4">
    <center>
      <form>
        Starts With: <input type="text" id="myText" value=""><br>
      </form>
    </center>
   </tr>

<!-- Site Options -->
  <td><center>Site</center><br>
                  <input type="radio" name="siteID" onclick="updateSiteID(this.value)" value="Asc"checked>
                  <input type ='button' id='siteIDChosen' class='button-addAsc'/>
              <br>
                  <input type="radio" name="siteID" onclick="updateSiteID(this.value)" value="Desc" >
                  <input type ='button' id='siteIDChosen' class='button-addDesc'/>
              <br>
         </input>
     </form></td>

<!-- Status options -->

    <td><center>Status
   <br><br></center><input type="radio" name="siteStatus" onclick="updateSiteStatus(this.value)"value="Online"> Online<br><input type="radio" name="siteStatus" onclick="up\
dateSiteStatus(this.value)" value="Offline"> Offline<br><input type="radio" name="siteStatus" onclick="updateSiteStatus(this.value)" value="Both" …
Run Code Online (Sandbox Code Playgroud)

html javascript forms jquery keypress

5
推荐指数
1
解决办法
3万
查看次数

使用PHP SDK查询Parse.com

我正在尝试使用新的PHP SDK查询Parse.com.我安装了所有必要的东西.我在查询时遇到了问题.

链接:[ https://www.parse.com/docs/php_guide#queries]

我试过用这个:

 require 'vendor/autoload.php';

 use Parse\ParseClient;
 use Parse\ParseObject;

 ParseClient::initialize('secret1','secret2', 'secret3');


 $query = new ParseQuery("TableName");
 $query->equalTo("email", "email@me.com");
 $results = $query->find();
 echo "Successfully retrieved " . count($results) . " scores.");
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激!谢谢!!!!


使用William George的帮助解决了!这是我更新的代码:

 require 'vendor/autoload.php';

 use Parse\ParseClient;
 use Parse\ParseObject;
 use Parse\ParseQuery;

 ParseClient::initialize('secret1','secret2', 'secret3');

 try{
 $query = new ParseQuery("TableName");
 $query->equalTo("email", "email@me.com");
 $results = $query->find();
 echo "Successfully retrieved " . count($results) . " scores.";
 } catch (Exception $e){
    echo $e->getMessage();
 }
Run Code Online (Sandbox Code Playgroud)

php parse-platform

4
推荐指数
1
解决办法
3425
查看次数

如何将 Google Earth KML 文件添加到 html iframe?

基本上,我正在尝试将 Google Earth div 上的 KML 文件添加/显示到我的网站。我将我的文件命名为“satellites.kml”。

<!-- html code starts...-->

 <p><iframe 
       name="myKMLEarth" 
       src="/getrack/satellites.kml"
       height="440" 
       width="100%" 
       frameborder="0" 
       scrolling="no">
 </iframe></p>

<!-- html code continues ...-->
Run Code Online (Sandbox Code Playgroud)

页面加载时,它会下载我的 KML,而不是在 iframe 中打开它。我不应该使用 src 链接到 KML 文件吗?任何意见,将不胜感激!先感谢您!

html iframe kml google-earth

3
推荐指数
1
解决办法
2万
查看次数

HTML Javascript在for循环中添加var作为输入值

我正在做的是创建一个表.我在for循环中使用带有html语句的Javascript添加此表的值.我知道这可能很难想象,所以我添加了一张图片,向左侧显示单选按钮,并在行的其余部分显示相应的数据.我试图给单选按钮提供与我的站点ID相同的值.

这是我的表的一个例子.

表格ex

这是我的for循环:

   //html is the html code that will be converted from javascript to html, and the array for siteID is also declared before the for loop   


 //for loop to add the results to the array and also to the table
    for (var i = 0; i < results4.length; i++) {
      var object4 = results4[i];
      //the value of the site ID
      siteIDArray[i] = object4.get('SiteID');

      html += "<tr><td><center><br><input type='radio' onclick='alert(this.value)' 
                name='siteChosen' value='siteIDArray[i]'><center></td>";
      html += "<td><center><p>" + siteIDArray[i] + "</p></center></td>";
      ... …
Run Code Online (Sandbox Code Playgroud)

html javascript dom for-loop

1
推荐指数
1
解决办法
602
查看次数