* Can only be called after coordinate system creation stage. * (Can be called before coordinate system update stage). * * @param {Object} opt {labelInside} * @return {Object} { * position, rotation, labelDirection, labelOffset, * tickDirection, labelRotate, z2 * }
(gridModel, axisModel, opt)
| 41290 | * } |
| 41291 | */ |
| 41292 | function layout$1(gridModel, axisModel, opt) { |
| 41293 | opt = opt || {}; |
| 41294 | var grid = gridModel.coordinateSystem; |
| 41295 | var axis = axisModel.axis; |
| 41296 | var layout = {}; |
| 41297 | var otherAxisOnZeroOf = axis.getAxesOnZeroOf()[0]; |
| 41298 | |
| 41299 | var rawAxisPosition = axis.position; |
| 41300 | var axisPosition = otherAxisOnZeroOf ? 'onZero' : rawAxisPosition; |
| 41301 | var axisDim = axis.dim; |
| 41302 | |
| 41303 | var rect = grid.getRect(); |
| 41304 | var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; |
| 41305 | var idx = {left: 0, right: 1, top: 0, bottom: 1, onZero: 2}; |
| 41306 | var axisOffset = axisModel.get('offset') || 0; |
| 41307 | |
| 41308 | var posBound = axisDim === 'x' |
| 41309 | ? [rectBound[2] - axisOffset, rectBound[3] + axisOffset] |
| 41310 | : [rectBound[0] - axisOffset, rectBound[1] + axisOffset]; |
| 41311 | |
| 41312 | if (otherAxisOnZeroOf) { |
| 41313 | var onZeroCoord = otherAxisOnZeroOf.toGlobalCoord(otherAxisOnZeroOf.dataToCoord(0)); |
| 41314 | posBound[idx.onZero] = Math.max(Math.min(onZeroCoord, posBound[1]), posBound[0]); |
| 41315 | } |
| 41316 | |
| 41317 | // Axis position |
| 41318 | layout.position = [ |
| 41319 | axisDim === 'y' ? posBound[idx[axisPosition]] : rectBound[0], |
| 41320 | axisDim === 'x' ? posBound[idx[axisPosition]] : rectBound[3] |
| 41321 | ]; |
| 41322 | |
| 41323 | // Axis rotation |
| 41324 | layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1); |
| 41325 | |
| 41326 | // Tick and label direction, x y is axisDim |
| 41327 | var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; |
| 41328 | |
| 41329 | layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; |
| 41330 | layout.labelOffset = otherAxisOnZeroOf ? posBound[idx[rawAxisPosition]] - posBound[idx.onZero] : 0; |
| 41331 | |
| 41332 | if (axisModel.get('axisTick.inside')) { |
| 41333 | layout.tickDirection = -layout.tickDirection; |
| 41334 | } |
| 41335 | if (retrieve(opt.labelInside, axisModel.get('axisLabel.inside'))) { |
| 41336 | layout.labelDirection = -layout.labelDirection; |
| 41337 | } |
| 41338 | |
| 41339 | // Special label rotation |
| 41340 | var labelRotate = axisModel.get('axisLabel.rotate'); |
| 41341 | layout.labelRotate = axisPosition === 'top' ? -labelRotate : labelRotate; |
| 41342 | |
| 41343 | // Over splitLine and splitArea |
| 41344 | layout.z2 = 1; |
| 41345 | |
| 41346 | return layout; |
| 41347 | } |
| 41348 | |
| 41349 | /* |