* @private
(chartArea)
| 1145 | * @private |
| 1146 | */ |
| 1147 | _computeLabelItems(chartArea) { |
| 1148 | const axis = this.axis; |
| 1149 | const options = this.options; |
| 1150 | const {position, ticks: optionTicks} = options; |
| 1151 | const isHorizontal = this.isHorizontal(); |
| 1152 | const ticks = this.ticks; |
| 1153 | const {align, crossAlign, padding, mirror} = optionTicks; |
| 1154 | const tl = getTickMarkLength(options.grid); |
| 1155 | const tickAndPadding = tl + padding; |
| 1156 | const hTickAndPadding = mirror ? -padding : tickAndPadding; |
| 1157 | const rotation = -toRadians(this.labelRotation); |
| 1158 | const items = []; |
| 1159 | let i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset; |
| 1160 | let textBaseline = 'middle'; |
| 1161 | |
| 1162 | if (position === 'top') { |
| 1163 | y = this.bottom - hTickAndPadding; |
| 1164 | textAlign = this._getXAxisLabelAlignment(); |
| 1165 | } else if (position === 'bottom') { |
| 1166 | y = this.top + hTickAndPadding; |
| 1167 | textAlign = this._getXAxisLabelAlignment(); |
| 1168 | } else if (position === 'left') { |
| 1169 | const ret = this._getYAxisLabelAlignment(tl); |
| 1170 | textAlign = ret.textAlign; |
| 1171 | x = ret.x; |
| 1172 | } else if (position === 'right') { |
| 1173 | const ret = this._getYAxisLabelAlignment(tl); |
| 1174 | textAlign = ret.textAlign; |
| 1175 | x = ret.x; |
| 1176 | } else if (axis === 'x') { |
| 1177 | if (position === 'center') { |
| 1178 | y = ((chartArea.top + chartArea.bottom) / 2) + tickAndPadding; |
| 1179 | } else if (isObject(position)) { |
| 1180 | const positionAxisID = Object.keys(position)[0]; |
| 1181 | const value = position[positionAxisID]; |
| 1182 | y = this.chart.scales[positionAxisID].getPixelForValue(value) + tickAndPadding; |
| 1183 | } |
| 1184 | textAlign = this._getXAxisLabelAlignment(); |
| 1185 | } else if (axis === 'y') { |
| 1186 | if (position === 'center') { |
| 1187 | x = ((chartArea.left + chartArea.right) / 2) - tickAndPadding; |
| 1188 | } else if (isObject(position)) { |
| 1189 | const positionAxisID = Object.keys(position)[0]; |
| 1190 | const value = position[positionAxisID]; |
| 1191 | x = this.chart.scales[positionAxisID].getPixelForValue(value); |
| 1192 | } |
| 1193 | textAlign = this._getYAxisLabelAlignment(tl).textAlign; |
| 1194 | } |
| 1195 | |
| 1196 | if (axis === 'y') { |
| 1197 | if (align === 'start') { |
| 1198 | textBaseline = 'top'; |
| 1199 | } else if (align === 'end') { |
| 1200 | textBaseline = 'bottom'; |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | const labelSizes = this._getLabelSizes(); |
no test coverage detected