* drawRaw: draw a single annotation, potentially with modifications * * @param {DOM element} gd * @param {object} options : this annotation's fullLayout options * @param {integer} index : index in 'annotations' container of the annotation to draw * @param {string} subplotId : id of the annotati
(gd, options, index, subplotId, xa, ya)
| 103 | * @param {object | undefined} ya : ... y-axis |
| 104 | */ |
| 105 | function drawRaw(gd, options, index, subplotId, xa, ya) { |
| 106 | var fullLayout = gd._fullLayout; |
| 107 | var gs = gd._fullLayout._size; |
| 108 | var edits = gd._context.edits; |
| 109 | |
| 110 | var className, containerStr; |
| 111 | |
| 112 | if(subplotId) { |
| 113 | className = 'annotation-' + subplotId; |
| 114 | containerStr = subplotId + '.annotations'; |
| 115 | } else { |
| 116 | className = 'annotation'; |
| 117 | containerStr = 'annotations'; |
| 118 | } |
| 119 | |
| 120 | var editHelpers = arrayEditor(gd.layout, containerStr, options); |
| 121 | var modifyBase = editHelpers.modifyBase; |
| 122 | var modifyItem = editHelpers.modifyItem; |
| 123 | var getUpdateObj = editHelpers.getUpdateObj; |
| 124 | |
| 125 | // remove the existing annotation if there is one |
| 126 | fullLayout._infolayer |
| 127 | .selectAll('.' + className + '[data-index="' + index + '"]') |
| 128 | .remove(); |
| 129 | |
| 130 | var annClipID = 'clip' + fullLayout._uid + '_ann' + index; |
| 131 | |
| 132 | // this annotation is gone - quit now after deleting it |
| 133 | // TODO: use d3 idioms instead of deleting and redrawing every time |
| 134 | if(!options._input || options.visible === false) { |
| 135 | d3.selectAll('#' + annClipID).remove(); |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | // calculated pixel positions |
| 140 | // x & y each will get text, head, and tail as appropriate |
| 141 | var annPosPx = {x: {}, y: {}}; |
| 142 | var textangle = +options.textangle || 0; |
| 143 | |
| 144 | // create the components |
| 145 | // made a single group to contain all, so opacity can work right |
| 146 | // with border/arrow together this could handle a whole bunch of |
| 147 | // cleanup at this point, but works for now |
| 148 | var annGroup = fullLayout._infolayer.append('g') |
| 149 | .classed(className, true) |
| 150 | .attr('data-index', String(index)) |
| 151 | .style('opacity', options.opacity); |
| 152 | |
| 153 | // another group for text+background so that they can rotate together |
| 154 | var annTextGroup = annGroup.append('g') |
| 155 | .classed('annotation-text-g', true); |
| 156 | |
| 157 | var editTextPosition = edits[options.showarrow ? 'annotationTail' : 'annotationPosition']; |
| 158 | var textEvents = options.captureevents || edits.annotationText || editTextPosition; |
| 159 | |
| 160 | function makeEventData(initialEvent) { |
| 161 | var eventData = { |
| 162 | index: index, |
no test coverage detected
searching dependent graphs…