我在 morris.js 图形库上有一个奇怪的错误
这适用于graphs.js
$(document).ready(function() {
Morris.Line({
element: 'annual',
data: [
{y: '2012', a: 100},
{y: '2011', a: 75},
{y: '2010', a: 50},
{y: '2009', a: 75},
{y: '2008', a: 50},
{y: '2007', a: 75},
{y: '2006', a: 100}
],
xkey: 'y',
ykeys: ['a'],
labels: ['Series A']
});
})
这不是 graphs.js
$(document).ready(function() {
Morris.Line({
element: 'annual',
data: $('#logs_chart').data('logs'),
xkey: 'y',
ykeys: ['a'],
labels: ['Series A']
});
})
在相应的html中
<div data-logs="[
{y: '2012', a: 100},
{y: '2011', a: 75},
{y: '2010', a: 50},
{y: '2009', a: 75},
{y: '2008', a: 50},
{y: '2007', a: 75},
{y: '2006', a: 100}
]" id="logs_chart"></div>
我明白了
Uncaught TypeError: Cannot call method 'match' of undefined morris.js:316
Morris.parseDate = function(date) {
var isecs, m, msecs, n, o, offsetmins, p, q, r, ret, secs;
if (typeof date === 'number') {
return date;
}
m = date.match(/^(\d+) Q(\d)$/);
Uncaught TypeError: Cannot call method 'match' of undefined
n = date.match(/^(\d+)-(\d+)$/);
有人遇到过这种情况并找到解决方案吗?