A5.u.arraystack Method
Syntax
Arguments
- arrayarray
The array to stack.
- settingsobject
The settings to use for stacking the array.
- startstring
The property name in each array entry in which the start value is stored.
- endstring
The property name in each array entry in which the end value is stored.
- sizestring
The property name in each array entry in which the size value is stored.
- stackarray
An array of arrays stacked so that if visually presented no array entries would overlap.
Description
Stack an array of object for visual presentation based on a start value and an end or size value.
Discussion
The A5.u.object.stack method allows for the linear stacking of an array of objects so that when visually presented there will be now overlaps. A "start" property must always be passed in, but the "end" can be automatically calculated by passing in a "size" property (which will be added to the "start" to get the "end").
Example
var d = [ {start: 25, end: 300, color: 'red'}, {start: 10, end: 20, color: 'blue'}, {start: 25, end: 200, color: 'green'}, {start: 300, end: 320, color: 'purple'}, {start: 310, end: 340, color: 'yellow'}, {start: 340, end: 400, color: 'red'}, {start: 340, end: 400, color: 'purple'}, {start: 340, end: 400, color: 'blue'}, {start: 340, end: 400, color: 'green'} ] var stack = A5.u.array.stack(d,{start: 'start', end: 'end'}); // stack = [ // [{"start":10,"end":20,"color":"blue"},{"start":25,"end":300,"color":"red"},{"start":300,"end":320,"color":"purple"},{"start":340,"end":400,"color":"red"}], // [{"start":25,"end":200,"color":"green"},{"start":310,"end":340,"color":"yellow"},{"start":340,"end":400,"color":"purple"}], // [{"start":340,"end":400,"color":"blue"}],[{"start":340,"end":400,"color":"green"}] // ]