Created
May 9, 2012 21:07
-
-
Save rwaldron/2648835 to your computer and use it in GitHub Desktop.
WTF is this? http://bost.ocks.org/mike/chart/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will create constructed instances that can be easily extended | |
function Chart( width, height ) { | |
if ( !(this instanceof Chart) ) { | |
return new Chart( width || null, height || null ); | |
} | |
this.width = width || 720; | |
this.height = height || 80; | |
// construct your charts here... | |
} | |
Chart.prototype.width = function( value ) { | |
if ( !arguments.length ) return this.width; | |
this.width = value; | |
return this; | |
}; | |
Chart.prototype.height = function( value ) { | |
if ( !arguments.length ) return this.height; | |
this.height = value; | |
return this; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is JUST a function object with "static" expando properties | |
function chart() { | |
var width = 720, // default width | |
height = 80; // default height | |
function my() { | |
// generate chart here, using `width` and `height` | |
} | |
my.width = function(value) { | |
if (!arguments.length) return width; | |
width = value; | |
return my; | |
}; | |
my.height = function(value) { | |
if (!arguments.length) return height; | |
height = value; | |
return my; | |
}; | |
return my; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment