@@ -24,7 +24,8 @@ var templateAttrs = {
24
24
'in addition to any items the figure already has in this array.' ,
25
25
'You can modify these items in the output figure by making your own' ,
26
26
'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).' ,
28
29
'Has no effect outside of a template.'
29
30
] . join ( ' ' )
30
31
}
@@ -37,8 +38,8 @@ templateAttrs[TEMPLATEITEMNAME] = {
37
38
'Used to refer to a named item in this array in the template. Named' ,
38
39
'items from the template will be created even without a matching item' ,
39
40
'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).' ,
42
43
'If there is no template or no matching item, this item will be' ,
43
44
'hidden unless you explicitly show it with `visible: true`.'
44
45
] . join ( ' ' )
@@ -148,6 +149,8 @@ exports.newContainer = function(container, name, baseName) {
148
149
* @param {string } name: the name of the array to template (ie 'annotations')
149
150
* will be used to find default ('annotationdefaults' object) and specific
150
151
* ('annotations' array) template specs.
152
+ * @param {string } inclusionAttr: the attribute determining this item's
153
+ * inclusion in the output, usually 'visible' or 'enabled'
151
154
*
152
155
* @returns {object }: {newItem, defaultItems}, both functions:
153
156
* newItem(itemIn): create an output item, bare except for the correct
@@ -156,7 +159,7 @@ exports.newContainer = function(container, name, baseName) {
156
159
* specific template items that have not already beeen included,
157
160
* also as bare output items ready for supplyDefaults.
158
161
*/
159
- exports . arrayTemplater = function ( container , name ) {
162
+ exports . arrayTemplater = function ( container , name , inclusionAttr ) {
160
163
var template = container . _template ;
161
164
var defaultsTemplate = template && template [ arrayDefaultKey ( name ) ] ;
162
165
var templateItems = template && template [ name ] ;
@@ -199,7 +202,7 @@ exports.arrayTemplater = function(container, name) {
199
202
// to only be modifications it's most likely broken. Hide it unless
200
203
// it's explicitly marked visible - in which case it gets NO template,
201
204
// not even the default.
202
- out . visible = itemIn . visible || false ;
205
+ out [ inclusionAttr ] = itemIn [ inclusionAttr ] || false ;
203
206
return out ;
204
207
}
205
208
0 commit comments