EduardoDominguez / dwpe

Automatically exported from code.google.com/p/dwpe
MIT License
0 stars 0 forks source link

Error when visualizing a table with only "0" values #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I created a table with one row containing headers and one row containing
containing the values. It may be the case that all these values are 0
depending on the users input. The plugin creates the markup and then
triggers the an error, so that any follow up code won't be executed.

Firebug displays the following error:

An invalid or illegal string was specified" code: "12

And the following stack trace:

getText([td 0=td context=td  length=1 jquery=1.4.1])jquery-1.4.1.js (line 3315)
anonymous(Object name=text)jquery-1.4.1.js (line 3899)
anonymous()visualiz...jquery.js (line 52)
anonymous([td, td, td, 11 more... prevObject=[1] context=tr selector=td
0=td 1=td 2=td], function(), Object name=args)jquery-1.4.1.js (line 572)
anonymous(function(), Object name=args)jquery-1.4.1.js (line 240)
anonymous(Object name=i value=0)visualiz...jquery.js (line 51)
anonymous([tr prevObject=[1] context=table selector=tr:gt(0) 0=tr],
function(), Object name=args)jquery-1.4.1.js (line 572)
anonymous(function(), Object name=args)jquery-1.4.1.js (line 240)
anonymous()visualiz...jquery.js (line 46)
anonymous()visualiz...jquery.js (line 72)
anonymous()visualiz...jquery.js (line 95)
anonymous()visualiz...jquery.js (line 141)
anonymous()visualiz...jquery.js (line 401)
anonymous([table selector=#diagram > table context=document 0=table],
scrapeTable(), Object name=args)jquery-1.4.1.js (line 572)
anonymous(scrapeTable(), Object name=args)jquery-1.4.1.js (line 240)
anonymous(Object type=area height=200 appendKey=false, Object
name=container)visualiz...jquery.js (line 11)
anonymous()statistic.js (line 8)
anonymous()jquery-1.4.1.js (line 387)
anonymous()jquery-1.4.1.js (line 736)

The error occured in Firefox 3.6 on Windows XP.

Original issue reported on code.google.com by froschla...@googlemail.com on 1 Apr 2010 at 3:16

GoogleCodeExporter commented 8 years ago

Original comment by fg.mag...@gmail.com on 8 Apr 2010 at 9:21

GoogleCodeExporter commented 8 years ago
Insert this code after 286 line:
/**                 
* This checking is important if all of the data value in the table is 0.                    
*/                  
if(typeof(points[0]) == 'undefined' && points[0] == null) {                     
points[0]=0;                    
}                   
if(!isFinite(yScale)) yScale=0;                                     

Then try to find this row:
var zeroLoc = o.height * (topValue/totalYRange);

And insert this:
/**     
* This checking is important if all of the data value in the table is 0.        
*/      
if((typeof(zeroLoc) == 'undefined' && zeroLoc == null) || isNaN(zeroLoc)) {         
zeroLoc = 0;        
}       

Br,
Tamas

Original comment by tamas....@eldanor.hu on 16 Apr 2010 at 3:38

GoogleCodeExporter commented 8 years ago
Hello! Great plugin. But I'll have a use case that initially all tables are 
filled with 0 values. I tried to make changes to the code as mentioned above 
but still get this error in firebug:

An invalid or illegal string was specified" code: "12
[Break On This Error] ctx.translate(0,zeroLoc);

Any ideas? Thanks, Sev

Original comment by ego...@gmail.com on 5 Jan 2011 at 11:28

GoogleCodeExporter commented 8 years ago
i just tried the suggestion above and it worked great. I originally put the 
first section of code at line 286 as suggested, but it didn't work. put it 
between the "var integer = 0;" and the "ctx.moveTo(0,-(points[0]*yScale));" 
lines.

*** 289,294 ****
--- 289,301 ----
                                        ctx.lineJoin = 'round';
                                        var points = this.points;
                                        var integer = 0;
+                                       /**
+                                       * This checking is important if all of 
the data value in the table is 0.
+                                       */
+                                       if(typeof(points[0]) == 'undefined' && 
points[0] == null) {
+                                       points[0]=0;
+                                       }
+                                       if(!isFinite(yScale)) yScale=0;
                                        ctx.moveTo(0,-(points[0]*yScale));
                                        $.each(points, function(){
                                                ctx.lineTo(integer,-(this*yScale));
***************
*** 404,409 ****
--- 411,422 ----
                var memberTotals = tableData.memberTotals();
                var totalYRange = tableData.totalYRange();
                var zeroLoc = o.height * (topValue/totalYRange);
+               /**
+               * This checking is important if all of the data value in the 
table is 0.
+               */
+               if((typeof(zeroLoc) == 'undefined' && zeroLoc == null) || 
isNaN(zeroLoc)) {
+                       zeroLoc = 0;
+               }
                var xLabels = tableData.xLabels();
                var yLabels = tableData.yLabels();

Original comment by anthony%...@gtempaccount.com on 10 Jan 2011 at 4:11

GoogleCodeExporter commented 8 years ago
Thanks for your input. This worked for me! No more errors :)

Regards,
sev

Original comment by ego...@gmail.com on 10 Jan 2011 at 9:34

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I got the same problem in Firefox 3.6.13 on Windows Vista. I only have 1 set of 
data, I'm trying to show 1 line in my line diagram and this crashes the code on 
line 284, it says 

An invalid or illegal string was specified" code: "12
ctx.translate(0,zeroLoc);

As previously stated. But the problem is that my chart is completely empty, no 
line shows up at all. If I use the hack previously posted in this thread I get 
rid of the error, but my chart is still empty. It works in Chrome, Safari and 
IE8. Any suggestions?

Original comment by stefanko...@gmail.com on 17 Feb 2011 at 8:42

GoogleCodeExporter commented 8 years ago
@stefanko Use jquery 1.4.2 and it will probably work. At least it does for me. 
Any higher than that results in an empty graph area. No graph and not even the 
grid lines will show.

Original comment by citsdoti...@gmail.com on 8 Apr 2011 at 1:55

GoogleCodeExporter commented 8 years ago
Yes, http://code.google.com/p/dwpe/issues/detail?id=12#c4 worked perfectly. 
Thanks

Original comment by alex.joh...@gmail.com on 9 Jun 2011 at 12:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have tried above comment#4. It doesn't work in IE browser 

Original comment by nighthaw...@gmail.com on 25 Jul 2011 at 7:36

Attachments:

GoogleCodeExporter commented 8 years ago
I have the same problem, shows zeros but only shows the table caption.
I added the following lines:

        //get title for chart
        var title = o.title || self.find('caption').text();

        alert('o title ' + o.title);
        alert('selft caption ' + self.find('caption').text());

And there's something interesting, o is NULL .... author please comment !!
I'm using IE 8 and IIS 7 server on windows7.

Original comment by fernando...@gmail.com on 9 Nov 2012 at 4:19

GoogleCodeExporter commented 8 years ago
Ok I did this fix to the visualize .js:
Eliminated all .filter(o.colFilter) and .filter(o.rowFilter) from the script 
and graphic is now working good..

Original comment by fernando...@gmail.com on 9 Nov 2012 at 2:19