Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

flatten & proportional buttons

  • Loading branch information...
commit e333c0c245f1fe7560833a3dd59b7362ece568ff 1 parent db63e3e
Matthew Gerring authored
View
3  explorer/templates/index.html
@@ -7,6 +7,9 @@
<h2>Step <span id="currentStep">{{ params.step }}</span> of {{ step.count.steps }}, containing <span id="currentClusters">{{ step.count.clusters }}</span> clusters</h2>
<a class="button" href="/{{params.step}}/csv">Export to CSV</a>
</div>
+ <div class="chart_buttons">
+ <button id="makeFlat">Flat</button><button id="makeProportional">Proportional</button>
+ </div>
<div id="chart"></div>
<div id="cluster_overlay" {% if cluster %}class="show"{% endif %}>
<div id="close">Close</div>
View
51 media/js/libs/d3/treemap.js
@@ -1,4 +1,4 @@
-var w = 1140,
+var w = 1240,
h = 600,
color = d3.scale.category20c();
@@ -15,6 +15,21 @@ var div = d3.select("#chart").append("div")
.style("height", h + "px")
.style("margin", "0 auto");
+function treemapInnerHtml(params) {
+ if (params == 'undefined') params = clusterExplore.params;
+ div.selectAll('div')
+ .html(function(d, i) {
+ var ret = ""
+ if (d.children == null) {
+ ret += "<a href='/"+params.step+'/'+i+"'>"+d.count+" documents</a>";
+ //if (d.dx-1 > 80 || d.dy-1 > 80) {
+ ret += "<p>"+d.docs[0].text+"</p>";
+ //}
+ return ret;
+ }
+ });
+}
+
function drawIt(someData, params) {
//if (hash.substr(-1) != "/") hash = hash+"/";
@@ -36,19 +51,27 @@ function drawIt(someData, params) {
.style("width","0px")
.remove();
- div.selectAll('div')
- .html(function(d, i) {
- var ret = ""
- if (d.children == null) {
- ret += "<a href='/"+params.step+'/'+i+"'>"+d.count+" documents</a>";
- if (d.dx-1 > 80 || d.dy-1 > 80) {
- ret += "<p>"+d.docs[0].text+"</p>";
- }
- return ret;
- }
- })
-
- div.selectAll('div')
+ treemapInnerHtml(params);
+}
+
+function makeFlat() {
+ treemap.value(function(d){
+ return 1;
+ });
+ div.selectAll("div").data( treemap.nodes ).call(cell);
+ $(this).siblings().attr('disabled','');
+ $(this).attr('disabled','disabled');
+ treemapInnerHtml();
+}
+
+function makeProportional() {
+ treemap.value(function(d){
+ return d.count;
+ });
+ div.selectAll("div").data( treemap.nodes ).call(cell);
+ $(this).siblings().attr('disabled','');
+ $(this).attr('disabled','disabled');
+ treemapInnerHtml();
}
function cell() {
View
99 templates/base.html
@@ -79,53 +79,57 @@
]);
//all the jQuery
- $(function(){
- var clusterExplore = {
- ce : this,
-
- templates : {
- step : _.template("{% filter escapejs %}{% spaceless %}{% include "step-info.mt.html" %}{% endspaceless %}{% endfilter %}"),
- cluster : _.template("{% filter escapejs %}{% spaceless %}{% include "cluster-info.mt.html" %}{% endspaceless %}{% endfilter %}"),
- doc : _.template("{% filter escapejs %}{% spaceless %}{% include "doc.mt.html" %}{% endspaceless %}{% endfilter %}")
- },
+ var clusterExplore = {
+ ce : this,
- ajax : {
- step : function(data, hash) {
- $('#cluster_info').html(clusterExplore.templates.step({c : data, params : data.params}));
- $('#loader').delay(500).fadeOut('fast');
- $("#cluster_overlay #overlay_inner").empty();
- $("#cluster_overlay").attr('style','').attr('class','');
- drawIt(data.step, data.params);
- },
- cluster : function(data) {
- if ($("#cluster_overlay").is(":hidden")) {
- $("#cluster_overlay").css({display:"block"}).delay(50)
- .animate({
- position : "fixed",
- width : "80%",
- height : "80%",
- left : "10%",
- top : "10%",
- })
- }
- $("#cluster_overlay #overlay_inner").html(clusterExplore.templates.cluster({cluster: data.cluster}));
- },
- doc : function(data, state) {
- $('#'+state.data.id+" a").after(clusterExplore.templates.doc({ doc: data.doc }) );
- },
- callback: function(data, state, params) {
- if(data.step) {
- this.step(data);
- } else
- if (data.cluster) {
- this.cluster(data);
- } else
- if ( data.doc) {
- this.doc(data, state);
- }
+ params : [],
+
+ templates : {
+ step : _.template("{% filter escapejs %}{% spaceless %}{% include "step-info.mt.html" %}{% endspaceless %}{% endfilter %}"),
+ cluster : _.template("{% filter escapejs %}{% spaceless %}{% include "cluster-info.mt.html" %}{% endspaceless %}{% endfilter %}"),
+ doc : _.template("{% filter escapejs %}{% spaceless %}{% include "doc.mt.html" %}{% endspaceless %}{% endfilter %}")
+ },
+
+ ajax : {
+ step : function(data, hash) {
+ $('#cluster_info').html(clusterExplore.templates.step({c : data, params : data.params}));
+ $('#loader').delay(500).fadeOut('fast');
+ $("#cluster_overlay #overlay_inner").empty();
+ $("#cluster_overlay").attr('style','').attr('class','');
+ drawIt(data.step, data.params);
+ },
+ cluster : function(data) {
+ if ($("#cluster_overlay").is(":hidden")) {
+ $("#cluster_overlay").css({display:"block"}).delay(50)
+ .animate({
+ position : "fixed",
+ width : "80%",
+ height : "80%",
+ left : "10%",
+ top : "10%",
+ })
+ }
+ $("#cluster_overlay #overlay_inner").html(clusterExplore.templates.cluster({cluster: data.cluster}));
+ },
+ doc : function(data, state) {
+ $('#'+state.data.id+" a").after(clusterExplore.templates.doc({ doc: data.doc }) );
+ },
+ callback: function(data, state, params) {
+ clusterExplore.params = data.params;
+ if(data.step) {
+ this.step(data);
+ } else
+ if (data.cluster) {
+ this.cluster(data);
+ } else
+ if ( data.doc) {
+ this.doc(data, state);
}
- },
- }
+ }
+ },
+ }
+
+ $(function(){
//bind 'em
$(window).bind("statechange", function(){
var State = window.History.getState();
@@ -179,6 +183,7 @@
hash = window.History.getState().hash.split("/")[1];
window.History.pushState(null, null, "/"+hash)
});
+
$(".doc-link").live('click',
function(event) {
event.preventDefault();
@@ -193,12 +198,16 @@
}
}
)
+
$("#readmore").live('click',
function(event) {
event.preventDefault();
window.History.pushState(null,null,$(this).attr('href'));
}
);
+
+ $("#makeFlat").click(makeFlat);
+ $("#makeProportional").click(makeProportional);
});
</script>
Please sign in to comment.
Something went wrong with that request. Please try again.