【发布时间】:2018-02-28 17:58:57
【问题描述】:
我无法在 morris js 中绘制折线图。下面是我的 javascript 代码,用于从数据库中检索数据并在我的控制台日志“raphael-min.js:10 Error: attribute d: Expected number, “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
});
【问题讨论】:
标签: javascript php yii2 linechart morris.js