@@ -24,7 +24,8 @@ var templateAttrs = {
2424 'in addition to any items the figure already has in this array.' ,
2525 'You can modify these items in the output figure by making your own' ,
2626 'item with `templateitemname` matching this `name`' ,
27- 'alongside your modifications (including `visible: false` to hide it).' ,
27+ 'alongside your modifications (including `visible: false` or' ,
28+ '`enabled: false` to hide it).' ,
2829 'Has no effect outside of a template.'
2930 ] . join ( ' ' )
3031 }
@@ -37,8 +38,8 @@ templateAttrs[TEMPLATEITEMNAME] = {
3738 'Used to refer to a named item in this array in the template. Named' ,
3839 'items from the template will be created even without a matching item' ,
3940 'in the input figure, but you can modify one by making an item with' ,
40- '`templateitemname` matching its `name`, alongside your' ,
41- 'modifications (including `visible: false` to hide it).' ,
41+ '`templateitemname` matching its `name`, alongside your modifications ' ,
42+ '(including `visible: false` or `enabled : false` to hide it).' ,
4243 'If there is no template or no matching item, this item will be' ,
4344 'hidden unless you explicitly show it with `visible: true`.'
4445 ] . join ( ' ' )
@@ -148,6 +149,8 @@ exports.newContainer = function(container, name, baseName) {
148149 * @param {string } name: the name of the array to template (ie 'annotations')
149150 * will be used to find default ('annotationdefaults' object) and specific
150151 * ('annotations' array) template specs.
152+ * @param {string } inclusionAttr: the attribute determining this item's
153+ * inclusion in the output, usually 'visible' or 'enabled'
151154 *
152155 * @returns {object }: {newItem, defaultItems}, both functions:
153156 * newItem(itemIn): create an output item, bare except for the correct
@@ -156,7 +159,7 @@ exports.newContainer = function(container, name, baseName) {
156159 * specific template items that have not already beeen included,
157160 * also as bare output items ready for supplyDefaults.
158161 */
159- exports . arrayTemplater = function ( container , name ) {
162+ exports . arrayTemplater = function ( container , name , inclusionAttr ) {
160163 var template = container . _template ;
161164 var defaultsTemplate = template && template [ arrayDefaultKey ( name ) ] ;
162165 var templateItems = template && template [ name ] ;
@@ -199,7 +202,7 @@ exports.arrayTemplater = function(container, name) {
199202 // to only be modifications it's most likely broken. Hide it unless
200203 // it's explicitly marked visible - in which case it gets NO template,
201204 // not even the default.
202- out . visible = itemIn . visible || false ;
205+ out [ inclusionAttr ] = itemIn [ inclusionAttr ] || false ;
203206 return out ;
204207 }
205208
0 commit comments