diff --git a/README.md b/README.md index 6f7ccd0..143625c 100644 --- a/README.md +++ b/README.md @@ -140,59 +140,58 @@ The `draw()` function parses through all the items of the treemap. You could use ### Treemap Creates a new empty Treemap with position (x, y), width and height. -To specify drawing a bit more, you can give drawing options. `order` is "sort" or "shuffle". -`direction` is either "horizontal", "vertical" or "both". With 'ignore', you can easily switch on and off branches of the Treemap. +To specify drawing a bit more, you can give drawing options. See method `setOptions()` for more information. Content may be added using `addData()` or `addItem()`. **Parameters** -- `x` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** x position -- `y` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** y position -- `w` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** width -- `h` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** height -- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** drawing and sorting options {sort:true or false, direction:"horizontal", "vertical" or "both", ignore:["abc", "xyz"]} +- `x` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** – X position +- `y` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** – Y position +- `w` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** – Width +- `h` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** – Height +- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** – Drawing options -Returns **[Treemap](#treemap)** the new empty Treemap +Returns **[Treemap](#treemap)** – The new empty Treemap #### x -x position of the rectangle. +X position of the rectangle. #### y -y position of the rectangle. +Y position of the rectangle. #### w -width of the rectangle. +Width of the rectangle. #### h -height of the rectangle. +Height of the rectangle. #### minValue -the minimum value of the items in the items array +The minimum value of the items in the items array #### maxValue -the maximum value of the items in the items array +The maximum value of the items in the items array #### level -level of the item; the root node has level 0 +Level of the item; the root node has level 0 #### depth -the depth of the branch; end nodes have depth 0 +The depth of the branch; end nodes have depth 0 #### itemCount -the number of items in the complete branch +The number of items in the complete branch #### index -index of the item in the sorted items array. +Index of the item in the sorted items array. ### addData @@ -227,7 +226,11 @@ Returns **[Treemap](#treemap)** – Returns the treemap where the data was added ### setOptions -Set order, padding, ... for next calculation of the treemap. +Set options for next calculation of the treemap. Currently there are the following options you might set: + +- order: 'sort', 'shuffle' or 'keep'. Default is 'sort'. Attention: don't use 'keep' for the first calculation of the treemap. +- direction: 'both, 'horizontal' or 'vertical'. Default is 'both'. +- padding: 0 (default) or any positive number. **Parameters** diff --git a/dist/Treemap.js b/dist/Treemap.js index b0aad77..42be70d 100644 --- a/dist/Treemap.js +++ b/dist/Treemap.js @@ -6,21 +6,20 @@ var packageInfo = require('./package.json'); /** * Creates a new empty Treemap with position (x, y), width and height. - * To specify drawing a bit more, you can give drawing options. `order` is "sort" or "shuffle". - * `direction` is either "horizontal", "vertical" or "both". With 'ignore', you can easily switch on and off branches of the Treemap. + * To specify drawing a bit more, you can give drawing options. See method `setOptions()` for more information. * Content may be added using `addData()` or `addItem()`. * * @class Treemap * @constructor - * @param {Number} x x position - * @param {Number} y y position - * @param {Number} w width - * @param {Number} h height - * @param {Object} [options] drawing and sorting options {sort:true or false, direction:"horizontal", "vertical" or "both", ignore:["abc", "xyz"]} - * @return {Treemap} the new empty Treemap + * @param {Number} x – X position + * @param {Number} y – Y position + * @param {Number} w – Width + * @param {Number} h – Height + * @param {Object} [options] – Drawing options + * @return {Treemap} – The new empty Treemap */ -/** +/* * @class Treemap * @ignore * @constructor (mainly for internal use) @@ -30,7 +29,7 @@ var packageInfo = require('./package.json'); * @return {Treemap} the new Treemap that represents one item */ -/** +/* * @class Treemap * @ignore * @constructor (mainly for internal use) @@ -45,25 +44,25 @@ function Treemap() { this.items = []; /** - * x position of the rectangle. + * X position of the rectangle. * @property x * @type {Number} */ this.x = 0; /** - * y position of the rectangle. + * Y position of the rectangle. * @property y * @type {Number} */ this.y = 0; /** - * width of the rectangle. + * Width of the rectangle. * @property w * @type {Number} */ this.w = 0; /** - * height of the rectangle. + * Height of the rectangle. * @property h * @type {Number} */ @@ -103,20 +102,20 @@ function Treemap() { /** - * the minimum value of the items in the items array + * The minimum value of the items in the items array * @property minValue * @type {Number} */ this.minValue = 0; /** - * the maximum value of the items in the items array + * The maximum value of the items in the items array * @property maxValue * @type {Number} */ this.maxValue = 0; /** - * level of the item; the root node has level 0 + * Level of the item; the root node has level 0 * @property level * @type {Number} */ @@ -124,21 +123,21 @@ function Treemap() { if (this.parent) this.level = this.parent.level + 1; /** - * the depth of the branch; end nodes have depth 0 + * The depth of the branch; end nodes have depth 0 * @property depth * @type {Number} */ this.depth = 0; /** - * the number of items in the complete branch + * The number of items in the complete branch * @property itemCount * @type {Number} */ this.itemCount = 1; /** - * index of the item in the sorted items array. + * Index of the item in the sorted items array. * @property index * @type {Number} */ @@ -266,7 +265,10 @@ function Treemap() { /** - * Set order, padding, ... for next calculation of the treemap. + * Set options for next calculation of the treemap. Currently there are the following options you might set: + * - order: 'sort', 'shuffle' or 'keep'. Default is 'sort'. Attention: don't use 'keep' for the first calculation of the treemap. + * - direction: 'both, 'horizontal' or 'vertical'. Default is 'both'. + * - padding: 0 (default) or any positive number. * * @method setOptions * @param {Object} options – Object in the form `{order: 'keep', padding: 4}` @@ -661,7 +663,7 @@ module.exports = Treemap; },{"./package.json":2}],2:[function(require,module,exports){ module.exports={ "name": "Treemap.js", - "version": "0.3.0", + "version": "0.4.0", "description": "A javascript library for calculating a treemap.", "license": "MIT", "main": "index.js", diff --git a/dist/Treemap.min.js b/dist/Treemap.min.js index f6ad048..b1d7c94 100644 --- a/dist/Treemap.min.js +++ b/dist/Treemap.min.js @@ -1 +1 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Treemap=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=4){this.x=arguments[0];this.y=arguments[1];this.w=arguments[2];this.h=arguments[3];this.options=arguments[4]||{}}else{this.parent=arguments[0];this.data=arguments[1];this.value=arguments[2]||0;if(typeof this.value=="object"){Object.keys(this.value).forEach(function(k){var v=parseFloat(this.value[k]);v=isNaN(v)?0:v;this.value[k]=v}.bind(this))}else{var v=parseFloat(this.value);v=isNaN(v)?0:v;this.value=v}}this.x=this.x||0;this.y=this.y||0;this.w=this.w||0;this.h=this.h||0;this.minValue=0;this.maxValue=0;this.level=0;if(this.parent)this.level=this.parent.level+1;this.depth=0;this.itemCount=1;this.index=0;this.root=this;this.isRoot=true;if(this.parent){this.root=this.parent.root;this.isRoot=false}this.options=this.options||this.root.options;this.ignored=false;Treemap.prototype.addData=function(data,opts){opts=opts||{};if(opts.data)this.data=data[opts.data];else this.data=data;if(typeof data==="number"){this.value=data}else{if(Array.isArray(opts.value)){if(typeof this.value!="object"){this.value={}}opts.value.forEach(function(k){this.value[k]=data[k]||0}.bind(this))}else{this.value=data[opts.value]||0}}var children=data;if(opts.children)children=data[opts.children];if(Array.isArray(children)){children.forEach(function(child){var t=new Treemap(this);this.items.push(t);t.addData(child,opts)}.bind(this));return true}return false};Treemap.prototype.addItem=function(data,keys,value){value=value||1;if(keys){var currItem=this;for(var j=0;j=0){if(j==keys.length-1)currItem.items[i].add(value);currItem=currItem.items[i]}else{var newItem=new Treemap(currItem,data[k],value);currItem.items.push(newItem);currItem=newItem}}return currItem}else{var i=this.items.findIndex(function(el){return el.data==data});if(i>=0){this.items[i].add(value);return false}else{var newItem=new Treemap(this,data,value);this.items.push(newItem)}return newItem}};Treemap.prototype.setOptions=function(opts){Object.keys(opts).forEach(function(k){this.options[k]=opts[k]}.bind(this));this.items.forEach(function(el){el.setOptions(opts)})};Treemap.prototype.addTreemap=function(data,value){var t=new Treemap(this,data,value);this.items.push(t);return t};Treemap.prototype.add=function(val){if(typeof val==="object"){if(typeof this.value!="object"){this.value={}}Object.keys(val).forEach(function(k){var v=parseFloat(val[k]);v=isNaN(v)?0:v;if(this.value[k]){this.value[k]+=v}else{this.value[k]=v}}.bind(this))}else{var v=parseFloat(val);this.value+=isNaN(v)?0:v}};Treemap.prototype.sumUpValues=function(valueKey){if(Array.isArray(this.options.ignore)){if(this.options.ignore.indexOf(this.data)>=0){this.ignored=true}else{this.ignored=false}}if(this.items.length==0){if(this.ignored)return valueKey?{}:0}else{this.minValue=Number.MAX_VALUE;this.maxValue=0;this.depth=0;this.itemCount=1;this.value=valueKey?{}:0;if(this.ignored)return valueKey?{}:0;for(var i=0;ib.value[valueKey])return-1}else{if(a.valueb.value)return-1}return 0})}else if(this.root.options.order=="shuffle"){shuffleArray(this.items)}for(var i=0;irestH||this.root.options.direction=="vertical"){isHorizontal=false;a=restH;b=restW}}var rowSum=0;var rowCount=0;var avRelPrev=Number.MAX_VALUE;for(var i=actIndex;i0;i--){var j=Math.floor(Math.random()*(i+1));var temp=array[i];array[i]=array[j];array[j]=temp}}if(!Array.isArray){Array.isArray=function(obj){return Object.prototype.toString.call(obj)=="[object Array]"}}module.exports=Treemap},{"./package.json":2}],2:[function(require,module,exports){module.exports={name:"Treemap.js",version:"0.3.0",description:"A javascript library for calculating a treemap.",license:"MIT",main:"index.js",scripts:{bundle:"browserify index.js --standalone Treemap -o dist/Treemap.js",devbundle:"npm run bundle && copyfiles -u 1 dist/Treemap.js examples/lib/",dist:"npm run bundle && browserify index.js --standalone Treemap | uglifyjs > dist/Treemap.min.js && copyfiles -u 1 dist/Treemap.js examples/lib/",documentation:"documentation readme index.js --section=Reference",onchange:"onchange 'index.js' -- npm run devbundle"},repository:{type:"git",url:"https://github.com/bohnacker/Treemap.js"},keywords:["dataviz","graph","treemap","recursive"],author:"Hartmut Bohnacker ",bugs:{url:"https://github.com/bohnacker/Treemap.js/issues"},homepage:"https://github.com/bohnacker/Treemap.js",devDependencies:{browserify:"^14.4.0",documentation:"^5.2.2","uglify-js":"^3.0.28",watch:"1.0.2",onchange:"6.0.0"}}},{}]},{},[1])(1)}); +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Treemap=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=4){this.x=arguments[0];this.y=arguments[1];this.w=arguments[2];this.h=arguments[3];this.options=arguments[4]||{}}else{this.parent=arguments[0];this.data=arguments[1];this.value=arguments[2]||0;if(typeof this.value=="object"){Object.keys(this.value).forEach(function(k){var v=parseFloat(this.value[k]);v=isNaN(v)?0:v;this.value[k]=v}.bind(this))}else{var v=parseFloat(this.value);v=isNaN(v)?0:v;this.value=v}}this.x=this.x||0;this.y=this.y||0;this.w=this.w||0;this.h=this.h||0;this.minValue=0;this.maxValue=0;this.level=0;if(this.parent)this.level=this.parent.level+1;this.depth=0;this.itemCount=1;this.index=0;this.root=this;this.isRoot=true;if(this.parent){this.root=this.parent.root;this.isRoot=false}this.options=this.options||this.root.options;this.ignored=false;Treemap.prototype.addData=function(data,opts){opts=opts||{};if(opts.data)this.data=data[opts.data];else this.data=data;if(typeof data==="number"){this.value=data}else{if(Array.isArray(opts.value)){if(typeof this.value!="object"){this.value={}}opts.value.forEach(function(k){this.value[k]=data[k]||0}.bind(this))}else{this.value=data[opts.value]||0}}var children=data;if(opts.children)children=data[opts.children];if(Array.isArray(children)){children.forEach(function(child){var t=new Treemap(this);this.items.push(t);t.addData(child,opts)}.bind(this));return true}return false};Treemap.prototype.addItem=function(data,keys,value){value=value||1;if(keys){var currItem=this;for(var j=0;j=0){if(j==keys.length-1)currItem.items[i].add(value);currItem=currItem.items[i]}else{var newItem=new Treemap(currItem,data[k],value);currItem.items.push(newItem);currItem=newItem}}return currItem}else{var i=this.items.findIndex(function(el){return el.data==data});if(i>=0){this.items[i].add(value);return false}else{var newItem=new Treemap(this,data,value);this.items.push(newItem)}return newItem}};Treemap.prototype.setOptions=function(opts){Object.keys(opts).forEach(function(k){this.options[k]=opts[k]}.bind(this));this.items.forEach(function(el){el.setOptions(opts)})};Treemap.prototype.addTreemap=function(data,value){var t=new Treemap(this,data,value);this.items.push(t);return t};Treemap.prototype.add=function(val){if(typeof val==="object"){if(typeof this.value!="object"){this.value={}}Object.keys(val).forEach(function(k){var v=parseFloat(val[k]);v=isNaN(v)?0:v;if(this.value[k]){this.value[k]+=v}else{this.value[k]=v}}.bind(this))}else{var v=parseFloat(val);this.value+=isNaN(v)?0:v}};Treemap.prototype.sumUpValues=function(valueKey){if(Array.isArray(this.options.ignore)){if(this.options.ignore.indexOf(this.data)>=0){this.ignored=true}else{this.ignored=false}}if(this.items.length==0){if(this.ignored)return valueKey?{}:0}else{this.minValue=Number.MAX_VALUE;this.maxValue=0;this.depth=0;this.itemCount=1;this.value=valueKey?{}:0;if(this.ignored)return valueKey?{}:0;for(var i=0;ib.value[valueKey])return-1}else{if(a.valueb.value)return-1}return 0})}else if(this.root.options.order=="shuffle"){shuffleArray(this.items)}for(var i=0;irestH||this.root.options.direction=="vertical"){isHorizontal=false;a=restH;b=restW}}var rowSum=0;var rowCount=0;var avRelPrev=Number.MAX_VALUE;for(var i=actIndex;i0;i--){var j=Math.floor(Math.random()*(i+1));var temp=array[i];array[i]=array[j];array[j]=temp}}if(!Array.isArray){Array.isArray=function(obj){return Object.prototype.toString.call(obj)=="[object Array]"}}module.exports=Treemap},{"./package.json":2}],2:[function(require,module,exports){module.exports={name:"Treemap.js",version:"0.4.0",description:"A javascript library for calculating a treemap.",license:"MIT",main:"index.js",scripts:{bundle:"browserify index.js --standalone Treemap -o dist/Treemap.js",devbundle:"npm run bundle && copyfiles -u 1 dist/Treemap.js examples/lib/",dist:"npm run bundle && browserify index.js --standalone Treemap | uglifyjs > dist/Treemap.min.js && copyfiles -u 1 dist/Treemap.js examples/lib/",documentation:"documentation readme index.js --section=Reference",onchange:"onchange 'index.js' -- npm run devbundle"},repository:{type:"git",url:"https://github.com/bohnacker/Treemap.js"},keywords:["dataviz","graph","treemap","recursive"],author:"Hartmut Bohnacker ",bugs:{url:"https://github.com/bohnacker/Treemap.js/issues"},homepage:"https://github.com/bohnacker/Treemap.js",devDependencies:{browserify:"^14.4.0",documentation:"^5.2.2","uglify-js":"^3.0.28",watch:"1.0.2",onchange:"6.0.0"}}},{}]},{},[1])(1)}); diff --git a/examples/lib/Treemap.js b/examples/lib/Treemap.js index b0aad77..42be70d 100644 --- a/examples/lib/Treemap.js +++ b/examples/lib/Treemap.js @@ -6,21 +6,20 @@ var packageInfo = require('./package.json'); /** * Creates a new empty Treemap with position (x, y), width and height. - * To specify drawing a bit more, you can give drawing options. `order` is "sort" or "shuffle". - * `direction` is either "horizontal", "vertical" or "both". With 'ignore', you can easily switch on and off branches of the Treemap. + * To specify drawing a bit more, you can give drawing options. See method `setOptions()` for more information. * Content may be added using `addData()` or `addItem()`. * * @class Treemap * @constructor - * @param {Number} x x position - * @param {Number} y y position - * @param {Number} w width - * @param {Number} h height - * @param {Object} [options] drawing and sorting options {sort:true or false, direction:"horizontal", "vertical" or "both", ignore:["abc", "xyz"]} - * @return {Treemap} the new empty Treemap + * @param {Number} x – X position + * @param {Number} y – Y position + * @param {Number} w – Width + * @param {Number} h – Height + * @param {Object} [options] – Drawing options + * @return {Treemap} – The new empty Treemap */ -/** +/* * @class Treemap * @ignore * @constructor (mainly for internal use) @@ -30,7 +29,7 @@ var packageInfo = require('./package.json'); * @return {Treemap} the new Treemap that represents one item */ -/** +/* * @class Treemap * @ignore * @constructor (mainly for internal use) @@ -45,25 +44,25 @@ function Treemap() { this.items = []; /** - * x position of the rectangle. + * X position of the rectangle. * @property x * @type {Number} */ this.x = 0; /** - * y position of the rectangle. + * Y position of the rectangle. * @property y * @type {Number} */ this.y = 0; /** - * width of the rectangle. + * Width of the rectangle. * @property w * @type {Number} */ this.w = 0; /** - * height of the rectangle. + * Height of the rectangle. * @property h * @type {Number} */ @@ -103,20 +102,20 @@ function Treemap() { /** - * the minimum value of the items in the items array + * The minimum value of the items in the items array * @property minValue * @type {Number} */ this.minValue = 0; /** - * the maximum value of the items in the items array + * The maximum value of the items in the items array * @property maxValue * @type {Number} */ this.maxValue = 0; /** - * level of the item; the root node has level 0 + * Level of the item; the root node has level 0 * @property level * @type {Number} */ @@ -124,21 +123,21 @@ function Treemap() { if (this.parent) this.level = this.parent.level + 1; /** - * the depth of the branch; end nodes have depth 0 + * The depth of the branch; end nodes have depth 0 * @property depth * @type {Number} */ this.depth = 0; /** - * the number of items in the complete branch + * The number of items in the complete branch * @property itemCount * @type {Number} */ this.itemCount = 1; /** - * index of the item in the sorted items array. + * Index of the item in the sorted items array. * @property index * @type {Number} */ @@ -266,7 +265,10 @@ function Treemap() { /** - * Set order, padding, ... for next calculation of the treemap. + * Set options for next calculation of the treemap. Currently there are the following options you might set: + * - order: 'sort', 'shuffle' or 'keep'. Default is 'sort'. Attention: don't use 'keep' for the first calculation of the treemap. + * - direction: 'both, 'horizontal' or 'vertical'. Default is 'both'. + * - padding: 0 (default) or any positive number. * * @method setOptions * @param {Object} options – Object in the form `{order: 'keep', padding: 4}` @@ -661,7 +663,7 @@ module.exports = Treemap; },{"./package.json":2}],2:[function(require,module,exports){ module.exports={ "name": "Treemap.js", - "version": "0.3.0", + "version": "0.4.0", "description": "A javascript library for calculating a treemap.", "license": "MIT", "main": "index.js", diff --git a/index.js b/index.js index 92bf1fe..207ac5d 100644 --- a/index.js +++ b/index.js @@ -5,21 +5,20 @@ var packageInfo = require('./package.json'); /** * Creates a new empty Treemap with position (x, y), width and height. - * To specify drawing a bit more, you can give drawing options. `order` is "sort" or "shuffle". - * `direction` is either "horizontal", "vertical" or "both". With 'ignore', you can easily switch on and off branches of the Treemap. + * To specify drawing a bit more, you can give drawing options. See method `setOptions()` for more information. * Content may be added using `addData()` or `addItem()`. * * @class Treemap * @constructor - * @param {Number} x x position - * @param {Number} y y position - * @param {Number} w width - * @param {Number} h height - * @param {Object} [options] drawing and sorting options {sort:true or false, direction:"horizontal", "vertical" or "both", ignore:["abc", "xyz"]} - * @return {Treemap} the new empty Treemap + * @param {Number} x – X position + * @param {Number} y – Y position + * @param {Number} w – Width + * @param {Number} h – Height + * @param {Object} [options] – Drawing options + * @return {Treemap} – The new empty Treemap */ -/** +/* * @class Treemap * @ignore * @constructor (mainly for internal use) @@ -29,7 +28,7 @@ var packageInfo = require('./package.json'); * @return {Treemap} the new Treemap that represents one item */ -/** +/* * @class Treemap * @ignore * @constructor (mainly for internal use) @@ -44,25 +43,25 @@ function Treemap() { this.items = []; /** - * x position of the rectangle. + * X position of the rectangle. * @property x * @type {Number} */ this.x = 0; /** - * y position of the rectangle. + * Y position of the rectangle. * @property y * @type {Number} */ this.y = 0; /** - * width of the rectangle. + * Width of the rectangle. * @property w * @type {Number} */ this.w = 0; /** - * height of the rectangle. + * Height of the rectangle. * @property h * @type {Number} */ @@ -102,20 +101,20 @@ function Treemap() { /** - * the minimum value of the items in the items array + * The minimum value of the items in the items array * @property minValue * @type {Number} */ this.minValue = 0; /** - * the maximum value of the items in the items array + * The maximum value of the items in the items array * @property maxValue * @type {Number} */ this.maxValue = 0; /** - * level of the item; the root node has level 0 + * Level of the item; the root node has level 0 * @property level * @type {Number} */ @@ -123,21 +122,21 @@ function Treemap() { if (this.parent) this.level = this.parent.level + 1; /** - * the depth of the branch; end nodes have depth 0 + * The depth of the branch; end nodes have depth 0 * @property depth * @type {Number} */ this.depth = 0; /** - * the number of items in the complete branch + * The number of items in the complete branch * @property itemCount * @type {Number} */ this.itemCount = 1; /** - * index of the item in the sorted items array. + * Index of the item in the sorted items array. * @property index * @type {Number} */ @@ -265,7 +264,10 @@ function Treemap() { /** - * Set order, padding, ... for next calculation of the treemap. + * Set options for next calculation of the treemap. Currently there are the following options you might set: + * - order: 'sort', 'shuffle' or 'keep'. Default is 'sort'. Attention: don't use 'keep' for the first calculation of the treemap. + * - direction: 'both, 'horizontal' or 'vertical'. Default is 'both'. + * - padding: 0 (default) or any positive number. * * @method setOptions * @param {Object} options – Object in the form `{order: 'keep', padding: 4}` diff --git a/package.json b/package.json index 9fb845f..7d1259c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Treemap.js", - "version": "0.3.0", + "version": "0.4.0", "description": "A javascript library for calculating a treemap.", "license": "MIT", "main": "index.js",