(gd, trace)
| 106 | } |
| 107 | |
| 108 | function convertTextStyle(gd, trace) { |
| 109 | var fullLayout = gd._fullLayout; |
| 110 | var count = trace._length; |
| 111 | var textfontIn = trace.textfont; |
| 112 | var textpositionIn = trace.textposition; |
| 113 | var textPos = isArrayOrTypedArray(textpositionIn) ? textpositionIn : [textpositionIn]; |
| 114 | var tfc = textfontIn.color; |
| 115 | var tfs = textfontIn.size; |
| 116 | var tff = textfontIn.family; |
| 117 | var tfw = textfontIn.weight; |
| 118 | var tfy = textfontIn.style; |
| 119 | var tfv = textfontIn.variant; |
| 120 | var optsOut = {}; |
| 121 | var i; |
| 122 | var plotGlPixelRatio = gd._context.plotGlPixelRatio; |
| 123 | |
| 124 | var texttemplate = trace.texttemplate; |
| 125 | if (texttemplate) { |
| 126 | optsOut.text = []; |
| 127 | |
| 128 | var d3locale = fullLayout._d3locale; |
| 129 | var isArray = Array.isArray(texttemplate); |
| 130 | var N = isArray ? Math.min(texttemplate.length, count) : count; |
| 131 | var txt = isArray |
| 132 | ? function (i) { |
| 133 | return texttemplate[i]; |
| 134 | } |
| 135 | : function () { |
| 136 | return texttemplate; |
| 137 | }; |
| 138 | |
| 139 | for (i = 0; i < N; i++) { |
| 140 | var d = { i: i }; |
| 141 | var labels = trace._module.formatLabels(d, trace, fullLayout); |
| 142 | var pointValues = {}; |
| 143 | appendArrayPointValue(pointValues, trace, i); |
| 144 | optsOut.text.push( |
| 145 | Lib.texttemplateString({ |
| 146 | data: [pointValues, d, trace._meta], |
| 147 | fallback: trace.texttemplatefallback, |
| 148 | labels, |
| 149 | locale: d3locale, |
| 150 | template: txt(i) |
| 151 | }) |
| 152 | ); |
| 153 | } |
| 154 | } else { |
| 155 | if (isArrayOrTypedArray(trace.text) && trace.text.length < count) { |
| 156 | // if text array is shorter, we'll need to append to it, so let's slice to prevent mutating |
| 157 | optsOut.text = trace.text.slice(); |
| 158 | } else { |
| 159 | optsOut.text = trace.text; |
| 160 | } |
| 161 | } |
| 162 | // pad text array with empty strings |
| 163 | if (isArrayOrTypedArray(optsOut.text)) { |
| 164 | for (i = optsOut.text.length; i < count; i++) { |
| 165 | optsOut.text[i] = ''; |
no test coverage detected
searching dependent graphs…