JqxChart Giving error错误:<rect>属性height =“ - 1”</rect>的负值无效

时间:2012-08-08 09:58:27

标签: javascript jquery

使用JqxPanel,JqxDocking和JqxChart。

JqxPanel包含正常工作的Docking窗口。当我以前把JqxChart放到一个窗口Chrome时给出错误错误:属性高度的负值=“ - 1”(重复2次)无效的标签

请有人在这方面帮助我

JavaScript deviceschart.js

var DevicesgenerateData = function () {
            var devicedata = new Array();
            var deviceNames =
            [
            "Working", "GPS Antenna","Power Removed","SIM Problem","Servicing","Damaged"
            ];
            var deviceNos =
            [
            10,10,30,10,20,20
            ];

            for (var i = 0; i < 6; i++) {
                var devicerow = {};

                devicerow["devicenames"] = deviceNames[i];
                devicerow["devicenos"] = deviceNos[i];
                devicedata[i] = devicerow;
            }
            return devicedata;
             }

       var devicesource =
        {
            localdata: DevicesgenerateData(),
                datafields: [
                { name: 'devicenames' },
                { name: 'devicenos' }
            ], 
            datatype: "array"

        };


        var ddataAdapter = new $.jqx.dataAdapter(devicesource);
            //, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } });
            //$('#jqxChart').jqxChart({borderColor: 'Blue'});

        // prepare jqxChart settings
        var devicesettings = {
            //title: "Mobile browsers share in Dec 2011",
           // description: "(source: wikipedia.org)",
            enableAnimations: true,
                borderColor: 'Red',
            showLegend: true,
            legendLayout: { left: 210, top: 50, width: 100, height: 200, flow: 'vertical' },
            padding: { left: 5, top: 5, right: 5, bottom: 5 },
            titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
            source: ddataAdapter,
            colorScheme: 'scheme02',
            seriesGroups:
                [
                    {
                        type: 'pie',
                        showLabels: true,
                        series:
                            [
                                { 
                                    dataField: 'devicenos',
                                    displayText: 'devicenames',
                                    labelRadius: 70,
                                    initialAngle: 15,
                                    radius: 95,
                                    centerOffset: 0,
                                    formatSettings: { sufix: '%', decimalPlaces: 1 }
                                }
                            ]
                    }
                ]
        };



         <link rel="stylesheet" href="css/jqx.base.css" type="text/css" />

        <script type="text/javascript" src="js/gettheme.js"></script>
        <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="js/jqxcore.js"></script>
        <script type="text/javascript" src="js/jqxscrollbar.js"></script>
        <script type="text/javascript" src="js/jqxbuttons.js"></script>
        <script type="text/javascript" src="js/jqxpanel.js"></script>
        <script type="text/javascript" src="js/jqxwindow.js"></script>
       <script type="text/javascript" src="js/jquery.global.js"></script>
        <script type="text/javascript" src="js/jqxdocking.js"></script>
        <script type="text/javascript" src="js/jqxsplitter.js"></script>

        <script type="text/javascript" src="js/jqxchart.js"></script>
        <script type="text/javascript" src="js/jqxdata.js"></script>

         <script type="text/javascript" src="js/deviceschart.js"></script>




        <script type="text/javascript">
            $(document).ready(function () {
                // Create jqxPanel
                var theme = getTheme();
                $("#panel").jqxPanel({ width: "100%", height: 350, theme: theme });


                $('#maindocking').jqxDocking({ theme: theme, orientation: 'horizontal', width: 990, mode: 'docked' });
                $('#maindocking').jqxDocking('disableWindowResize', 'window1');
                $('#maindocking').jqxDocking('disableWindowResize', 'window2');
                $('#maindocking').jqxDocking('disableWindowResize', 'window3');
                $('#maindocking').jqxDocking('disableWindowResize', 'window4');
                $('#maindocking').jqxDocking('disableWindowResize', 'window5');
                $('#maindocking').jqxDocking('disableWindowResize', 'window6');
        $('#jqxChart').jqxChart(devicesettings);

            });
        </script>
    </head>


    <body class='default'>
        <div id='panel' style=" font-size: 13px; font-family: Verdana;">

          <div id="maindocking">
            <div id="column1docking">
                <div id="window1" style="height: 200px;">
                   <div>Vehicle Information</div>
                        <div style="overflow: hidden;">
                            <div id="jqxChart"></div>   
                        </div>

                </div><!-- window1--->
                  <div id="window2" style="height: 200px;">
                   <div>Vehicle Information</div>
                        <div style="overflow: hidden;">

                        </div>

                </div><!-- window2--->

             </div><!-- Column1 Docking-->

             <div id="column2docking">
                <div id="window3" style="height: 200px;">
                   <div>Vehicle Information</div>
                        <div style="overflow: hidden;">

                        </div>

                </div><!-- window3--->
                  <div id="window4" style="height: 200px;">
                   <div>Vehicle Information</div>
                        <div style="overflow: hidden;">

                        </div>

                </div><!-- window4--->

             </div><!-- Column2 Docking-->

           <div id="column3docking">
                <div id="window5" style="height: 200px;">
                   <div>Vehicle Information</div>
                        <div style="overflow: hidden;">

                        </div>

                </div><!-- window5--->
                  <div id="window6" style="height: 200px;">
                   <div>Vehicle Information</div>
                        <div style="overflow: hidden;">

                        </div>

                </div><!-- window6--->

             </div><!-- Column3 Docking-->


          </div> <!-- MainDocking -->
        </div> <!-- Panel -->
        </body>

4 个答案:

答案 0 :(得分:10)

我有同样的问题,我通过将包含div的宽度设置得足够大以包含指定设置的图表来解决它。

<div id="jqxChart" style="width:680px; height:400px; vertical-align: top;  display: inline-block; padding: 10px;">

希望这有帮助

答案 1 :(得分:1)

答案 2 :(得分:1)

对我而言,事实证明是这样的,因为我将图表嵌入到页面加载中不可见的制表符div中。当我将其移动到页面加载时可见的标签时,它可以正常工作。

答案 3 :(得分:0)

所以我收到此错误是因为提供的数据与series中的seriesGroups不完全匹配。有些数据没有正确定义,所以当我第一次尝试绘制图表时,他们的代码不喜欢丢失的内容并咳出其中一些错误。

此外,我想尝试使用新数据和新seriesGroups更新我的图表。在进行类似的更改时,我必须在更改其他数据之前调用jqxChart并更新seriesGroups

        if (chartTableArea.jqxChart("isInitialized") === true) {
            if (gSettings === undefined || gSettings.title === undefined) {
                gSettings = getSettings(); //sets up the gSettings
            }
            chartTableArea.jqxChart({ seriesGroups: gSettings.seriesGroups });
            chartTableArea.jqxChart(gSettings);
        } else {
            //not initialized
            chartTableArea.jqxChart(getSettings());
        }