-
28 Nov 2011 1:51 AM #1
Unanswered: RadarAxis drawAxis method
Unanswered: RadarAxis drawAxis method
Hello,
I have a radar chart that I've integrated inside the portal example.
When the chart gets rendered I noticed in firebug an error: "sprites[i + j] is undefined".
I've debugged the application and I saw that j is undefined in the method: the only reference to it is a declaration on line 44054, but it is used on line 44101 on the store.each function.
What is the logic behind using the j variable?
-
28 Nov 2011 1:57 AM #2Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
Can you post a small code sample?
-
28 Nov 2011 2:02 AM #3
Code sample
Code sample
The problem appears on store.each(function(rec, j)) method body.Code:for (i = 0; i < steps; i++) { sprites[i].setAttributes({ x: centerX, y: centerY, radius: Math.max(rho * (i + 1) / steps, 0), stroke: '#ccc' }, true); } store.each(function(rec, j) { sprites[i + j].setAttributes({ path: ['M', centerX, centerY, 'L', centerX + rho * cos(j / l * pi2), centerY + rho * sin(j / l * pi2), 'Z'], stroke: '#ccc' }, true); });
j is undefined here.
-
28 Nov 2011 2:10 AM #4Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
Are you shure that i isnt undefined instead of j?
Firebug can be misleading somethimes.
And what is Store, an Ext Array? Can you give its definition.
-
28 Nov 2011 2:15 AM #5
store is a reference to the attached Store of the view. It contains data that gets displayed in the chart.
i can't be undefined as its value is set in the for structure. j is undefined as it is not manipulated anywhere inside the body of the function(drawAxis).
-
28 Nov 2011 2:27 AM #6Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
If it is out of scope then it can be undefined. But ok.
its possible that the each function on the store only has one input param. Store.data had three.
So try
Code:store.data.each(function(rec, j) { sprites[i + j].setAttributes({ path: ['M', centerX, centerY, 'L', centerX + rho * cos(j / l * pi2), centerY + rho * sin(j / l * pi2), 'Z'], stroke: '#ccc' }, true); });
-
28 Nov 2011 3:57 AM #7
I think that there might be another issue.
I am really new to javascript so if I write something stupid bellow pardon me :P.
After debugging again the script I noticed the following:
- sprites has 10 items.
- steps in the for structure is equal to 10.
- after completing the for loop i is also 10
- j is undefined. If in javascript we add i + undefined, will that be equal to i?. Say for the sake of argument that it is equal to i, then the error is caused by an index out of bounds as there is no sprites[10].
What now?
-
28 Nov 2011 5:09 AM #8Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
yes, i ends up with the value of steps


Reply With Quote