(animate)
| 650 | } |
| 651 | |
| 652 | draw(animate): void { |
| 653 | this.set_ranges(); |
| 654 | const curvesSel = this.d3el.selectAll('.curve').data(this.model.mark_data); |
| 655 | |
| 656 | const yScale = this.scales.y; |
| 657 | |
| 658 | const newCurves = curvesSel.enter().append('g').attr('class', 'curve'); |
| 659 | newCurves |
| 660 | .append('path') |
| 661 | .attr('class', 'line') |
| 662 | .attr('fill', 'none') |
| 663 | .attr('id', (d, i) => 'curve' + (i + 1)) |
| 664 | .on('click', () => { |
| 665 | this.event_dispatcher('element_clicked'); |
| 666 | }); |
| 667 | newCurves.append('path').attr('class', 'area'); |
| 668 | newCurves |
| 669 | .append('text') |
| 670 | .attr('class', 'curve_label') |
| 671 | .attr('x', 3) |
| 672 | .attr('dy', '.35em') |
| 673 | .attr( |
| 674 | 'display', |
| 675 | this.model.get('labels_visibility') !== 'label' ? 'none' : 'inline' |
| 676 | ) |
| 677 | .text((d: any) => d.name); |
| 678 | |
| 679 | const fill = this.model.get('fill'), |
| 680 | area = fill === 'top' || fill === 'bottom' || fill === 'between'; |
| 681 | |
| 682 | this.draw_dots(); |
| 683 | |
| 684 | this.line = d3 |
| 685 | .line() |
| 686 | .curve(this.get_interpolation()) |
| 687 | .defined((d: any) => { |
| 688 | return d.y !== null && isFinite(yScale.scale(d.y)); |
| 689 | }); |
| 690 | |
| 691 | this.area = d3 |
| 692 | .area() |
| 693 | .curve(this.get_interpolation()) |
| 694 | .defined((d: any) => { |
| 695 | return area && d.y !== null && isFinite(yScale.scale(d.y)); |
| 696 | }); |
| 697 | |
| 698 | // Having a transition on exit is complicated. Please refer to |
| 699 | // Scatter.js for detailed explanation. |
| 700 | curvesSel.exit().remove(); |
| 701 | this.update_line_xy(animate); |
| 702 | this.update_style(); |
| 703 | |
| 704 | // alter the display only if a few of the curves are visible |
| 705 | this.update_curves_subset(); |
| 706 | } |
| 707 | |
| 708 | draw_dots(): void { |
| 709 | if (this.model.get('marker')) { |
no test coverage detected