@@ -12,42 +12,69 @@ var Lib = require('../lib');
12
12
var extendFlat = Lib . extendFlat ;
13
13
var isPlainObject = Lib . isPlainObject ;
14
14
15
+ var traceOpts = {
16
+ valType : 'flaglist' ,
17
+ extras : [ 'none' ] ,
18
+ flags : [ 'calc' , 'calcIfAutorange' , 'plot' , 'style' , 'colorbars' ] ,
19
+ description : [
20
+ 'trace attributes should include an `editType` string matching this flaglist.' ,
21
+ '*calc* is the most extensive: a full `Plotly.plot` starting by clearing `gd.calcdata`' ,
22
+ 'to force it to be regenerated' ,
23
+ '*calcIfAutorange* does a full `Plotly.plot`, but only clears and redoes `gd.calcdata`' ,
24
+ 'if there is at least one autoranged axis.' ,
25
+ '*plot* calls `Plotly.plot` but without first clearing `gd.calcdata`.' ,
26
+ '*style* only calls `module.style` for all trace modules and redraws the legend.' ,
27
+ '*colorbars* only redraws colorbars.'
28
+ ] . join ( ' ' )
29
+ } ;
30
+
31
+ var layoutOpts = {
32
+ valType : 'flaglist' ,
33
+ extras : [ 'none' ] ,
34
+ flags : [
35
+ 'calc' , 'calcIfAutorange' , 'plot' , 'legend' , 'ticks' ,
36
+ 'layoutstyle' , 'modebar' , 'camera' , 'arraydraw'
37
+ ] ,
38
+ description : [
39
+ 'layout attributes should include an `editType` string matching this flaglist.' ,
40
+ '*calc* is the most extensive: a full `Plotly.plot` starting by clearing `gd.calcdata`' ,
41
+ 'to force it to be regenerated' ,
42
+ '*calcIfAutorange* does a full `Plotly.plot`, but only clears and redoes `gd.calcdata`' ,
43
+ 'if there is at least one autoranged axis.' ,
44
+ '*plot* calls `Plotly.plot` but without first clearing `gd.calcdata`.' ,
45
+ '*legend* only redraws the legend.' ,
46
+ '*ticks* only redraws axis ticks, labels, and gridlines.' ,
47
+ '*layoutstyle* reapplies global and SVG cartesian axis styles.' ,
48
+ '*modebar* just updates the modebar.' ,
49
+ '*camera* just updates the camera settings for gl3d scenes.' ,
50
+ '*arraydraw* allows component arrays to invoke the redraw routines just for the' ,
51
+ 'component(s) that changed.'
52
+ ] . join ( ' ' )
53
+ } ;
54
+
55
+ // flags for inside restyle/relayout include a few extras
56
+ // that shouldn't be used in attributes, to deal with certain
57
+ // combinations and conditionals efficiently
58
+ var traceEditTypeFlags = traceOpts . flags . slice ( )
59
+ . concat ( [ 'clearCalc' , 'fullReplot' ] ) ;
60
+
61
+ var layoutEditTypeFlags = layoutOpts . flags . slice ( )
62
+ . concat ( 'layoutReplot' ) ;
63
+
15
64
module . exports = {
65
+ traces : traceOpts ,
66
+ layout : layoutOpts ,
16
67
/*
17
68
* default (all false) edit flags for restyle (traces)
18
69
* creates a new object each call, so the caller can mutate freely
19
70
*/
20
- traces : function ( ) {
21
- return {
22
- calc : false ,
23
- calcIfAutorange : false ,
24
- plot : false ,
25
- style : false ,
26
- colorbars : false ,
27
- autorangeOn : false ,
28
- clearCalc : false ,
29
- fullReplot : false
30
- } ;
31
- } ,
71
+ traceFlags : function ( ) { return falseObj ( traceEditTypeFlags ) ; } ,
32
72
33
73
/*
34
74
* default (all false) edit flags for relayout
35
75
* creates a new object each call, so the caller can mutate freely
36
76
*/
37
- layout : function ( ) {
38
- return {
39
- legend : false ,
40
- ticks : false ,
41
- layoutstyle : false ,
42
- plot : false ,
43
- calc : false ,
44
- calcIfAutorange : false ,
45
- modebar : false ,
46
- camera : false ,
47
- arraydraw : false ,
48
- layoutReplot : false
49
- } ;
50
- } ,
77
+ layoutFlags : function ( ) { return falseObj ( layoutEditTypeFlags ) ; } ,
51
78
52
79
/*
53
80
* update `flags` with the `editType` values found in `attr`
@@ -65,6 +92,12 @@ module.exports = {
65
92
overrideAll : overrideAll
66
93
} ;
67
94
95
+ function falseObj ( keys ) {
96
+ var out = { } ;
97
+ for ( var i = 0 ; i < keys . length ; i ++ ) out [ keys [ i ] ] = false ;
98
+ return out ;
99
+ }
100
+
68
101
/**
69
102
* For attributes that are largely copied from elsewhere into a plot type that doesn't
70
103
* support partial redraws - overrides the editType field of all attributes in the object
0 commit comments