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