Skip to content

Commit

Permalink
#48 changing the order of the arguments (declaring key first)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Jul 17, 2013
1 parent 1dab7ae commit 28cde70
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build/cloudvisio-min.js

Large diffs are not rendered by default.

32 changes: 27 additions & 5 deletions build/cloudvisio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @name cloudvisio - 0.6.0 (Tue, 16 Jul 2013 14:16:09 GMT)
// @name cloudvisio - 0.6.0 (Wed, 17 Jul 2013 06:18:25 GMT)
// @url https://github.com/makesites/cloudvisio

// @author makesites
Expand Down Expand Up @@ -576,14 +576,36 @@ Cloudvisio.prototype.find = function( query, options ){


// create an axis by grouping the raw data
Cloudvisio.prototype.group = function( groups, key, options){
Cloudvisio.prototype.group = function(){
// for no arguments (or more arguments) just exit
if( !arguments.length ) return this;
// variables
var key, groups, options, field;
// count arguments (groups are optional)
switch( arguments.length ){
case 1:
key = arguments[0];
break;
case 2:
key = arguments[0];
if( arguments[1] instanceof Array ){
groups = arguments[1];
} else {
options = arguments[1];
}
break;
default:
key = arguments[0];
groups = arguments[1];
options = arguments[2];
break;
}
// fallbacks
options = options || {};
// variables
// get the (working) data
var data = this.data();
var field;
// convert groups to lower case
groups = groups.join("`").toLowerCase().split("`");
if( groups ) groups = groups.join("`").toLowerCase().split("`");
// reset models if needed
if( options.reset ){
// create a model set equal to the length of the groups
Expand Down
52 changes: 26 additions & 26 deletions examples/gists.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
var vis;

$(function(){

vis = new Cloudvisio({
layout: "force"
});
layout: "force"
});
requestUser();
});

Expand All @@ -28,24 +28,24 @@
}

function getData( user ){

$.getJSON("https://api.github.com/users/"+ user +"/gists?callback=?", function(response){
if( response.meta.status == 200 ){
if( response.meta.status == 200 ){
renderGraph( response.data );
}
});

}

function renderGraph( data ){
vis.data( data );
console.log( vis.keys() );
vis.axis("description");
vis.group([true, false], "public");
//vis.set({ chart: { radius : 10 } });
vis.axis("comments");
//vis.gt(0, "comments");
vis.render();
vis.data( data );
console.log( vis.keys() );
vis.axis("description");
vis.group("public", [true, false]);
//vis.set({ chart: { radius : 10 } });
vis.axis("comments");
//vis.gt(0, "comments");
vis.render();
}

</script>
Expand All @@ -56,7 +56,7 @@
width: 100%;
height: 100%;
}

header {
position: absolute;
padding: 12px;
Expand All @@ -68,17 +68,17 @@
<body>

<header>
<h2>Gists</h2>
<p>Grouping a user's public gists sized based on number of comments</p>
<pre>
vis = new Cloudvisio({
layout: "force"
});
vis.axis("created_at");
vis.group([true, false], "public");
vis.axis("comments");
vis.render();
</pre>
<h2>Gists</h2>
<p>Grouping a user's public gists sized based on number of comments</p>
<pre>
vis = new Cloudvisio({
layout: "force"
});
vis.axis("created_at");
vis.group("public", [true, false]);
vis.axis("comments");
vis.render();
</pre>
</header>

<div id="vis"><!-- --></div>
Expand Down
4 changes: 2 additions & 2 deletions examples/income.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
vis.axis("radius", 5);
// create a new axis
vis.axis("name");
vis.group(["high", "Medium", "Low"], "incomeLevel");
vis.group("incomeLevel", ["High", "Medium", "Low"]);

vis.render();
});
Expand Down Expand Up @@ -70,7 +70,7 @@ <h3>countries split in high/medium/low groups</h3>
vis.axis("radius", 5);

vis.axis("name");
vis.group(["high", "Medium", "Low"], "incomeLevel");
vis.group("incomeLevel", ["High", "Medium", "Low"]);

vis.render();
});
Expand Down
30 changes: 26 additions & 4 deletions lib/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,36 @@ Cloudvisio.prototype.find = function( query, options ){


// create an axis by grouping the raw data
Cloudvisio.prototype.group = function( groups, key, options){
Cloudvisio.prototype.group = function(){
// for no arguments (or more arguments) just exit
if( !arguments.length ) return this;
// variables
var key, groups, options, field;
// count arguments (groups are optional)
switch( arguments.length ){
case 1:
key = arguments[0];
break;
case 2:
key = arguments[0];
if( arguments[1] instanceof Array ){
groups = arguments[1];
} else {
options = arguments[1];
}
break;
default:
key = arguments[0];
groups = arguments[1];
options = arguments[2];
break;
}
// fallbacks
options = options || {};
// variables
// get the (working) data
var data = this.data();
var field;
// convert groups to lower case
groups = groups.join("`").toLowerCase().split("`");
if( groups ) groups = groups.join("`").toLowerCase().split("`");
// reset models if needed
if( options.reset ){
// create a model set equal to the length of the groups
Expand Down

0 comments on commit 28cde70

Please sign in to comment.