Open Side Menu Go to the Top

11-24-2013 , 07:59 PM
What group of people did you find that can be 43% male?

Actually, that graph looks pretty cool. Just not descriptive yet, which can be fixed.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
11-24-2013 , 08:26 PM
Quote:
Originally Posted by daveT
What group of people did you find that can be 43% male?
The points in this case are not people but consumer products. The goal of the visualization is to study how products are related based on the demographics of the people who purchase them. I'm using a similar technique for other variables besides just gender and age, too.

Quote:
Originally Posted by daveT
Actually, that graph looks pretty cool. Just not descriptive yet, which can be fixed.
Thanks, I'd love to hear any and all suggestions.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2013 , 08:31 PM
Quote:
Originally Posted by Urinal Mint
How about JSFiddle?

(I'm not sure how to make the buttons work on JSFiddle.)
here's a refactoring that answers your question:
http://jsfiddle.net/sMg39/

I only touched that one part you were interested in with the labels. The rest of the could be cleaned up similarly and you could probably cut it down by 50% or so. In general, with d3, if you are ever looping you know you are doing it wrong. The whole thing is designed to let you think in terms of selections, rather than individual elements you loop through. Even my refactoring can be made much better by replacing the forEach loop, but I'd have to spend a bit more time to remember how.

EDIT: So I think what you want to do to avoid even the forEach I have, is have all your dots be "g" elements instead, which start by containing a dot. Then you can just append the text label to the g, and the whole thing becomes one big chain command.

Last edited by gaming_mouse; 11-24-2013 at 08:43 PM. Reason: Updated to keep your check so labels dont get added twice
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2013 , 10:39 PM
Quote:
Originally Posted by gaming_mouse
In general, with d3, if you are ever looping you know you are doing it wrong. The whole thing is designed to let you think in terms of selections, rather than individual elements you loop through.
What's the primary means through which to think in terms of selections? I've used the "select" and "selectAll" methods in their most primitive way, but not combined with filters.

Does the bit of code "selectedCircles[0]" take advantage of the structure of selections? I should learn more about how those work.

Quote:
Originally Posted by gaming_mouse
Then you can just append the text label to the g, and the whole thing becomes one big chain command.
Would you create two groups, one for the circle elements and one for the text elements?

Thanks for the help. Thinking in selections is cool, but a bit counter-intuitive at first. Mainly I need to learn the means through which to think selectively.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2013 , 11:09 PM
I refuse to ever read anything in a "what's new" overlay out of principle. The creative types at my work are absolutely addicted to them.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 12:40 AM
I generally figure that
Quote:
what's new
roughly translate to

Quote:
we added these 4 features, but expect to run into 400 bugs that make your life hell, you can't do crap about, and we don't have time to fix.

Have a Happy Thanksgiving!
Company X

PS: That one feature you loved? Yeah, we removed it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 03:46 AM
Quote:
Originally Posted by Urinal Mint
What's the primary means through which to think in terms of selections? I've used the "select" and "selectAll" methods in their most primitive way, but not combined with filters.
What I meant is that if you want something to happen to a certain set of something, you should just create a selection to represent that set, then apply styles, or classes, or appends, or whatever, to that set. d3 abstracts away the concept of looping, you just do stuff to selections, which you can think of as a unit, and d3 makes sure that it happens to everything in the selection.

Quote:
Does the bit of code "selectedCircles[0]" take advantage of the structure of selections? I should learn more about how those work.
I'd say that bit of code was a wart, in that I'm relying on internal details of how selections work. But it's useful to understand them if you're going to be working with d3. This is a great article by d3's author: http://bost.ocks.org/mike/selection/

Quote:
Would you create two groups, one for the circle elements and one for the text elements?
The "g" element would be a container element, and each one would hold a circle and a label for that circle.

Alternatively, or additionally, you should consider creating all the labels and circles at once (you could do this with or without containing "g" elments) and then the search selection is just a matter of applying a class to the matching elements. That is, everything has a class that makes circles black and labels invisible to start. Then you do a selection to get matching elements, as I did in the fiddle, and simply use d3's selection.classed() method to change how they look: ie, turn them red and show the label. This greatly shortens and clarifies your method.

Quote:
Thanks for the help. Thinking in selections is cool, but a bit counter-intuitive at first. Mainly I need to learn the means through which to think selectively.
That link should help, and there are a number of good tutorials on d3 around, many of which focus on that. Just remember: If you ever find yourself manually looping, stop and look for a solution that uses just selections.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 01:02 PM
Is it me, or do Software companies have an extreme love of Movember?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 01:09 PM
Probably just correlated to them having a disproportionate number of young men.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 01:37 PM
i live in san francisco; every month is movember.

Last edited by tyler_cracker; 11-25-2013 at 01:38 PM. Reason: well i mean there's mocember, moptember, mougust, moly, ...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 02:54 PM
WTF is a movember?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 02:58 PM
You haven't noticed extra facial hair at the office? Do you work in an office?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 09:42 PM
clown lives and works in an ivory tower. disorder such as facial hair is not tolerated.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 10:01 PM
After the full month I finally look respectably homeless.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 10:13 PM
Quote:
Originally Posted by tyler_cracker
clown lives and works in an ivory tower. disorder such as facial hair is not tolerated.
I would have assumed the opposite end of the spectrum. Clown works in an ivory tower and social niceties such as showering and shaving aren't worth their time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2013 , 10:32 PM
I work for Jewish people. Facial hair is nearly required at my job.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 12:03 AM
Quote:
Originally Posted by kerowo
After the full month I finally look respectably homeless.

Pics
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 12:08 AM
Quote:
Originally Posted by jjshabado
I would have assumed the opposite end of the spectrum. Clown works in an ivory tower and social niceties such as showering and shaving aren't worth their time.
Pretty much this.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 12:32 AM
Quote:
Originally Posted by jjshabado
I would have assumed the opposite end of the spectrum. Clown works in an ivory tower and social niceties such as showering and shaving aren't worth their time.
Quote:
Originally Posted by alex23
Pretty much this.
europe tho[1]



Quote:
Originally Posted by kerowo
After the full month I finally look respectably homeless.
Quote:
Originally Posted by LirvA
Pics
++



[1] i think this means ++shaving --showering but i'll admit that we're reaching the limits of my mental models for phd programs and european stereotypes
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 06:23 AM
Quote:
Originally Posted by tyler_cracker
clown lives and works in an ivory tower. disorder such as facial hair is not tolerated.
Nah the admin next door looks very much like an old-school Unix admin

Regarding shaving...I'm a bit of a nut there. Got a nice silvertip badger brush and whip up my own shaving cream (Taylor of Old Bond Street ftw) and use pre/post stuff (+stainless steel double edged safety razor with Israely blades)

Last edited by clowntable; 11-26-2013 at 06:29 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 07:18 AM
Quote:
Originally Posted by clowntable
Nah the admin next door looks very much like an old-school Unix admin

Regarding shaving...I'm a bit of a nut there. Got a nice silvertip badger brush and whip up my own shaving cream (Taylor of Old Bond Street ftw) and use pre/post stuff (+stainless steel double edged safety razor with Israely blades)
have you used feather blades? i really like those.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 11:53 AM
Mouse, thanks for the explanation. Looping felt wrong; now I know why!

What is the best way to "export" JSON data from javascript code to use elsewhere?

For example, if I have a dictionary in Python and I want to use the data, I can easily write the dictionary to a file to access it elsewhere.

I have a big JSON variable in javascript, and during execution it is parsed into a smaller variable which I want to save to use later. I tried to console.log(parsedJSONvariable), but that doesn't seem to allow for easy data accessibility, i.e. I can't copy and paste the new JSON variable's data to save and use elsewhere.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 12:15 PM
HTML5's local storage may be what you want
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 12:34 PM
Thanks. If the storage can be accessed outside of javascript it's exactly what I want.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2013 , 12:55 PM
localstorage is not, as far as I'm aware, available outside the browser.

I'm not sure what your use case is. You want it to be accessible outside of the browser on the machine where the browser runs? Or on the server side for a web application? If the former, I don't think it's easy to do, if it's possible, because the browser security model does not want to let random javascript write files on the machine. If the latter, you can just do an AJAX post to your server and send it the json string and it can do whatever.

I suppose the other other case is something with node.js in which case I'm sure there are like db backends for that, but given that you were trying console.log() I'm imagining this is javascript running in a browser on an enduser machine
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m