raphael-min.js:10错误: 属性d:预期数字,“M,0,0”
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了raphael-min.js:10错误: 属性d:预期数字,“M,0,0”相关的知识,希望对你有一定的参考价值。
我无法在morris js中绘制线图。下面是我的javascript代码,用于从datebase中检索数据,并在我的控制台日志中遇到此错误“raphael-min.js:10错误:属性d:预期数字,”M,0,0“。”
<script>
var balance = '<?php $connection = Yii::$app->getDb();$command =
$connection->createCommand("select count(*) as tally from
tbmessages_external where field3='310000' and
(datex>=TO_DATE(to_char('21-02-18 15:00:00'), 'dd-mm-yy hh24:mi:ss')
and datex<=TO_DATE(to_char('21-02-18 17:59:59'), 'dd-mm-yy
hh24:mi:ss'))");
serialize($command);?>';
console.log(balance);
var line = new Morris.Line({
element: 'bi-chart',
resize: true,
data: [
{ hours: '00:00', a: balance},
{ hours: '01:00', a: balance},
{ hours: '02:00', a: balance},
{ hours: '03:00', a: balance},
{ hours: '04:00', a: balance},
{ hours: '05:00', a: balance},
{ hours: '06:00', a: balance},
{ hours: '07:00', a: balance},
{ hours: '08:00', a: balance},
{ hours: '09:00', a: balance},
{ hours: '10:00', a: balance},
{ hours: '11:00', a: balance},
{ hours: '12:00', a: balance},
{ hours: '13:00', a: balance},
{ hours: '14:00', a: balance},
{ hours: '15:00', a: balance},
{ hours: '16:00', a: balance},
{ hours: '17:00', a: balance},
{ hours: '18:00', a: balance},
{ hours: '19:00', a: balance},
{ hours: '20:00', a: balance},
{ hours: '21:00', a: balance},
{ hours: '22:00', a: balance},
{ hours: '23:00', a: balance},
],
//data:balance,
xkey: 'hours',
ykeys: ['a'],
labels: ['BI'],
lineColors: ['#3c8dbc'],
hideHover: 'auto',
parseTime: false
});
答案
在你的PHP代码中你只是准备一个sql命令但不执行你应该添加 - > queryScalar();用于反转Count(*)数据(标量是第一行的第一列)
<script>
var balance = <?php $connection = Yii::$app->getDb();
$command = $connection->createCommand(
"select count(*) as tally
from tbmessages_external
where field3='310000'
and (datex >= TO_DATE(to_char('21-02-18 15:00:00'), 'dd-mm-yy hh24:mi:ss')
and datex<=TO_DATE(to_char('21-02-18 17:59:59'),
'dd-mm-yy hh24:mi:ss'))")->queryScalar();;
echo $command . ';' ;
?>';
以上是关于raphael-min.js:10错误: 属性d:预期数字,“M,0,0”的主要内容,如果未能解决你的问题,请参考以下文章
安装win10时出现错误代码,0x80070570 - 0x2000C
错误:<tspan> 属性 dy:预期长度,“NaN”。 |错误:<路径> 属性 d:预期数字,“M,0,0”。 |拉斐尔.js | Wheelnav.js