简体   繁体   中英

JqxChart Giving error Error: Invalid negative value for <rect> attribute height=“-1”

Am using JqxPanel, JqxDocking and JqxChart.

JqxPanel consists Docking windows which are working fine. when i used to place JqxChart into a window Chrome giving error Error: Invalid negative value for attribute height="-1" (repated 2 times) at tag

Please some one can help me in this regard

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>

I had the same issue , I solved it by setting the width of the containing div to be large enough to contain the chart given the settings specified .

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

Hope this helps

@Anon, Thank you for that solution. I had the same issue, but with "Raphael" framework (raphael-2.1.0.js) for drawing charts, with the same error messages as OP. Removing the max-width (css) of a parent element solved my issue.

(This was posted as solution because 50 reputation was required to add a comment to Anon's solution.)

For me this turned out to be the case because I embedded the chart in a tab div that wasn't visible on page load. When I move it to a tab that's visible on page load it works.

So I was getting this error because the data that was supplied did not entirely match my series in the seriesGroups . Some of the data was not defined correctly so when I first tried drawing the chart their code didn't like what was missing and coughed up several of these errors.

Further, I wanted to try to update my chart using new data and new seriesGroups . In making a change like that I have to call jqxChart and update the seriesGroups before changing other data.

        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());
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM