MCPcopy Index your code
hub / github.com/bqplot/bqplot / updateSlices

Method updateSlices

js/src/Pie.ts:308–353  ·  view source on GitHub ↗
(animate?: boolean)

Source from the content-addressed store, hash-verified

306 }
307
308 private updateSlices(animate?: boolean) {
309 const that = this;
310 const animation_duration =
311 animate === true ? this.parent.model.get('animation_duration') : 0;
312
313 // update pie slices
314 const slices = this.pieSelection
315 .select('.slices')
316 .selectAll('.slice')
317 .data(this.d3Pie(this.model.mark_data));
318
319 const stroke = this.model.get('stroke');
320
321 slices
322 .enter()
323 .append('path')
324 .attr('class', 'slice')
325 .each(function (d) {
326 this._current = d;
327 })
328 .on('click', (d, i) => {
329 return that.event_dispatcher('element_clicked', { data: d, index: i });
330 })
331 .merge(slices)
332 .transition('draw')
333 .duration(animation_duration)
334 .style('fill', (d, i) => that.get_mark_color(d.data, i))
335 .style('stroke', stroke)
336 .style('opacity', (d, i) => that.get_mark_opacity(d.data, i))
337 .attrTween('d', function (d) {
338 const interpolate = d3.interpolate(this._current, d);
339 this._current = d;
340 return function (t) {
341 return that.arc(interpolate(t));
342 };
343 });
344
345 slices
346 .exit()
347 .transition('remove')
348 .duration(animation_duration)
349 .style('opacity', 0)
350 .remove();
351
352 this.apply_styles();
353 }
354
355 private updateLabels(animate?: boolean) {
356 const that = this;

Callers 1

drawMethod · 0.95

Calls 4

get_mark_colorMethod · 0.80
get_mark_opacityMethod · 0.80
removeMethod · 0.45
apply_stylesMethod · 0.45

Tested by

no test coverage detected