Skip to content

Commit 6381229

Browse files
author
Derek Greentree
committed
Fix typos and change space+newline -> newline
1 parent 23cb959 commit 6381229

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

content/guides/rendering-data-as-graphs.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In this guide, we're going to poll repositories that we own, and render the
1111
information there with graphs, using the [d3.js][d3.js] library. We'll also
1212
be using Octokit, a Ruby library designed to interact with the GitHub API.
1313

14-
We're going to jump right in and assume you've already read the ["Basics of Authentication"][basics-of-authentication]
14+
We're going to jump right in and assume you've already read the ["Basics of Authentication"][basics-of-authentication]
1515
guide.
1616

1717
Note: you can download the complete source code for this project [from the platform-samples repo](https://github.com/github/platform-samples/tree/master/api/ruby/rendering-data-as-graphs).
@@ -68,10 +68,10 @@ Set up a similar _config.ru_ file as in the previous example:
6868
## Fetching repository information
6969

7070
This time, in order to talk to the GitHub API, we're going to use the [Octokit
71-
Ruby library][Octokit]. This is supremly better than directly making a bunch of
71+
Ruby library][Octokit]. This is supremely better than directly making a bunch of
7272
REST calls. Plus, Octokit was developed by a GitHubber, so you know it'll work.
7373

74-
Establishing an Octokit instance is extremly easy; just pass your login
74+
Establishing an Octokit instance is extremely easy; just pass your login
7575
and token to the `Octokit::Client` constructor:
7676

7777
if !authenticated?
@@ -81,7 +81,7 @@ and token to the `Octokit::Client` constructor:
8181
end
8282

8383
Let's do something interesting with our repository information; let's list the count
84-
of each language found in our repositories. To do that, we'll first have to grab
84+
of each language found in our repositories. To do that, we'll first have to grab
8585
a list of repositories we own. With Octokit, that looks like this:
8686

8787
repos = client.repositories
@@ -91,7 +91,7 @@ identifies:
9191

9292
language_obj = {}
9393
repos.each do |repo|
94-
# sometimes language can be nil
94+
# sometimes language can be nil
9595
if repo.language
9696
if !language_obj[repo.language]
9797
language_obj[repo.language] = 1
@@ -103,7 +103,7 @@ identifies:
103103

104104
languages.to_s
105105

106-
When you restart your server, your web page should display some information
106+
When you restart your server, your web page should display some information
107107
that looks like this:
108108

109109
{"JavaScript"=>13, "PHP"=>1, "Perl"=>1, "CoffeeScript"=>2, nil=>4, "Python"=>1, "Java"=>3, "Ruby"=>3, "Go"=>1, "C++"=>1}
@@ -119,11 +119,11 @@ d3.js likes working with arrays of JSON, so let's convert our Ruby hash into one
119119
language_obj.each do |lang, count|
120120
languages.push :language => lang, :count => count
121121
end
122-
122+
123123
erb :lang_freq, :locals => { :languages => languages.to_json}
124124

125125
We're iterating over each key-value pair in our object, and just pushing them into
126-
a new array. The reason we didn't do this earlier is because we didn't want to iterate
126+
a new array. The reason we didn't do this earlier is because we didn't want to iterate
127127
over our `language_obj` object whilst we were creating it.
128128

129129
Now, _lang_freq.erb_ is going to need a bunch of code to support rendering a bar graph.
@@ -146,7 +146,7 @@ For a really good tutorial on the basics of d3, check out [this article called
146146
fill: white;
147147
}
148148
text.yAxis {
149-
font-size: 12px;
149+
font-size: 12px;
150150
font-family: Helvetica, sans-serif;
151151
fill: black;
152152
}
@@ -208,7 +208,7 @@ For a really good tutorial on the basics of d3, check out [this article called
208208
</html>
209209

210210
Phew! Again, don't worry about what most of this code is doing. The relevant part
211-
here is a line way at the top--`var data = <%= languages %>;`--which indicates
211+
here is a line way at the top--`var data = <%= languages %>;`--which indicates
212212
that we're passing our previously created `languages` array into ERB for manipulation.
213213

214214
As the "D3 for Mortals" guide suggests, this isn't necessarily the best use of
@@ -218,22 +218,22 @@ to make some really amazing things.
218218
## Combining different API calls
219219

220220
Now it's time for a confession: the `language` attribute within repositories
221-
only identifies the "primary" language defined. That means that if you have
221+
only identifies the "primary" language defined. That means that if you have
222222
a repository that combines several languages, the one with the most bytes of code
223223
is considered to be the primary language.
224224

225-
Let's combine a few API calls to get a _true_ representation of which language
225+
Let's combine a few API calls to get a _true_ representation of which language
226226
has the greatest number of bytes written across all our code. A [treemap][d3 treemap]
227-
should be a great way to visualize the sizes of our coding languages used, rather
228-
than simply the count. We'll need to construct an array of objects that looks
227+
should be a great way to visualize the sizes of our coding languages used, rather
228+
than simply the count. We'll need to construct an array of objects that looks
229229
something like this:
230230

231231
[ { "name": "language1", "size": 100},
232232
{ "name": "language2", "size": 23}
233233
...
234234
]
235235

236-
Since we already have a list of repositories above, let's inspect each one, and
236+
Since we already have a list of repositories above, let's inspect each one, and
237237
call [the language listing API method][language API]:
238238

239239
repos.each do |repo|
@@ -269,7 +269,7 @@ To wrap up, we'll want to just pass this JSON information over to the same ERB f
269269

270270

271271
Just like we did before, here's a bunch of d3 JavaScript code that you can just drop
272-
directly into your template:
272+
directly into your template:
273273

274274
<div id="byte_freq"></div>
275275
<script>
@@ -279,26 +279,26 @@ directly into your template:
279279
var sizeFunction = function(d){return d.count;};
280280
var colorFunction = function(d){return Math.floor(Math.random()*20)};
281281
var nameFunction = function(d){return d.name;};
282-
282+
283283
var color = d3.scale.linear()
284284
.domain([0,10,15,20])
285285
.range(["grey","green","yellow","red"]);
286-
286+
287287
drawTreemap(5000, 2000, '#byte_freq', language_bytes, childrenFunction, nameFunction, sizeFunction, colorFunction, color);
288288

289289
function drawTreemap(height,width,elementSelector,language_bytes,childrenFunction,nameFunction,sizeFunction,colorFunction,colorScale){
290-
290+
291291
var treemap = d3.layout.treemap()
292292
.children(childrenFunction)
293293
.size([width,height])
294294
.value(sizeFunction);
295-
295+
296296
var div = d3.select(elementSelector)
297297
.append("div")
298298
.style("position","relative")
299299
.style("width",width + "px")
300300
.style("height",height + "px");
301-
301+
302302
div.data(language_bytes).selectAll("div")
303303
.data(function(d){return treemap.nodes(d);})
304304
.enter()
@@ -308,7 +308,7 @@ directly into your template:
308308
.call(cell)
309309
.text(nameFunction);
310310
}
311-
311+
312312
function cell(){
313313
this
314314
.style("left",function(d){return d.x + "px";})

0 commit comments

Comments
 (0)