Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 278
Kiran Kumar D Avatar asked Aug 08 '12 09:08

Kiran Kumar D


2 Answers

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

like image 51
Anon Avatar answered Oct 03 '22 23:10

Anon


@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.)

like image 40
user1582362 Avatar answered Oct 03 '22 23:10

user1582362