Permalink
Browse files

Messing around with another viz

  • Loading branch information...
1 parent e6e355e commit 6392c7cb611e6efd3ef38a1e5cbe3379d71bc32d @ggreer committed Sep 8, 2012
Showing with 50 additions and 5 deletions.
  1. +9 −2 README.md
  2. +1 −0 popup.html
  3. +40 −3 popup.js
View
@@ -1,7 +1,14 @@
# History Stats
-## Development status: Not ready. This isn't worth using yet.
-
A Chrome extension that shows some pretty graphs related to your browser history.
+### Development status: Not ready. This isn't worth using yet.
+
+
Basically an excuse for me to play around with [D3](http://d3js.org/).
+
+## TODO
+
+* breakdown by domain
+* day of week?
+* graph of visits over time
View
@@ -13,6 +13,7 @@
<ul>
<li id="visits_domain">Domain Visits</li>
<li id="visits_url">URL Visits</li>
+ <li id="visits_timeline">Timeline</li>
</ul>
</div>
<div id="graph_container">
View
@@ -10,7 +10,6 @@ var width = 600;
var height = 400;
var svg;
-
var timeout_id;
function init_graph() {
@@ -20,6 +19,42 @@ function init_graph() {
.attr("class", "chart");
}
+function visit_timeline(visit_data) {
+ var e;
+ var i;
+ var x;
+ var visits;
+
+ d3.select("#graph_container svg").remove();
+ svg = d3.select("#graph_container").append("svg")
+ .attr("height", height)
+ .attr("width", width)
+ .attr("class", "chart");
+
+ visits = visit_data;
+ visits.sort(function (a, b) {
+ if (a.visitTime > b.visitTime) {
+ return -1;
+ }
+ else if (a.visitTime < b.visitTime) {
+ return 1;
+ }
+ return 0;
+ });
+
+ x = d3.scale.linear()
+ .domain([visits[0].visitTime, visits[visits.length - 1].visitTime])
+ .range(0, 420);
+
+ svg.selectAll("circle").data(visits)
+ .enter().append("circle")
+ .attr("x", function (d) { return x(d.visitTime) + 100; })
+ .attr("y", function (d, i) { return 0; })
+ .attr("r", 10);
+
+}
+
+
function visit_count_graph(graph_data) {
var i;
var urls = [];
@@ -42,7 +77,7 @@ function visit_count_graph(graph_data) {
data_arr.push(graph_data[k]);
}
- data_arr.sort(function (a,b) {
+ data_arr.sort(function (a, b) {
if (a.visits.length > b.visits.length) {
return -1;
}
@@ -52,7 +87,6 @@ function visit_count_graph(graph_data) {
return 0;
});
-
x = d3.scale.linear()
.domain([0, d3.max(data_arr, function (d) {
return d.visits.length;
@@ -156,4 +190,7 @@ document.addEventListener("DOMContentLoaded", function () {
document.getElementById("visits_url").addEventListener("click", function () {
visit_count_graph(data);
});
+ document.getElementById("visits_timeline").addEventListener("click", function () {
+ visit_timeline(domain_data["www.google.com"].visits);
+ });
});

0 comments on commit 6392c7c

Please sign in to comment.