- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
传感器设备(温度传感器)每 10 秒向数据库发送一次数据。我必须绘制一天时间和温度之间的图表(最新数据)。我设法从数据库中获取数据。问题是因为我有大量的时间数据以及如何使用它来标记 Y 轴。日期和时间的格式为 2019-04-09 12:28:36。但我可以提取时间。但仍然如何在一个 (Y) 轴上使用时间。我的代码显示错误 Uncaught SyntaxError: Unexpected token :
//PHP
$sql = "SELECT TIME(Date_Time) as TIME , Temperature FROM dataTable WHERE Date_Time>= (CURDATE() - INTERVAL 1 DAY ) ORDER BY Date_Time DESC ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$tempValue =$row['Temperature'];
$timeInterval=$row['TIME'];
$tempValues =$tempValues. $tempValue. ',';
$timeIntervals =$timeIntervals. $timeInterval. ',';
}
$tempValues =trim ($tempValues, ",");
$timeIntervals= trim ($timeIntervals,"," );
//Javascript
var myChart = document.getElementById('myChart').getContext('2d');
var data = {
datasets: [{
data: [<?php echo $tempValues ?>],
backgroundColor: 'transparent',
borderColor:'rgba(255,99,132)',
borderWidth:5,
label: 'Temperature in degree'
}],
//error in the following line !
labels: [<?php echo $timeIntervals ?>]
};
var particleChart =new Chart(myChart, {
type:'line',
data: data
});
最佳答案
标签必须是字符串。以这种方式构建 $timeIntervals
...
$timeIntervals = $timeIntervals . '"' . $timeInterval . '",';
...为了将日期时间值括在双引号之间。
关于php - How to use 'time'(来自数据库的数据,数据类型: timestamp ) for plotting graph in Chart JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55594467/
标题基本上说明了一切。 我主要对更新案例感兴趣。假设我们正在尝试更新具有时间戳记字段的记录,并且我们希望将该字段设置为记录更新的时间戳记。有没有办法做到这一点? 最佳答案 经过一些实验,我找到了合适的
我正在学习一门类(class),其中我必须将日期转换为 unix 时间戳。 import pandas as pd df = pd.read_csv('file.csv') print type(df
我在两个不同的数据库中运行了相同的语句:我的本地数据库和 Oracle Live SQL . CREATE TABLE test( timestamp TIMESTAMP DEFAULT SY
我在两个不同的数据库中运行了相同的语句:我的本地数据库和 Oracle Live SQL . CREATE TABLE test( timestamp TIMESTAMP DEFAULT SY
bson.timestamp.Timestamp需要两个参数:time 和 inc。 time 显然是存储在 Timestamp 中的时间值。 什么是公司?它被描述为递增计数器,但它有什么用途呢?它应
2016-08-18 04:52:14 是我从数据库中获取的时间戳,用于跟踪我想从哪里加载更多记录,这些记录小于该时间 这是代码 foreach($explode as $stat){
我想将 erlang:timestamp() 的结果转换为正常的日期类型,公历类型。 普通日期类型表示“日-月-年,时:分:秒”。 ExampleTime = erlang:timeStamp(),
我想将 erlang:timestamp() 的结果转换为正常的日期类型,公历类型。 普通日期类型表示“日-月-年,时:分:秒”。 ExampleTime = erlang:timeStamp(),
我是 Java 新手。我正在使用两个 Timestamp 对象 dateFrom和dateTo 。我想检查是否dateFrom比 dateTo早 45 天。我用这个代码片段来比较这个 if(dateF
在将 panda 对象转换为时间戳时,我遇到了这个奇怪的问题。 Train['date'] 值类似于 01/05/2014,我正在尝试将其转换为 linuxtimestamp。 我的代码: Train
我正在努力让我的代码运行。时间戳似乎有问题。您对我如何更改代码有什么建议吗?我看到之前有人问过这个问题,但没能成功。 这是我在运行代码时遇到的错误:'Timestamp' object has no
我正在尝试运行以下查询: SELECT startDate FROM tests WHERE startDate BETWEEN TIMESTAMP '1555248497'
我正在使用 Athena 查询以 bigInt 格式存储的日期。我想将其转换为友好的时间戳。 我试过了: from_unixtime(timestamp DIV 1000) AS readab
最近进行了一些数据库更改,并且 hibernate 映射出现了一些困惑。 hibernate 映射: ...other fields 成员模型对象: public class Mem
rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 我想要
rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 我想要
我必须在我的数据库中保存 ServerValue.TIMESTAMP 但它必须是一个字符串。当我键入 String.valueOf(ServerValue.TIMESTAMP); 或 ServerVa
在我的程序中,每个表都有一列 last_modified: last_modified int8 DEFAULT (date_part('epoch'::text, now()::timestamp)
我想将此时间戳对象转换为日期时间此对象是在数据帧上使用 asfreq 后获得的这是最后一个索引 Timestamp('2018-12-01 00:00:00', freq='MS') 想要的输出 2
我有一个包含时间序列传感器数据的大表。大型是指分布在被监控的各个 channel 中的从几千到 10M 的记录。对于某种传感器类型,我需要计算当前读数和上一个读数之间的时间间隔,即找到当前读数之前的最
我是一名优秀的程序员,十分优秀!