morris.js图表​​在生产服务器上不起作用 [英] morris.js chart doesn't work on production server

查看:135
本文介绍了morris.js图表​​在生产服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这张 morris.js 图表,该图表中填充了随机值(例如示例中提供的值)。尽管它可以完美地在 localhost 中呈现,但是一旦我在生产服务器上上传,它就不再起作用。

I have this morris.js chart which I populated with random values (the ones provided in the exemple). Whereas it renders perfectly in localhost, once I upload on the production server it no longer works.

JS代码

new Morris.Line({
        element: 'daily-chart',
        data: [
            { y: '2006', a: 100, b: 90 },
            { y: '2007', a: 75,  b: 65 },
            { y: '2008', a: 50,  b: 40 },
            { y: '2009', a: 75,  b: 65 },
            { y: '2010', a: 50,  b: 40 },
            { y: '2011', a: 75,  b: 65 },
            { y: '2012', a: 100, b: 90 }
        ],
        xkey: 'y',
        ykeys: ['a', 'b'],
        labels: ['Series A', 'Series B']
});

HTML代码

<div id="daily-chart" style="height: 350px; width: 1000px">

</div>



渲染



在Chrome中/ Opera

尽管宽度高度#daily-chart < div> 中设置时,尺寸设置不正确。我只看到图表的一部分,其余部分被隐藏了。尽管< div id = daily-chart style = height:350px; width:1000px>

Despite the width and height set up in the #daily-chart <div>, the dimensions are not set up properly. I only see one part of the chart, the rest being hidden. It's about 50px width despite of <div id="daily-chart" style="height: 350px; width: 1000px">.

在Firefox中

脚本忙或完全不响应。我收到以下消息:此页面上的脚本可能正忙,或者已停止响应。您可以立即停止脚本,也可以继续查看脚本是否将完成。选择 Continue | Stop脚本,浏览器将冻结。它指出该行是 1164 ,这是一段时间的条件:

The script gets busy or does not respond at all. I get the following message : A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete. with Continue|Stop script choices and the browser freezes. It states that the line is the 1164 which is a while condition :

while ((t = d.getTime()) <= dmax) { // <-- 1164 line
  if (t >= dmin) {
    ret.push([spec.fmt(d), t]);
  }
  spec.incr(d);
}

在控制台中没有任何错误,除非我停止获取脚本的地方,否则:

No errors in console or whatsoever except when I stop the script where I get :

Error: Script terminated by timeout at:
Morris.labelSeries@https://<url>/js/uncompressed/morris.js:1164:1
Morris.Line</Line.prototype.drawXAxis@https://<url>/js/uncompressed/morris.js:930:11
Morris.Line</Line.prototype.draw@https://<url>/js/uncompressed/morris.js:890:9
Morris.Grid</Grid.prototype.redraw@https://<url>/js/uncompressed/morris.js:472:9
Morris.Grid</Grid.prototype.setData@https://<url>/js/uncompressed/morris.js:338:9
Grid@https://<url>/js/uncompressed/morris.js:102:7
Line@https://<url>/js/uncompressed/morris.js:726:7
Line@https://<url>/js/uncompressed/morris.js:724:9
@https://<url>/<path/to/webpage>:1171:9



其他规格



生产服务器使用HTTPS协议和PHP版本(完全不相关),在dev和 5.4.30 上分别为 5.4.29 在产品上。据我所知,这是唯一的区别。

Other specs

The production server uses an HTTPS protocol and PHP version (don't think this is related at all) is 5.4.29 on dev and 5.4.30 on prod. As far as I know, these are the only differences.

是什么原因引起的?

推荐答案

查看此处:在Firefox中使用morris.js脚本不再回答任何错误

只需添加属性

parseTime: false

在创建时进入您的莫里斯图表。

to your Morris chart at creation time.

这篇关于morris.js图表​​在生产服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆