Skip to content
Snippets Groups Projects
Commit 1b77a3eb authored by alvaro's avatar alvaro
Browse files

Fixed issues with d3dendrogram

Added random,horizontal and vertical layour to wordcloud
parent 0d0ceaa8
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ class Haanga_Extension_Filter_D3Dendrogram{ ...@@ -35,7 +35,7 @@ class Haanga_Extension_Filter_D3Dendrogram{
} }
//options //options
$options = array(); $options = array();
$options['width'] = 960; $options['width'] = 600;
$options['height'] = 500; $options['height'] = 500;
$options['color'] = '#aec7e8'; $options['color'] = '#aec7e8';
$options['highlightedColor'] = '#00477f'; $options['highlightedColor'] = '#00477f';
...@@ -88,8 +88,8 @@ class Haanga_Extension_Filter_D3Dendrogram{ ...@@ -88,8 +88,8 @@ class Haanga_Extension_Filter_D3Dendrogram{
<script> <script>
// Based on http://bost.ocks.org/mike/treemap/ // Based on http://bost.ocks.org/mike/treemap/
function initD3TreeMaps'.$randId.'(json){ function initD3TreeMaps'.$randId.'(json){
var width = 600, var width = '.$options['width'].',
height = 500; height = '.$options['height'].';
var cluster = d3.layout.cluster() var cluster = d3.layout.cluster()
.size([height, width - 200]); .size([height, width - 200]);
......
...@@ -77,6 +77,7 @@ function D3WordCloud'.$randId.'(words, newcfg){ ...@@ -77,6 +77,7 @@ function D3WordCloud'.$randId.'(words, newcfg){
font: "sans-serif", font: "sans-serif",
minsize: 10, minsize: 10,
maxsize: 100, maxsize: 100,
wordOrientation: "random",
color: "black", color: "black",
stopwords: ["of", "the", "a", "or", "to", "and", "for", "at", "with", "without", "in", "from", "is", "are", "were", "was", "this", "that", "these", "those", "in", "on"] stopwords: ["of", "the", "a", "or", "to", "and", "for", "at", "with", "without", "in", "from", "is", "are", "were", "was", "this", "that", "these", "those", "in", "on"]
}; };
...@@ -112,7 +113,7 @@ function D3WordCloud'.$randId.'(words, newcfg){ ...@@ -112,7 +113,7 @@ function D3WordCloud'.$randId.'(words, newcfg){
.words(totalWords.map(function(d) { .words(totalWords.map(function(d) {
return {text: d.name, size: parseInt(cfg.minsize + (cfg.maxsize-cfg.minsize)*(d.total/maxValue))}; return {text: d.name, size: parseInt(cfg.minsize + (cfg.maxsize-cfg.minsize)*(d.total/maxValue))};
})) }))
.rotate(function() { return ~~(Math.random() * 2) * 90; }) .rotate(function() { var x=~~(Math.random() * 2) * 90; if(cfg.wordOrientation == "horizontal"){x = 0;}if(cfg.wordOrientation == "vertical"){x = 90;} return x; })
.padding(1) .padding(1)
.font("arial") .font("arial")
.fontSize(function(d) { return d.size; }) .fontSize(function(d) { return d.size; })
...@@ -127,7 +128,7 @@ function D3WordCloud'.$randId.'(words, newcfg){ ...@@ -127,7 +128,7 @@ function D3WordCloud'.$randId.'(words, newcfg){
.attr("transform", "translate("+cfg.width/2+","+cfg.height/2+")"); .attr("transform", "translate("+cfg.width/2+","+cfg.height/2+")");
g.selectAll("text").data(words) g.selectAll("text").data(words)
.enter().append("a").attr("xlink:href", function(d){console.log(d);return wordLinks[d.text]}).append("text") .enter().append("a").attr("xlink:href", function(d){return wordLinks[d.text]}).append("text")
.style("font-family", cfg.font) .style("font-family", cfg.font)
.style("font-size", function(d) { return d.size + "px"; }) .style("font-size", function(d) { return d.size + "px"; })
.style("fill", cfg.color) .style("fill", cfg.color)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment