(gd, trace, xa, ya, x, y, ppad)
| 157 | } |
| 158 | |
| 159 | function calcAxisExpansion(gd, trace, xa, ya, x, y, ppad) { |
| 160 | var serieslen = trace._length; |
| 161 | var fullLayout = gd._fullLayout; |
| 162 | var xId = xa._id; |
| 163 | var yId = ya._id; |
| 164 | var firstScatter = fullLayout._firstScatter[firstScatterGroup(trace)] === trace.uid; |
| 165 | var stackOrientation = (getStackOpts(trace, fullLayout, xa, ya) || {}).orientation; |
| 166 | var fill = trace.fill; |
| 167 | |
| 168 | // cancel minimum tick spacings (only applies to bars and boxes) |
| 169 | xa._minDtick = 0; |
| 170 | ya._minDtick = 0; |
| 171 | |
| 172 | // check whether bounds should be tight, padded, extended to zero... |
| 173 | // most cases both should be padded on both ends, so start with that. |
| 174 | var xOptions = {padded: true}; |
| 175 | var yOptions = {padded: true}; |
| 176 | |
| 177 | if(ppad) { |
| 178 | xOptions.ppad = yOptions.ppad = ppad; |
| 179 | } |
| 180 | |
| 181 | // TODO: text size |
| 182 | |
| 183 | var openEnded = serieslen < 2 || (x[0] !== x[serieslen - 1]) || (y[0] !== y[serieslen - 1]); |
| 184 | |
| 185 | if(openEnded && ( |
| 186 | (fill === 'tozerox') || |
| 187 | ((fill === 'tonextx') && (firstScatter || stackOrientation === 'h')) |
| 188 | )) { |
| 189 | // include zero (tight) and extremes (padded) if fill to zero |
| 190 | // (unless the shape is closed, then it's just filling the shape regardless) |
| 191 | |
| 192 | xOptions.tozero = true; |
| 193 | } else if(!(trace.error_y || {}).visible && ( |
| 194 | // if no error bars, markers or text, or fill to y=0 remove x padding |
| 195 | |
| 196 | (fill === 'tonexty' || fill === 'tozeroy') || |
| 197 | (!subTypes.hasMarkers(trace) && !subTypes.hasText(trace)) |
| 198 | )) { |
| 199 | xOptions.padded = false; |
| 200 | xOptions.ppad = 0; |
| 201 | } |
| 202 | |
| 203 | if(openEnded && ( |
| 204 | (fill === 'tozeroy') || |
| 205 | ((fill === 'tonexty') && (firstScatter || stackOrientation === 'v')) |
| 206 | )) { |
| 207 | // now check for y - rather different logic, though still mostly padded both ends |
| 208 | // include zero (tight) and extremes (padded) if fill to zero |
| 209 | // (unless the shape is closed, then it's just filling the shape regardless) |
| 210 | |
| 211 | yOptions.tozero = true; |
| 212 | } else if(fill === 'tonextx' || fill === 'tozerox') { |
| 213 | // tight y: any x fill |
| 214 | |
| 215 | yOptions.padded = false; |
| 216 | } |
no test coverage detected
searching dependent graphs…