Placeholder Image

字幕表 動画を再生する

  • Hello.

  • We're here.

  • We're live.

  • Yes, we're back.

  • Surprise.

  • This is one of those rare occasions where a coding train episode is planned within, like, 15 minutes.

  • That's not entirely true.

  • Because surely welcome again to surely guest from last Friday's regularly scheduled Nothing nothing has ever regularly scheduled.

  • But somewhat consistently on Fridays, I have been live streaming and we mostly surely, but I'll say we since I was also here.

  • Uh uh, did a tutorial around working with D three Js for data visualization, and it was completely my fault that I arrived.

  • Sure related Rush rush.

  • So there was very little time.

  • Uh, I'm just checking the chat.

  • Make sure nobody's saying focus alert.

  • I will focus the camera.

  • I forgot to focus the camera.

  • So we're saw a soft focus.

  • I look nice.

  • Um, so we rushed through a lot of stuff and I felt like that wasn't fair to surely on dhe.

  • So here we are, back surely generously had an extra little bit extra time today.

  • Shirley's here, actually, at I t p doing a fellowship, working on a bunch of really go to her social media and see, you're making all these like physical?

  • Yes.

  • Talk about that for a minute.

  • Why focus the camera?

  • Yes.

  • Okay.

  • So I don't know how to talk about this without any visual aid.

  • Oh, actually, I couldn't have visual aid, right?

  • I could open up a browser.

  • Yeah, I'm which you have hit in the way.

  • So it's on the dock is on the left side.

  • I'll just do this.

  • Who?

  • Look at all these things that showed up.

  • Okay.

  • Like what?

  • Oh, did laptops not actually on screen.

  • I know.

  • It's fine.

  • It will be now in a second.

  • Okay, So I'm I'm I tiki because usually I do data visualization in the web, so it's very I'm very digital, but I've been wanting Thio.

  • I'm kind of brought in my horizons and get more into the physical world.

  • So I've been auditing two of the classes here on one has to do with, like, are doing news and sensors.

  • And the other one, I'm like, screaming all of my media.

  • It's, like, kind of basic, and, uh, the other one has to do with fabrication.

  • So I'm doing two projects.

  • One final project with the students I'm and it's gonna be a physical data visualization of I'm women in Computing is really excited.

  • This is the one with the laser cut.

  • No, no, no.

  • This is the one.

  • I'm that we're still prototyping, so it's gonna be like an actual installation.

  • You walk through on and there's gonna be hanging lights, um, and it's going to be hanging like orbs.

  • And then the idea is that as you walk through the orbs, each of them are represent a woman that had a great contribution in computing.

  • Um, but the thing is that most of them we don't know about most of them.

  • So at the beginning of the installation, they're all going to start out really dim because they're they're not very well known.

  • And as people go through their invited to kind of like I'm seeing or kind of interact what they read more about the woman.

  • And there's gonna be details in the or And every time someone reads more about them, they grow glow brighter and a little bit brighter and a little bit brighter.

  • And the hope is that by the end of the exhibit, like all of them will be lit up a lot more beautiful.

  • Yeah.

  • And then so as you walk through, I'm so there's a lot of, like, kind of data and coat into it.

  • So it's gonna be my first, like, kind of big data installation that, like people can actually walk through.

  • So that's the one I've been working on.

  • That's what this tilt switch is for that I was playing with because then when someone interacts with I'm so I don't know if you can see, but yeah, I'm like, as that's which is being tilted.

  • I'm the l e d lights up s Oh, that's gonna be how we control.

  • Like when someone interacts with the order.

  • That's how we sense that they're like, interacting with it.

  • I'm so that one that you saw with the laser.

  • Oh, so this is kind of the prototyping for that.

  • Like reforms for the orbs.

  • Yeah.

  • Like mysterious old.

  • Like she's so cool.

  • She is a prolific inventor and co founder and CEO.

  • One laptop per child.

  • I am, but yeah, and then the other one you saw is on.

  • This was one, right.

  • Okay.

  • And this is just for fabrication homework where I wanted Thio.

  • And these are some of the women noble Laureates and this is this is a prototype base, but I'm The idea is to light.

  • The led is from the bottom are sorry.

  • Like the crystals from the bottom.

  • I'm and so this is kind of the latest iteration I was working on yesterday.

  • So, like, then I'm they're color coded by the category of their award.

  • And as and so I'm gonna put the crystals on top of the lights and then it's gonna glow the different colors.

  • This is great.

  • So it's so fun to see because, you know, I'm somewhat of I would say, like an anomaly here, but so many people at this program at I, t.

  • P and I am a work it with physical computing and fabrication and building physical devices, making three dimensional objects that live in the real world.

  • And I kind of fall back to my safe, happy place of software, which has its own problems and complexities.

  • But it's great to see I know that you have done so much work with data visualization on screen and the browser d three.

  • That's what we're talking about.

  • What we talked about it Friday we're talking about today, so it's really I find it always exciting to see people move into, like to, like break through that What could be scary, like Thio and like start to make physical stuff.

  • But it's been such like a friendly, supportive environment like I realized, like how deeply I am in software.

  • So much so that, like even the most obvious physical things I don't see like you.

  • Earlier today I was talking to one of the residents and I was like, Oh, I need to build in the switch and he's like, No, just unplug it and I'm like, Oh, like I was sorry.

  • I was I was plugging like like a battery into an art studio.

  • And I'm like, Oh, now I should build a switch to, like, control on and off And he's like, No, you can Just like Yes, I'm going.

  • By the way, I think I mentioned this, but wait and going be waiting into laser cutting myself.

  • Cy was a student here, and I are gonna work on I have Ah, it's going to arrive sometime this week, a box of 250 train whistles, and I'm gonna try to, like Liza Wretch, the coding train, send them out is like patri on, but I'm not.

  • I think I'm not gonna use Patron, but it's a longer story that I will get to it.

  • Another way.

  • You'll talk about more in this Friday's life membership Gifts for people.

  • Um, okay, uh, so let's move.

  • Let's move on, because way we'll hope that won't be super rushed today, but we'll be here till about five o'clock.

  • That's about 45 months.

  • That's 1/2 an hour.

  • Okay, so I'm gonna kind of let surely take the lead here, Let me at least open up.

  • What I what we'd made before.

  • And I will try to, in my own words, kind of recap what we did.

  • And then you can tell me if I kind of understood it correctly.

  • Um oh, And then we will also take your questions on Peter in is asking, Can you explain how to generate over the films again?

  • So that that has to do with kind of like the interrupter.

  • They exit stuff.

  • So now that we need to answer that right now, I'm just trying to pinpoint where s so I feel like there's two parts he could be talking about one when we loop through the data itself to calculate on dhe use the scales I'm and but he's probably talking about the enter update exit part.

  • But we're in arraigning through the kind of the SPG, so we'll make the jump.

  • What we re coded somewhat step by step last time was how to make one flower based on one movie.

  • But then we really quickly I don't think we again who is surely, surely very quickly just added some code.

  • And so, yes, let's try to take some time to unpack that.

  • And I also would love to show a couple of projects that people made based on, um yeah, so I know there were.

  • So it's so let me first recap, and I'm gonna try to spend less than two minutes doing this.

  • So the first thing that I learned from Shirley is that syntax for creating a path in S V g m remove.

  • See for curve, too.

  • There's also L for lying to you and then on then that's really what That's what's happening here.

  • This petal path is like start here, started the top curve to the bottom and then curve again, back to the top And so there's a very simplistic design on dhe.

  • Maybe surely will touch on how you might make that more beautiful.

  • Or you could look at her actual film.

  • What's it called again?

  • Film them Flowers project to see that we learned then we could actually put that on an HTML page by creating an SPG element when all this is happening in the observable notebook, which is like the P five Web editor in the sense that I'm coding in the browser but very different in that it's got cells that could be executed separately, uses require a bunch of different syntax things.

  • Okay, then we loaded the D three library that's the primary library were using in these code examples.

  • Then we loaded a Jason file that has all this information about movies in particular there.

  • The year they were released, their box office, the number of the ratings, things like that.

  • A lot of many meta data about then what we did was use a nominal, just like sort make this discussion much shorter.

  • We use the D three library, So if I go up here and look at the data we can see here is the movie die hard to on all of the data associate with that movie.

  • Then we use the D three library to parse out two pieces of data the rating and what was the number of votes again Soon A number I am Devi votes.

  • So basically the number of people that like raided Okay, so and those pieces of data were used to design the flower?

  • Yes.

  • And so the all this functionality that you're seeing, like extent, scale, linear Kwan ties all of these air D three built in D three functions that perform common operations on data like remap it from this range of this range or, you know, inverted or multiplied by this or that kind of stuff.

  • And so we did that.

  • And once that was done, there is now this sort of crucial piece of code which I think is kind of what you want to re explain in this crucial piece of code.

  • After the data is parsed in on re mapped all the appropriate ranges, it takes the data and makes the flowers out of it.

  • Through this process called enter update exit.

  • But we're only using enter for this particular exam.

  • Yes, Yeah.

  • And, um, we were talking about, um I think going through the enter update, I say and then kind of talking about steps of maybe what I'm people that are watching might be able to do to kind of, like, complete the project, right?

  • I am.

  • And so do you want to do the which I think you should start with re explaining We're slowly.

  • Any of the bits you thought you rushed had to rush through.

  • And you could do that on the white board.

  • Who spread the whiteboard camera on?

  • Yes, I do love.

  • I would love any.

  • And I will keep an eye on the chat.

  • Yes, that'd be great.

  • I think I would love any questions to do with the interrupting, actually.

  • And I think that is Peters Peters Question.

  • Yeah, and science is giving us information about, uh, details of S e G tags.

  • And so why don't let me just make sure this works if I switched to hear books.

  • No, that's the wrong, but okay.

  • The audio should be back.

  • That was my fault.

  • So why I'm gonna all right.

  • I think I might know what's going on here.

  • Um, so just do this sound should be back and hopefully the white It's gonna be packing a second.

  • People can still hear me.

  • Um, okay.

  • Video capture device existing weird.

  • Something happened.

  • Create new.

  • Okay, everybody, I realized that's the green screen.

  • That's no signal.

  • That's the computer.

  • This should be the white board.

  • There we go.

  • We're back in business saying I don't know what happened there.

  • So can I say something for a second?

  • Surely.

  • Okay.

  • Your mike is good.

  • So now we're we're back in business, so you can explain.

  • Go back to whatever discussion you want tohave with the viewers, and I will keep an eye on the chat.

  • Okay, So, um, we did this last Friday where I, like super intensely rushed through Enter update, exit.

  • And that was the kind of the one that I want to to go over.

  • And then if we have more questions about other parts of what we went over on Friday, I love to answer that, too, but I'm going to start with this and then hopefully, like, questions will come in as we're doing this.

  • I'm so what I wanted to do is kind of give a more concrete example of like, um, something that you might actually do when you're working with data are working with the three and data on DSO.

  • Let's make this, like, hypothetical data set of I'm just gonna start with three.

  • So let's just say I want to draw like, three circles and my and I want to like Matt my data to that.

  • So this is my data.

  • And let's see, I'm just making things up right now.

  • Um, I see.

  • So my data is an array of three objects and each object has an i.

  • D and a radius number.

  • Um And so let's say that this is our SPG are, as vision currently looks like.

  • And so we talked about last week about how on, uh, what d three goes and does when we say d three that select and we always have to go select the SPG.

  • And then when we see thoughts like all and let's say that this time we're trying to draw circles and so we're gonna select all circles that are in the SPG.

  • And right now what we said last week is there is nothing that exists in the SPG, and so that would return an empty selection and then the three kind of most common things that you see in d three or that you saw Andy three.

  • I think, um, inversion four.

  • And before was this kind of hot and called data Enter upend?

  • I'm and actually I think inversion five or a newer version.

  • I think we now have a different It's a It's a different method.

  • I I'll cover this first and then I'll talk about the new method because it's conceptually still the same the new month.

  • It just makes the code part easier.

  • Um, and so will pass in music.

  • Hi.

  • Always name is data, and then I regret it.

  • I'm so we have values.

  • Let me just call it by news and we're gonna pass in values.

  • And this is the part that I kind of wanted to explain in more detail, which is on Indy three dog data.

  • This method actually can take in a potential second argument, and we call that the key function.

  • And so, um, what the key function I am if anybody's ever used react or view, Um, that's probably really familiar to you, because every time you trying to render in the ray of something like, they'll scream at you and be like, for best practices enter a key function on.

  • And so that's the same concept.

  • But I I'm let me do this first and was say whatever.

  • Um, is so let me do this and then I'll explain it and just watch out that actually, the camera only gets to about here.

  • Okay, Thank you.

  • Um, so I'm gonna stop this right here, and I'm gonna kind of I am go back to here and say I'm trying color coded.

  • So let me see that I'm my values here.

  • So, like my actual data that I'm trying to bind our, um, this kind of like 15 This i d is one and Radius is five.

  • And then I'm trying to find no ideas, too.

  • And radius is 10 um, 3 50 And so when d three sees that, it's got data.

  • What it's doing underneath the hood is it's going thio, take the bat, this array of values in it, and when you pass in data, it has to be in the right or else you're going to get on error and d three is saying Okay, let's loop through each of these, identify what the key is.

  • So this is where it's like I'm looping through each of the elements in the data and identifying what the key is.

  • So it's saying, Okay, the key is one.

  • The key is to kids three.

  • And then they will look in the dom and they will say, Okay, is there any elements that are existing The dom that our circle elements?

  • I'm that have the key?

  • Um, I d one key I d to carry the three.

  • They'll be like, Oh, no, there isn't any of those.

  • And so it will be like, Okay, so the I'm there will be an enter selection.

  • I think I understand this.

  • Now you're on, there will be an inter selection that deed three calculate this dysfunction calculates, and it's saying like, Oh, I need Thio.

  • I'm trying to figure out.

  • Then let me, Let me have, like, an actual like color coding of like, Okay, so all concepts are going to be in blue.

  • All data are gonna be green and all as veggie elements are red from now on, so it's gonna be called an enter selection.

  • And this says that because there's none of those things that match.

  • Like all that criteria existing in the bomb.

  • That means I need to go and create three circle elements I am.

  • And we're gonna get into Yes.

  • Yes.

  • So if if those did exist, would it then would just, like, grab those elements and okay, so entered.

  • Enter the enter, But most typically is sort of the first thing that happens based on the data.

  • And and this stuff isn't there, so it creates them, creates the dom elements.

  • So d three does not do anything for you.

  • You have to create it.

  • So you have the option.

  • So let me, actually.

  • Okay, keep going.

  • Keep going.

  • I'm And so let me rephrase what I said a little bit.

  • So it data the method data will say you need to like, we We need to create three Dom and three circle Element will be able to match the data.

  • So it, like, has this data structure, if you like, actually look at the dom element and like, it has all this like it, huh?

  • It just says I I have three placeholders.

  • If you ever want to go and create on three dom elements so that the reason why I'm making this like, really like that distinction is then the reason why you do dot end her is because you're telling do three.

  • Okay, I understand that there is something in the interests election.

  • And so please give me return me these three placeholders and then when we do thought upend, we're saying for each of these placeholders actually make me so when I do dot upend, This makes the dom elements.

  • Yes.

  • And we had g and r example because we This is an example that simplified.

  • That's just making some circles.

  • But ours made a group that we then put a whole engine pedals and things.

  • Yes, Perfect.

  • So, actually, let me do this over here.

  • So this is this over here?

  • Is the enter like it's saying return?

  • Many enter selection.

  • That is it.

  • Making these dom elements the circles with the i.

  • D.

  • That's here in the data.

  • Yes.

  • So I'm actually knew would be fun.

  • Let's actually go into our what we created and let's inspect the elements.

  • Actually, can you consul log every group, um, in the So let me just finish drawing this really quick So here.

  • What enter does is give you back three placeholders.

  • And what a pen does is actually create these three dom elements in the three circle elements in the dom with the data bound to it.

  • And when you when you Consul log will be able to see what?

  • That.

  • So when you say console log right now, the result of this whole process is stored in a variable called flowers.

  • Yes.

  • Console.

  • Lug that object.

  • Sure.

  • Okay.

  • Like this?

  • Yeah.

  • Uh, I'm like, here we go, everybody.

  • I'm like, all my buttons are in different places.

  • Council log flowers.

  • So if I run this, then if I look at the console juice again So these are the No, that's that's our data.

  • And so this is actually what d three words are you?

  • And what saying is that it has 135 group elements, and right on, then the most evident to my code Vanna White, huh?

  • Okay.

  • So what?

  • The most important part of this.

  • So this is what, like a dom element looks great.

  • And what d three does is it kind of makes this Oh, yes.

  • Data in there.

  • That's the data.

  • So when people are like D three binds the data like that.

  • This is what they mean.

  • It actually like, makes this little attributes like call like underscore underscore data.

  • And then you can see this is this is the data we created here, the pest sized, some pedals in the array of petals.

  • Right.

  • Okay.

  • And that's what we're gonna about to use down here.

  • And so I think there was Peter's question was like, How did you loop through the films?

  • I'm ensue.

  • What actually happens?

  • So, actually, do you wanna come?

  • Yeah, you're So what actually happens is when we do any of these thought adder or that style, what's happening under the hood is that d three is applying this function that we passed in to every single one of those dom elements g over here.

  • Yes.

  • Oh, yes.

  • Every single one of these bomb elements.

  • And in every one of these function, we can actually see that right there and that.

  • Sorry, I'm interrupting you with France for in the way we actually see that in There was like, there's a property there that would have that this translated the trans Oh, yes.

  • Oh, I think you think it was there under T s?

  • So that part is not actually, that's that's a part of just like a human G.

  • I'm and so like, basically, Detroit is just abstracting some, like don manipulations stuff for you.

  • I am.

  • But in this function transform, it's probably under the transfer on that you found this is a really big Yeah.

  • Yes.

  • I don't know if you want to get into this.

  • No, no, don't.

  • Let's definitely do not.

  • It was my fault.

  • Go on.

  • But I'm so it's on this function.

  • What we're doing is we're getting the data, this data per group element and then I'm and then we're evaluating it, and I'm d three is looping through it under the hood and applying whatever is being returned to each of those group elements.

  • And so that's how deep throaty I'm.

  • That's how we use d three to kind of apply data to each element.

  • So usually, after you see this, there's a the outer door after the other, the outer most are yet usually after you see this set of code, you'll see So actually, what an adder is short for attributes?

  • Yes.

  • Which HTML elements can.

  • It has attributes, one of which is this, like style.

  • I'm just going to represent this as one Fine.

  • 2 10 and 3 50 Okay, so this is what happens when we do enter.

  • And then when the tying and talk about update and ice it on, can I ask a question?

  • So we only needed enter in our example, because we were just like, creating the visualization.

  • So if it's going to change over time or something different, it's gonna happen later.

  • It's gonna animate.

  • Or maybe that's why we would need to add update update.

  • And so So if if it's a static visualization, you only need enter.

  • Yes, it animates you need update, does not enemy, but, like, just changes, it changes value.

  • So let's let me just show that really quickly really quickly, are you?

  • Let me say that now that we've drawn okay, so in here, I wish I I'm like, on my computer right now, and I can just, like, cut this out and lying dragged us over here and putting here.

  • But one of these days I'm Sue.

  • I'm because this is recorded.

  • I'm just gonna erase this.

  • So we have we have your room.

  • Yeah, I saw Somewhere in the chapel is like, You don't you raise or something?

  • I'm okay.

  • It's all being saved for until as long as the it's not the Internet apocalypse, you'll be able to find material.

  • Okay, So then let's say now that we like you created all of this.

  • I'm Let's say now, for whatever reason, we want to show the second state of data or a second set of data.

  • Let's say that in the second state I'm you know, we have we still have.

  • Let's say I did too.

  • Aren't 10?

  • Let's say like we have actually knew it.

  • And let's say in the second state, the radius I'm actually goes up to 20.

  • And then let's say we have a news thing I am, and I'm gonna call it I d four and this one is gonna have a radius of 30.

  • I am making all of this up.

  • So just just to understand it for a second, the idea here is that if these are all tied two circles, this is now, in a way, a new value for existing circle on.

  • This is now a new circle because the idea is the key for each piece of data.

  • Yes.

  • So let's Yeah, exactly.

  • So let's go through that together.

  • Um, so I'm going to say, you know, this this was okay with me.

  • Now I'm trying to decide how I want to go about this.

  • Let's still go use thes.

  • No, I'll join you want?

  • So we have.

  • We now have three circles, and this is I'm just on Lee going to draw the eye.

  • D This is I d 12 and three.

  • And the radius is five 10 50.

  • This is the result after here.

  • After that?

  • Yes.

  • Thank you.

  • Um and then our new data.

  • Okay, Our new data is I d two and two radius 20 and I d four radius 30.

  • So just like you said, Dan, do you want Do you want to?

  • Um so?

  • Well, we would say we would say, Where do we have to say dot data again?

  • No way.

  • Let's just conceptually first.

  • And so let's saying that we want the very first the order I usually do.

  • It is actually I exit first.

  • And so I am.

  • You can exit after an enter, Actually, no.

  • I think you're right, Let's do it with the coat in Soo, I changed dressed that way.

  • Needed that.

  • Enter.

  • Oh, you don't have.

  • You just have update.

  • No.

  • Enter way.

  • Get that.

  • I was so understanding with the enter that code we have is the only if we only need to enter way.

  • Want to d'oh all the enter update, I say and I will give this.

  • I'm gonna put all of this in a call.

  • Circles.

  • Um And then what I'm gonna do is first I'm gonna exit.

  • So this is concept.

  • I am now, like getting confused.

  • I never use more than one.

  • Color is very amazing.

  • I should have I should have I don't know the things I get myself into the first step I want to do when I'm doing enter update, exit the whole shebang Is this part where I just healthy three to do the calculate buying the data, do the calculation.

  • Then what I d'oh is I take circles that exit dot Remove We would be this would happy happening, like here, So this Okay, I'm gonna make some more room for this circle is thing.

  • Um so this will be on a new line right there.

  • Yes.

  • Yeah.

  • Okay.

  • Here I am.

  • I just, uh, wanted Thio understood that this equal, sir.

  • Okay, I don't know.

  • And so Okay, so imagine that this is, like in the fellow guy, okay?

  • And so what's happening here is this is basically, like, return value of thought data.

  • I'm and it's saying I'm and here another thing that data would have done is say, Okay, there is I d to i.

  • D four.

  • So this remains, but these two need to go.

  • So thes two are the exits selection.

  • And so I'm this we call the exit selection and is the two circles with I d one and three because they're not here because they're not in the new data that we're trying to render.

  • But where we'll hear values is is here.

  • But I don't see any where we refer to Val too.

  • Okay, so very good point.

  • I am.

  • You've caught me on.

  • So technically speaking.

  • Okay, let me do this.

  • Look, that makes sense to me.

  • But how did it know to compare?

  • So you just said that?

  • Oh, you're just overriding the values changed?

  • Yes.

  • It's kind of like, isn't that the thing that react does or something.

  • It just like something changed.

  • Update stuff.

  • Sorry.

  • Okay, go there.

  • I'm Sue.

  • You're catching soup.

  • I'm what I usually do is I put this whole enter like I put all of this code into a function.

  • And every time that you want to enemy unused dead, it's set of data or you want to, um, like somebody clicked on something.

  • You want to update the data, you will then call the call that function and passing the new guy's got it.

  • Okay, Sorry.

  • I was like times.

  • I get it.

  • I get it.

  • Totally makes sense.

  • So this is not an automatic process where this is always like, looking at what the current values are is a process by which you can pull what's in the dom.

  • And compared to your data update everything.

  • Yeah.

  • Sue, The thing with is that you need to do everything else you need to do absolutely everything like react in view and stuff like they're doing this magically under p five is like that.

  • Well, you have to draw.

  • Nothing's gonna happen and p five unless you're explicitly drawn to me, this feels like more automatic than people But arguably, it's the same idea.

  • Actually, I think the difference is the mechanism by which things were drawn in p five is this set up and draw function?

  • And here it's really about starts more with the data and interrupting.

  • And also, I think that the fundamental difference between the three MP five is that p five default to canvas and set up and drop some sense because then, like you set up the canvas and then you draw.

  • And then if you want to integrate you clear campus, redraw everything.

  • This is actually actually updating SPG elements.

  • Yes, because SPG elements will stay in the dom and you need a way to be able thio remover it dependent or update it.

  • But I don't wanna go to off track here, but Indy three, you can also say use canvas instead of Esther.

  • But your your code doesn't have to change our changes a little bit.

  • So actually, the great thing is, if you want to use canvas, I don't think you need any of this coat okay?

  • Because with canvas, like we said, it's just about like, clear draw, clear draw.

  • And so, with canvas, what you might do, like with canvas.

  • All you would do is in the same function that you're drawing instead of going through this whole hassle.

  • But process on.

  • We would just pass in the new data, clear the canvas, just redraw the new data.

  • Um, so you might be like, Why are we going through all of this trouble?

  • Because if you want to learn d three every single example other than the examples for campus will have this whole pattern.

  • And it's really helpful to know what's going on.

  • Yes, okay.

  • Could continue.

  • There's also attention about, like, spg versus canvas and where you want to use, which.

  • But that's a that's a whole tangent.

  • I'm Yes.

  • So what was I talking?

  • Okay, so this exit, this thought exit is basically telling d three that I want to like, please give me this exit selection, which will include thes to dom elements.

  • And in this thought, remove, we will actually be.

  • That's the function that actually removes it from the dawn.

  • And so once we call this, what's gonna happen?

  • Thio r S E g is.

  • This gets deleted and this gets deleted.

  • So that's what the state looks like after this exit selection are a sorry.

  • After this cone is executed.

  • So I d number four is not added because the exit is on Li for giving you what's missing and removing.

  • And am I gonna guess correctly that update will add number four?

  • Very close.

  • Very close and dirt weed.

  • Another enter?

  • Yeah, because we just put exit before enter.

  • Yes.

  • Oh, that's you didn't actually, we're not actually getting rid of enter and replacing with update.

  • We're just We needed to add exit first.

  • Yes.

  • Ooh, I've gotten that.

  • Could you do them in any order because you're kind of setting up or it's going to do exit?

  • Because here it says, enter update, exit.

  • So that's kind of what I was imagining, essentially, like, because this is kind of I'm over the years I've liked developed this order because and I reasoned it out once I am, or a few times, and now I'll have to talk it through.

  • Okay.

  • Enter is gonna get us the missing one.

  • Okay?

  • Yeah, there's a reason for it.

  • And I don't remember off the top of my head and yeah, So what we want to do is Dr Pens like we hunt before.

  • And then this is where you can say, like, don't attribute.

  • Like, you can set your attributes.

  • And so what this does is like you guessed it will say Okay, in this SPG, what's missing is the four.

  • And so we're gonna go and create Oh, to line.

  • Yet to is still 10.

  • Update will change that to 20.

  • So exits for removing enter is for adding an update us for existing things with change data.

  • Thank you, Dan.

  • I love I love doing this, actually, because I always feel like I'm not, like, explain.

  • Yeah.

  • Yes.

  • No, I don't know any of this stuff.

  • I I like I've tinkered with d three, but I've just in that that that place, you know, you've been there, and I watched him in there where you don't know the thing that you found some example?

  • Yes.

  • You just like boots and stuff around.

  • And then you kind of got something and you move on p five.

  • I feel like I know that inner mechanics, how things work so I can go a little deeper, but this is completely new to me.

  • I also 100% agree with everybody.

  • That's like canvas and P five are easier to grok because I'm like you don't have to worry about, like persisting Dom Element, moving them, updating them I'm and like all you have to worry about is clear drawn, clear draw.

  • And so, like, I think I honestly feel like P five and canvases the more fun one.

  • But like with but like with D three also with us and did we can deal with hmm oh elements as G.

  • Ellman's cameras.

  • But you know, I I think that's always important that people get into this trap of like, Oh, should I be using this one or this one?

  • Which one's better?

  • This one's better.

  • That's one of no good.

  • I like my thing and instead all of these libraries.

  • It's not a zero sum game.

  • They all are tools that have their own value and, like you might say, like, Oh, hi, I've never programmed before.

  • Why don't you take a look at p five or high?

  • I program in Java script.

  • I have this giant data set.

  • I want visualize SPG feel like, oh, why did you take a look at T three?

  • So it's not.

  • I think we can fall into that trap of, like, I have to, like, prove that the one that I like is the one that was, like a weird stand Internet stand culture like I don't understand it.

  • These are all like he said.

  • Like they're all tools.

  • Used them where they make sense.

  • Okay, so the one last part and this is gonna be Oh, and then what I have to dio is I have to remember this.

  • Enter selection in here in this eye, uh, in this variable.

  • And this is the part that's gonna be get a little bit weird if it hasn't already.

  • Dan.

  • Andi, I'm realizing that I'm running out of space.

  • Wish me luck.

  • I'm gonna I'm gonna be over.

  • I'm gonna just do this.

  • They're apart over here.

  • Um, so this is gonna be the update step and what I'm doing here, it's saying in turn dot merge circles don't matter.

  • And whatever attributes I've never said adder before in my whole life and you didn't think I had a particular What is this, Adam?

  • No, but that's probably a thing.

  • That's a way to say that NTR.

  • So this is probably the There's a lot of weird things and this is probably the weirdest one.

  • So what this is saying is I have my enter selection, which was this for, And I'm God, data this actually also returns you the update selection, which is this too.

  • And so I'm saying give me this Inter selection of four merged that selection with this update selection of two and then set the attributes.

  • Whatever attributes I need in this case, what I want is to set the attributes radius.

  • Um, and d'oh I'm And then that you know, I want to use the d dot Are like and this would be that would be here also right s o The reason why I have this is because you don't need it.

  • So here it doesn't apply to us because I'm okay.

  • The best way to describe it is if you have attributes you want to set, that will never change.

  • Do wait here.

  • So maybe I want my fills to be read.

  • So that means that every time I created never update it will.

  • It will never.

  • This attributes will never be updated.

  • And so I'll just do it on creation just just cause that's much more efficient you can You can put this down here and the same thing will happen.

  • But, like, I mean, you just don't need Thio.

  • And I'll put any attributes that will that our data dependent off of this thing like change off of this thing s So now that we have this one line, this radius will become 20.

  • And this is this is the code for enter update exit.

  • So I have an interesting question here.

  • So enter maps exactly to this function called Enter exit maps.

  • Exactly.

  • This one's called exit, but update it's there's this 100 called Merged.

  • So there is no actual function called update.

  • The process of updating is merging the existing circles with the new data.

  • So it's called merges that kind of yes, basically the update selection.

  • You can think of it as like I'm I think that the update selection as like whatever it is existing and then needs to be kept, but yeah, honestly, it's it's a little bit.

  • It's a little bit.

  • That one's a little bit weird of the one I'm So now that we've gone through all of this pain, I am Let me show you the easier way to do it because I think I have this here.

  • So I just found over here this notebook for always from 2012.

  • So it must not be.

  • This is like it's got some examples of, like, enter.

  • We could see this a drag merge.

  • But what I was looking for was that somebody was telling me there's a new thing called Join.

  • Wait, Go back so that go back to that and then go up.

  • And so this is basically I am Well, actually, that's not That's not even really This is old.

  • This is from like, seven years ago.

  • Just like my Google search was a little off.

  • Wait.

  • So the thing I wanted to show you is what someone leads?

  • Yes, that's what I was looking for.

  • It's called Join.

  • Yeah, data joined.

  • So it's, um, selection on Join me child D three selection.

  • That's a rose.

  • And then do not find dot join selection, not join.

  • Uh, yeah.

  • So here are let you stand over here.

  • You can point over there.

  • People will be able to follow it more easily is interesting.

  • And so this stop joined, I think, came out in the newer version of the three.

  • I am where it just upsets away all of the pain that we went through and we went through this so that you can understand how it works.

  • But just do this s O join is kind of like there's gonna be new stuff.

  • There's gonna be stuff that's gone.

  • There's gonna be stuff that was there but the values changed.

  • Joins gonna like account for on an update The Dom elements magically video everything.

  • And if you want, like, specific things to happen like you, can you please call back functions?

  • Do you like all the pain?

  • We just want you to know this is like, This is good because, you know, it's it's Internet kind of me.

  • I have, like, encountered similar things like this.

  • Like you can jump to use a weight and a sink in new fancy job scripts.

  • Not that new, but like without looking back at what all this sort of gobbledygook of promises Are you confusing?

  • What's going on?

  • So this to me is a little bit similar.

  • Like, yes, we could have started with just this join, but at least remains and having seen D three code before having this having this Maur sort of like a full explanation of it.

  • Now I get it is like to reward you get dessert here, Joy.

  • So I actually personally have never used join before.

  • How new is this?

  • I think so.

  • Uh, Disclaimer.

  • I stopped using Enter update exit period last March when I started using view because, reactive, you again do all of this underneath the hood.

  • And so the way I actually like to Deb and it makes me faster developer is I used the three to do all of that data translations.

  • So last week, when we do did all of those scales, you see three for that, I used the three toe like calculate positions for me.

  • I am in like like, X y positions.

  • SPG pads on dhe.

  • Then when I actually need to go render to the dom I use view.

  • So I stopped using Enter update exit.

  • So it must happen between last march and now.

  • So I personally never used it.

  • But I think if you don't want to use like if you only want to use the three to draw, I'm and do everything.

  • Then I would highly recommend checking out the data dot Join somebody harp eat in the chat.

  • Suggested looking at this.

  • See if this this particular example Which explains enter update exit.

  • Is this the one you're looking at?

  • Islands, Miss Block?

  • Yeah, Cool.

  • So thank you.

  • OK, I can add a link to this in the video's description as well.

  • I wanted to show two things.

  • I don't know if you saw these, but two people created.

  • Let's start with this one, actually.

  • So based on Friday, Stream two people made their own versions of this.

  • This one is by Stefan Rife Enberg.

  • Let me open it in a new window and we can see here film flowers based on the original.

  • So what I love about it is the rebels How you can annotate with mark down.

  • It's really nice to be able to do that.

  • I mean, and and you can see the code he made.

  • The grid is so much nicer too.

  • So these are beautiful, you know, it's something about also the with these kinds of projects.

  • The repetition and the arrangement of all the different flowers is really what kind of brings out the visual for me?

  • I feel like I think I had assumed was working on a project, and it was like a sort of beautiful pattern.

  • But as soon as you could see, like 100 variations of them all in a grid got this other sense of what that patterns like, That's really nice.

  • So this looks like pretty similar.

  • So what we did, But just with a bit more thoughtfulness in terms of color and and the ranges But the other one that somebody made, which will go here Anthony McAteer or Spectral Flame, I recognize that name from YouTube Chat created something very similar, but with a totally different data.

  • So yeah, so let's look at this.

  • So this is popularity and contribution Flowers of coding junkers.

  • So I have a playlist.

  • I think it has, like a You know what number 150 something like videos of Like a coating Johnson will be actually could look at the data here will be like a star field, a snake game, all these different things.

  • So I guess what's interesting is to think about what first of all, what is it?

  • What does it mean for something to be popular?

  • I suppose that's tied to maybe the number of uses that the right metric for popularity, Interesting question, height of the background size of our heIp sets of views.

  • The number of petals is how many contributions and contributions is a thing that if you go onto the coating train website and goto like coding challenges, I'm pretty sure I think that 10 print one, this has the most contributions.

  • So if I go to here, you can see these are all like versions that people made after watching this video and seeing it's just this is the example of the pattern.

  • So this is like I like we were talking about, I think, surely never does.

  • This is like, How would you making an example like, How far do you go with it?

  • Like, uh, you know, Do you want you at all the features?

  • Do you make it beautiful?

  • Argued like, sort of leave stuff for the person who's gonna received example to build on top of it is hard to find that line.

  • Um, but let's so let's take a look at this.

  • So if we look at this, we can see here is all the data, Um, and then here's text is there this?

  • I guess this is just the number of the number of what challenge it is.

  • That's the name of a challenge.

  • And Len this with this down here.

  • Like what?

  • The curve?

  • Because Because there's Ah, there's a difference in how Sorry how long the Ark is right.

  • Some of these are really long.

  • So spectral is that spectral piano is in the chat.

  • Um, actually, clock has the most there.

  • He's there a little bit behind.

  • Okay, so you can ask your questions, we'll get Yes, I'm wondering.

  • So there was Wait.

  • There was popularity that was the size.

  • And then description up here says, by the way, you could you could if you go down, if you could just do this to hide it.

  • Okay, so it says views is, um size and height of the background number of petals is the number of contribution.

  • Okay, so maybe this is also tied to views.

  • Maybe that's what's so odd about the background.

  • Yeah, makes sense, because you can see this one over there has three pedals and a much smaller arc.

  • Where's that snake game has a lot of petals at a much larger Oh, the background curve is just the views. 01:00:29.7

Hello.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

A2 初級

D3.jsはシャーリー・ウーと続きます。 (D3.js Cont'd with Shirley Wu)

  • 0 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語