()
| 274 | } |
| 275 | |
| 276 | update_data() { |
| 277 | const that = this; |
| 278 | this.model.set('selected', []); |
| 279 | this.data = this.model.get('names') || []; |
| 280 | this.ref_data = this.model.get('ref_data'); |
| 281 | this.group_data = this.model.get('groups'); |
| 282 | this.groups = _.uniq(this.group_data, true); |
| 283 | let display_text = this.model.get('display_text'); |
| 284 | display_text = |
| 285 | display_text === null || display_text.length === 0 |
| 286 | ? this.data |
| 287 | : display_text; |
| 288 | |
| 289 | this.colors = this.model.get('colors'); |
| 290 | const num_colors = this.colors.length; |
| 291 | this.colors_map = function (d) { |
| 292 | return that.get_color(d, num_colors); |
| 293 | }; |
| 294 | const color_data = this.model.get('color'); |
| 295 | const mapped_data = _.map(this.data, (d, i) => { |
| 296 | return { |
| 297 | display: display_text[i], |
| 298 | name: d, |
| 299 | color: Number.isNaN(color_data[i]) ? undefined : color_data[i], |
| 300 | group: this.group_data[i], |
| 301 | ref_data: |
| 302 | this.ref_data === null || this.ref_data === undefined |
| 303 | ? null |
| 304 | : this.ref_data[i], |
| 305 | }; |
| 306 | }); |
| 307 | |
| 308 | this.update_domains(); |
| 309 | this.grouped_data = _.groupBy(mapped_data, (d, i) => { |
| 310 | return that.group_data[i]; |
| 311 | }); |
| 312 | this.groups = []; |
| 313 | this.running_sums = []; |
| 314 | this.running_sums[0] = 0; |
| 315 | let count = 0; |
| 316 | for (const key in this.grouped_data) { |
| 317 | this.groups.push(key); |
| 318 | count += this.grouped_data[key].length; |
| 319 | this.running_sums.push(count); |
| 320 | } |
| 321 | this.running_sums.pop(); |
| 322 | } |
| 323 | |
| 324 | update_domains() { |
| 325 | const color_scale_model = this.model.getScales().color; |
no test coverage detected