@@ -34,6 +34,13 @@ var dc = {
34
34
} ;
35
35
/*jshint +W079*/
36
36
37
+ /**
38
+ * dc.chartRegistry maintains a mapping of all instantiated dc.js charts under a given or a default group
39
+ * to facilitate rendering and filtering charts simultaneously using the functions dc.filterAll,
40
+ * dc.refocusAll, renderAll, redrawAll.
41
+ *
42
+ * @type {{has, register, deregister, clear, list} }
43
+ */
37
44
dc . chartRegistry = ( function ( ) {
38
45
// chartGroup:string => charts:array
39
46
var _chartMap = { } ;
@@ -51,6 +58,11 @@ dc.chartRegistry = (function () {
51
58
}
52
59
53
60
return {
61
+ /**
62
+ * Determine if a given chart instance resides in any group in the registry.
63
+ * @param {* } chart dc.js chart instance
64
+ * @returns {Boolean }
65
+ */
54
66
has : function ( chart ) {
55
67
for ( var e in _chartMap ) {
56
68
if ( _chartMap [ e ] . indexOf ( chart ) >= 0 ) {
@@ -60,11 +72,23 @@ dc.chartRegistry = (function () {
60
72
return false ;
61
73
} ,
62
74
75
+ /**
76
+ * Add given chart instance to the given group, creating the group if necessary.
77
+ * If no group is provided, a default group will be created using dc.constants.DEFAULT_CHART_GROUP.
78
+ * @param {* } chart dc.js chart instance
79
+ * @param {String } [group] Group name
80
+ */
63
81
register : function ( chart , group ) {
64
82
group = initializeChartGroup ( group ) ;
65
83
_chartMap [ group ] . push ( chart ) ;
66
84
} ,
67
85
86
+ /**
87
+ * Remove given chart instance from the given group, creating the group if necessary.
88
+ * If no group is provided, a default group will be created using dc.constants.DEFAULT_CHART_GROUP.
89
+ * @param {* } chart dc.js chart instance
90
+ * @param {String } [group] Group name
91
+ */
68
92
deregister : function ( chart , group ) {
69
93
group = initializeChartGroup ( group ) ;
70
94
for ( var i = 0 ; i < _chartMap [ group ] . length ; i ++ ) {
@@ -75,6 +99,10 @@ dc.chartRegistry = (function () {
75
99
}
76
100
} ,
77
101
102
+ /**
103
+ * Clear given group if one is provided, otherwise clears all groups.
104
+ * @param {String } group Group name
105
+ */
78
106
clear : function ( group ) {
79
107
if ( group ) {
80
108
delete _chartMap [ group ] ;
@@ -83,25 +111,52 @@ dc.chartRegistry = (function () {
83
111
}
84
112
} ,
85
113
114
+ /**
115
+ * Get an array of each chart instance in the given group.
116
+ * If no group is provided, the default group is returned.
117
+ * @param {String } [group] Group name
118
+ * @returns {* }
119
+ */
86
120
list : function ( group ) {
87
121
group = initializeChartGroup ( group ) ;
88
122
return _chartMap [ group ] ;
89
123
}
90
124
} ;
91
125
} ) ( ) ;
92
126
127
+ /**
128
+ * Add given chart instance to the given group, creating the group if necessary.
129
+ * If no group is provided, a default group will be created using dc.constants.DEFAULT_CHART_GROUP.
130
+ * @param {* } chart dc.js chart instance
131
+ * @param {String } [group] Group name
132
+ */
93
133
dc . registerChart = function ( chart , group ) {
94
134
dc . chartRegistry . register ( chart , group ) ;
95
135
} ;
96
136
137
+ /**
138
+ * Remove given chart instance from the given group, creating the group if necessary.
139
+ * If no group is provided, a default group will be created using dc.constants.DEFAULT_CHART_GROUP.
140
+ * @param {* } chart dc.js chart instance
141
+ * @param {String } [group] Group name
142
+ */
97
143
dc . deregisterChart = function ( chart , group ) {
98
144
dc . chartRegistry . deregister ( chart , group ) ;
99
145
} ;
100
146
147
+ /**
148
+ * Determine if a given chart instance resides in any group in the registry.
149
+ * @param {* } chart dc.js chart instance
150
+ * @returns {Boolean }
151
+ */
101
152
dc . hasChart = function ( chart ) {
102
153
return dc . chartRegistry . has ( chart ) ;
103
154
} ;
104
155
156
+ /**
157
+ * Clear given group if one is provided, otherwise clears all groups.
158
+ * @param {String } group Group name
159
+ */
105
160
dc . deregisterAllCharts = function ( group ) {
106
161
dc . chartRegistry . clear ( group ) ;
107
162
} ;
0 commit comments