Initializing Highstock.js throws a jQuery error in getComputedStyle

孤街醉人 提交于 2020-01-14 10:19:06

问题


I've been able to get Highstock to work in a sample html file, but in the application I'm working on, the same Highstock code loads part ways and then throws an error: "elem.ownerDocument is undefined" around line 5950 of the unminified code of jQuery 1.5.1 (the getComputedStyle function).

After some console logs, I discovered that the elem that throws the error is in fact a Highstock object and not a DOM element.

I also discovered that the jQuery function in question doesn't even get called when running the simple sample page.

What could I be missing? Some CSS craziness? Why would it even be calling that function?

JS Code:

<script type="text/javascript">
var chart123;
$(document).ready(function(){
   chart123 = new Highcharts.StockChart({
                 chart: {
                    renderTo: 'chartcontainer'
                 },
                 rangeSelector: {
                    selected: 1
                 },
                 series: [{
                    name: 'USD to EUR',
                    data: [[6000000, 2], [50000000, 5]] // predefined JavaScript array
                 }]
            });
});
</script>

HTML Code:

<div id="workspace-content">
    <div id="chartcontainer" style=" height: 400px"></div>
</div>

Let me stress again that the same exact code works in a bare page that uses the same jQuery file.


回答1:


were you using flot in your previous application?




回答2:


You saved me a lot of trouble. I was pulling my hair out (whatever is left of it) trying to figure this out. Same as you I had no idea that jquery.flot was included in the application. Thanks a bunch.




回答3:


We use Smartadmin that includes jquery-resize.js. Change loopy() to only process the element "if (elem.ownerDocument)". This is necessary for Highcharts or SVG items.

This is another answer for the same error with a different root cause. I only place this here in hopes it saves someone time debugging.



来源:https://stackoverflow.com/questions/8333228/initializing-highstock-js-throws-a-jquery-error-in-getcomputedstyle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!