(chart, options, size, yAlign)
| 244 | } |
| 245 | |
| 246 | function determineXAlign(chart, options, size, yAlign) { |
| 247 | const {x, width} = size; |
| 248 | const {width: chartWidth, chartArea: {left, right}} = chart; |
| 249 | let xAlign = 'center'; |
| 250 | |
| 251 | if (yAlign === 'center') { |
| 252 | xAlign = x <= (left + right) / 2 ? 'left' : 'right'; |
| 253 | } else if (x <= width / 2) { |
| 254 | xAlign = 'left'; |
| 255 | } else if (x >= chartWidth - width / 2) { |
| 256 | xAlign = 'right'; |
| 257 | } |
| 258 | |
| 259 | if (doesNotFitWithAlign(xAlign, chart, options, size)) { |
| 260 | xAlign = 'center'; |
| 261 | } |
| 262 | |
| 263 | return xAlign; |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Helper to get the alignment of a tooltip given the size |
no test coverage detected