Nested Selections D3’s selections can be hierarchical, much like the elements and data they join. Consider a table: <table><thead><tr><td> A</td><td> B</td><td> C</td><td> D</td></tr></thead><tbody><tr><td> 0</td><td> 1</td><td> 2</td><td> 3</td></tr><tr><td> 4</td><td> 5</td><td> 6</td><td> 7</td></tr><tr><td> 8</td><td> 9</td><td> 10</td><td> 11</td></tr><tr><td> 12</td><td> 13</td><td> 14</td><td> 15</td></tr></tbody></table> How would you select only the body cells? The selector "td" would match the td elements in the head as well as the body. To match only those elements A within some other elements B, use the descendant combinator, "B A". var td = d3.selectAll("tbody td"); Alternatively, select the tbody element first, then select the td elements within: var td = d3.select("tbody").selectAll("td"); This produces the same result because selectAll, for each element in the current selection, selects the matching descendants. #Nesting and Index var td = d3.selectAll("tbody tr").selectAll("td");
Removing User Interface Complexity, or Why React is Awesome I've been studying frameworks and libraries like Ember, Angular, and React the past several months, and given Web Components a lot of thought. These all solve similar problems to varying degrees, and are in conflict in some ways and in harmony in others. I'm mostly concerned with the core problems of data binding and componentizing UIs. After much research and usage of the technologies mentioned above, I found React to provide the best solution. I ask that you set aside your framework prejudices and read this post with an open mind. This post is not to evangelize React specifically, but to explain why its technique is profound. This post actually started as a call to address problems with Web Components. The Bloop Library# I'm not going to focus on React specifically. We're going to build our own library from scratch that is highly inspired by React. Let's call our library Bloop. First, we need a way to represent behavior and structure. Next, we need a way to render it into the page. Om#
Isometric projection in Inkscape Isometric projection helps us to demonstrate three-dimensional objects on a plane, creating the illusion of volume. Most often it is used in computer games and pixel-art. You can read more about it in the corresponding article on Wikipedia. In this article, we will examine ways to create objects in isometric projection by using Inkscape. These are: Axonometric gridTransformation of the objectCreating 3D boxes Note: If it is your first try in Inkscape I advise you firstly to examine the Help section (Menu > Help). These methods were picked up from various sources available online. Way I: Axonometric grid Inkscape supports two types of grid: rectangular and axonometric (File> Document Properties> Grids). Way II: Transformation of the object Almost any object can be transformed into the isometric projection by setting parameters. After creating a text we need to go to the Object > Transform > Scale and reduce the width to 86.6% (86.603%, to be exact). Way III: Creating 3D boxes That’s all.
Sports betting between friends No silly website I don't want to sign-up with Facebook.... Nooo silly website I don't want to sign-up with Twitter.... Noooo freaking website I don't even want to sign-up with Google+.... Noooooo I don't want to create an account either! Anyway I'm writing this because of a lot of very nice comments I've had both on HN (the thread) and Reddit when showing my newly created website I started developing the website last Saturday and knew I needed to be quick if I wanted to post something convincing on HN before Monday! Then I remembered how Doodle were doing their registrations and how great it was to have your little personal URL that you keep a "secret" and lets you access your poll. Well it turns out people love this feature, and in a few days I have thousands of users from all around the world!
Engineering During the latest redesign of our homepage I implemented a framework in AngularJS for building scrolling animations. The framework is called angular-scrollery and it makes implementing a scrolling animation as simple as defining a series of steps and element behaviors specific to each step. In this post I will describe the process of creating a scrolling animation (specifically, this demo) with angular-scrollery. Step 1: Set-up The first thing you need to do is standard set-up for using an angular module. This includes: including angular-scrollery-config.js and angular-scroller.js on your pageinitialize the angular-scrollery appinclude the controller attribute on the animation container like so:<div class='animation-container' ng-controller='ScrollerController'> Step 2: Design animation In angular-scrollery, animations are broken down into steps that you define in angular-scrollery-config.js, following the convention that user-defined settings exist in a separate config file.
An Interactive Introduction to Graphics Programming This is a proposal and proof-of-concept for an interactive book about programming the graphics processor. Modern computers come with two separate processors, two “brains”: The traditional CPU, the Central Processing Unit The newer GPU, the Graphics Processing Unit Almost all books and courses about programming only teach you how to program the CPU. GPU programming is esoteric. Yet there is a unique joy to programming the graphics processor. This book is intended to bring the wonder and joy of graphics processor programming to a wider audience. An Interactive Book This book will be interactive. The text will be extensively illustrated with manipulable diagrams and live code examples. On the left you have a graphic output and on the right you have the code that produced it. By experimenting with the code—by touching it—you can gain a much deeper understanding of how it works. Try moving your mouse over the output. I am extremely excited about the possibilities of interactive books in general.
Snark Hunting: Force Directed Graphs in D3 — delimited There are also really fun to look at and make a good launching point for talking about D3's force layout. After some searching, I found a dataset that contains the node and link information for many common snark graphs (thank you, internet!). You can get the original data here. Creating a D3 viz is less commonly done using a pseudo-classical style, but can be a powerful way of organizing your code if you need to develop visualizations that are more like small applications or tools that provide complex interactions rather than just a simple chart or graph. If you are unfamiliar with the pseudo-classical pattern, you can take a look at this post I did a few weeks back that gives you a quick overview of the most common patterns. A graph at its most fundamental is a set of vertices and edges. In these examples, the bulk of the action is happening in the graph.js file, so it will make sense to focus in on that file. The code in full for each of the example HTML files looks like this:
The Cellular Automaton Method for Cave Generation Dear reader, this post has an interactive simulation! We encourage you to play with it as you read the article below. In our series of posts on cellular automata, we explored Conway’s classic Game of Life and discovered some interesting patterns therein. In this post we’ll look at one particular application of cellular automata to procedural level generation in games. An example of a non-randomly generated cave level from Bethesda’s The Elder Scrolls series. The Need for More Caves Level design in video games is a time-consuming and difficult task. We’ll explore more of these techniques in the future, but for now we’ll see how a cellular automaton can be used to procedurally generate two-dimensional cave-like maps. A Quick Review of Cellular Automata While the interested reader can read more about cellular automata on this blog, we will give a quick refresher here. For our purposes here, a 2-dimensional cellular automaton is a grid of cells , where each cell It All Boils Down to a Simple Rule