5

我正在使用 JqxPanel、JqxDocking 和 JqxChart。

JqxPanel 包含运行良好的停靠窗口。当我将 JqxChart 放入窗口时 Chrome 给出错误错误:标签处属性 height="-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

4 回答 4

10

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

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

希望这可以帮助

于 2012-11-20T13:55:51.677 回答
1

对我来说,情况确实如此,因为我将图表嵌入在页面加载时不可见的选项卡 div 中。当我将它移动到页面加载时可见的选项卡时,它可以工作。

于 2016-10-25T21:16:18.460 回答
1

@Anon,谢谢您的解决方案。我遇到了同样的问题,但使用“Raphael”框架(raphael-2.1.0.js)来绘制图表,错误消息与 OP 相同。删除父元素的最大宽度(css)解决了我的问题。

(这是作为解决方案发布的,因为需要 50 名声望才能向 Anon 的解决方案添加评论。)

于 2016-02-02T15:35:36.840 回答
0

所以我收到了这个错误,因为提供的数据与我seriesseriesGroups. 一些数据没有正确定义,所以当我第一次尝试绘制图表时,他们的代码不喜欢丢失的内容,并咳出了其中的几个错误。

此外,我想尝试使用新数据和新的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());
        }
于 2017-09-20T20:34:24.000 回答