Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property "type" of undefined #501

Open
orwant opened this issue May 9, 2015 · 14 comments
Open

Cannot read property "type" of undefined #501

orwant opened this issue May 9, 2015 · 14 comments

Comments

@orwant
Copy link
Collaborator

orwant commented May 9, 2015

What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
1. Same bug as issue 489


What component is this issue related to (PieChart, LineChart, DataTable,
Query, etc)?
LineChart, ColumnsChart, BarCharts

Are you using the test environment (version 1.1)?
(If you are not sure, answer NO)
tested with the 2 versions. 

What operating system and browser are you using?
IE7, IE8, Chrome (yeah!)

The message in IE : 

- "'undefined' a la valeur Null ou n'est pas un objet." with IE

The message in Chrome :

- "Cannot read property 'type' of undefined" with Chrome.

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Original issue reported on code.google.com by baptiste.jeangeorges on 2011-01-21 08:47:08

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015


I have ran both examples of zero/small value on IE and Chrome and haven't seen this
issue. Can you send a more concrete example or try to narrow down the problem?

Original issue reported on code.google.com by metula on 2011-01-21 08:53:35

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

There is my javascript : 

<script type="text/javascript"> 
google.load("visualization", "1", {packages:["corechart"]});
function drawChart() {
var data = new google.visualization.DataTable();
var raw_data = [['Average',18.333333333333332]];
var years = ['Test Exemple'];
data.addColumn('string', 'Year');
  for (var i = 0; i  < raw_data.length; ++i) {
    data.addColumn('number', raw_data[i][0]);
  }
  data.addRows(years.length);
 for (var j = 0; j < years.length; ++j) {
   data.setValue(j, 0, years[j].toString());
 }
 for (var i = 0; i  < raw_data.length; ++i) {
   for (var j = 1; j  < raw_data[i].length; ++j) {
    data.setValue(j-1, i+1, raw_data[i][j]);
  }
 }
var chart = new google.visualization.ColumnChart(document.getElementById('montantMoyen'));
chart.draw(data, {width: 430, height: 230,backgroundColor: {stroke:'black', strokeSize:
2},colors:[{color:'#99DCF9'}, {color:'#E6EF99'}, {color:'#EAB7B7'}, {color:'#B8DCB8'},
{color:'#D4B3F8'}],backgroundColor:'#FFFFFF',isStacked:false,legend:'bottom',hAxis:
{title:'',textColor:'black',titleColor:'black'},vAxis: {title:'',textColor:'black',titleColor:'black',minValue:-1,maxValue:-1,baselineColor:'black'},borderSize:3,fontSize:15,titleFontSize:15,tooltipFontSize:10,legendTextColor:'black',titleColor:'black',legendFontSize:10,
title: 'Montant moyen versé quotidiennement'});
  }
google.setOnLoadCallback(drawChart);
</script>

And in my html, i've got a 

<div id="montantMoyen"></div>

Everything works fine in Firefox

Original issue reported on code.google.com by baptiste.jeangeorges on 2011-01-21 09:03:15

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

Some news : 

Actually, we used the hack : 

    <script type="text/javascript">
        Array.prototype.reduce = undefined;
    </script>

Without it, it seems to work in a simple page but in a JSF context, it doesn't. 

Original issue reported on code.google.com by baptiste.jeangeorges on 2011-01-21 09:54:42

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015


I tried your example on FF, Chrome and IE and it seemed to work fine for me in all
three.
Is your example contain only this and still give you the errors?

Original issue reported on code.google.com by metula on 2011-01-21 09:55:37

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

We identify that the problem seems to be a conflict between a4j, google api visualization
and prototype... Which version of prototype did you use ? 

Original issue reported on code.google.com by baptiste.jeangeorges on 2011-01-21 10:24:48

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

Fixed, but we have to modify the richfaces package to include the good version of prototype...

Original issue reported on code.google.com by baptiste.jeangeorges on 2011-01-21 16:04:30

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

I had the same problem using Richfaces. I solved my problem by following the advice
of [1] and [2] and replacing the Array.prototype.reduce function using following code
fragment:

<script type="text/javascript">
Array.prototype.reduce=function(fun){var len=this.length>>>0;if(typeof fun!="function")throw
new TypeError;if(len==0&&arguments.length==1)throw new TypeError;var i=0;if(arguments.length>=2)var
rv=arguments[1];else{do{if(i in this){var rv=this[i++];break}if(++i>=len)throw new
TypeError;}while(true)}for(;i<len;i++)if(i in this)rv=fun.call(undefined,rv,this[i],i,this);return
rv}; 
</script>

[1] http://stackoverflow.com/questions/3732298/javascript-compatibility-in-ie
[2] https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce

Original issue reported on code.google.com by f.buelthoff on 2011-02-07 22:22:19

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

A column chart does not work on Chrome, IE nor FF, if one embeds it within a Richfaces
3-series generated page. As noted above, the problem seems to be the version of Prototype
included within Richfaces.

The workaround

    <script type="text/javascript">
        Array.prototype.reduce = undefined;
    </script>

fixes the issue on IE and FF, but not on Chrome. Have you been able to solve this problem?

Original issue reported on code.google.com by lauri.lehmijoki on 2011-03-23 13:02:05

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

I'm using column charts on pages generated using Richfaces 3.3.3 CR3. I can confirm
that my charts are rendering correctly on Firefox 4, IE 8 and Chrome 10.0.648.151 beta
when using workaround I described above (comment 7).

Original issue reported on code.google.com by frederik@buelthoff.name on 2011-03-23 14:57:50

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

The problems that may have applied to the Google Visualization API in the past in combination
with other JS libraries (or similar libraries) are likely to be different now. In any
event, the workaround of forcing Array.prototype.reduce to be undefined is bound to
cause problems, and indeed, your code is very likely to fail now.  Please don't do
this.

If other problems still exist, without this workaround, please do report.

Original issue reported on code.google.com by dlaliberte@google.com on 2013-08-28 20:16:27

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

I am having the same problem.When I ran the script in IE it displays "this.xf[a].c is
undefined" and in chrome it displays "Cannot read property '1' of undefined". I dont
know wat to do?i am just using <script type="text/javascript" src="https://www.google.com/jsapi"></script>and
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>.Please
do help me Please...

Original issue reported on code.google.com by sumiah4 on 2014-01-21 15:46:31

@orwant
Copy link
Collaborator Author

orwant commented May 9, 2015

Sumiah, in order to help you, we will have to see something like a more complete example.
 Your error seems unrelated to others posted in this thread, so it would be better
to start a new posting.

Original issue reported on code.google.com by dlaliberte@google.com on 2014-02-10 16:29:17

@MSafter
Copy link

MSafter commented Sep 7, 2015

I have had the same issue. The solution of this error/bug was for me, to remove any css styles which has changed the padding of the div where the chart is drawn.

@nkomgrit
Copy link

Organizational charts can not display on Google Chrome 48.0.2564.116 m, but it can display on Mozilla Firefox 39.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants