()
| 624 | } |
| 625 | |
| 626 | function renderAnchor() { |
| 627 | var isNotPath = shapeOptions.type !== 'path'; |
| 628 | |
| 629 | // d3 join with dummy data to satisfy d3 data-binding |
| 630 | var visualCues = shapeLayer.selectAll('.visual-cue').data([0]); |
| 631 | |
| 632 | // Enter |
| 633 | var strokeWidth = 1; |
| 634 | visualCues |
| 635 | .enter() |
| 636 | .append('path') |
| 637 | .attr({ |
| 638 | fill: '#fff', |
| 639 | 'fill-rule': 'evenodd', |
| 640 | stroke: '#000', |
| 641 | 'stroke-width': strokeWidth |
| 642 | }) |
| 643 | .classed('visual-cue', true); |
| 644 | |
| 645 | // Update |
| 646 | var posX = x2p( |
| 647 | xPixelSized |
| 648 | ? shapeOptions.xanchor |
| 649 | : Lib.midRange( |
| 650 | isNotPath |
| 651 | ? [shapeOptions.x0, shapeOptions.x1] |
| 652 | : helpers.extractPathCoords(shapeOptions.path, constants.paramIsX) |
| 653 | ) |
| 654 | ); |
| 655 | var posY = y2p( |
| 656 | yPixelSized |
| 657 | ? shapeOptions.yanchor |
| 658 | : Lib.midRange( |
| 659 | isNotPath |
| 660 | ? [shapeOptions.y0, shapeOptions.y1] |
| 661 | : helpers.extractPathCoords(shapeOptions.path, constants.paramIsY) |
| 662 | ) |
| 663 | ); |
| 664 | |
| 665 | posX = helpers.roundPositionForSharpStrokeRendering(posX, strokeWidth); |
| 666 | posY = helpers.roundPositionForSharpStrokeRendering(posY, strokeWidth); |
| 667 | |
| 668 | if (xPixelSized && yPixelSized) { |
| 669 | var crossPath = |
| 670 | 'M' + |
| 671 | (posX - 1 - strokeWidth) + |
| 672 | ',' + |
| 673 | (posY - 1 - strokeWidth) + |
| 674 | 'h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z'; |
| 675 | visualCues.attr('d', crossPath); |
| 676 | } else if (xPixelSized) { |
| 677 | var vBarPath = 'M' + (posX - 1 - strokeWidth) + ',' + (posY - 9 - strokeWidth) + 'v18 h2 v-18 Z'; |
| 678 | visualCues.attr('d', vBarPath); |
| 679 | } else { |
| 680 | var hBarPath = 'M' + (posX - 9 - strokeWidth) + ',' + (posY - 1 - strokeWidth) + 'h18 v2 h-18 Z'; |
| 681 | visualCues.attr('d', hBarPath); |
| 682 | } |
| 683 | } |
no test coverage detected
searching dependent graphs…