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

Magic number can kill radar.js #8

Closed
AndreasPrang opened this issue Aug 30, 2016 · 5 comments
Closed

Magic number can kill radar.js #8

AndreasPrang opened this issue Aug 30, 2016 · 5 comments

Comments

@AndreasPrang
Copy link
Contributor

The bug is in radar.js: 117

var itemsByStage = _.groupBy(radar_data[i].items, function(item) { return Math.floor(item.pc.r / 100) });

With the magic number 100 itemsByStage can be something like this:

{
0 : [...],
2 : [...],
3 : [...]
}

So the JS throws an exception on

offsetIndex = offsetIndex + itemsByStage[stageIndex-1].length + 1;

In my case it worked with the "magic number" 150.

@jackunion
Copy link

jackunion commented Sep 12, 2016

@AndreasPrang
I think it works exactly as intended.
Iterating through an array with for..in is odd, sure, but still works as intended.

@AndreasPrang
Copy link
Contributor Author

It's not working with our data, because the index 1 is missing. Give it a try:
radar_data.js

@jackunion
Copy link

jackunion commented Sep 12, 2016

Ah, I see. It's not the magic number that causes the problem anyway.

Need help with the fix?

@AndreasPrang
Copy link
Contributor Author

would be nice ;-)

@jackunion
Copy link

Quick solution off the top of my head. Lines 120 through 126.

Looks something like this.

I'd say that getting rid of underscore altogether and treating Objects like Objects and not Arrays would be much more elegant, but I tried to change as little as possible.

One note: you have more items in "Techniques..." section, so in your own radar-data.js file you have to manually increase "Platforms & Infrastructure" quadrant's top value ((h/2 + 170) works fine for me).

Hope this helps, feel free to ping me if something doesn't work : )

@tlossen tlossen closed this as completed Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants