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

Method updatePolylines

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

Source from the content-addressed store, hash-verified

434 }
435
436 updatePolylines(animate?: boolean) {
437 const that = this;
438 const animation_duration =
439 animate === true ? this.parent.model.get('animation_duration') : 0;
440
441 const display_labels = this.model.get('display_labels');
442
443 const polylines = this.pieSelection
444 .select('.lines')
445 .selectAll('polyline')
446 .data(this.d3Pie(this.model.mark_data));
447
448 const polylinesTransition = polylines
449 .enter()
450 .append('polyline')
451 .each(function (d) {
452 this._current = d;
453 })
454 .merge(polylines)
455 .transition('draw')
456 .duration(animation_duration)
457 .style('opacity', (d: any) =>
458 display_labels !== 'outside' || d.value == 0 || d.data.label === ''
459 ? 0
460 : 1
461 );
462
463 if (display_labels === 'outside') {
464 polylinesTransition.attrTween('points', function (d: any) {
465 const interpolate = d3.interpolate(this._current, d);
466 const _this = this;
467 return function (t) {
468 const d2 = interpolate(t);
469 _this._current = d2;
470 const pos = that.outerArc.centroid(d2);
471 pos[0] =
472 that.model.get('radius') *
473 0.95 *
474 (that.midAngleLocation(d2) === 'left' ? -1 : 1);
475 return [
476 that.arc.centroid(d2),
477 that.outerArc.centroid(d2),
478 pos,
479 ].toString();
480 };
481 });
482 }
483
484 polylines.exit().remove();
485 }
486
487 clear_style(style_dict, indices?) {
488 // Function to clear the style of a dict on some or all the elements of the

Callers 2

create_listenersMethod · 0.95
drawMethod · 0.95

Calls 2

midAngleLocationMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected