(chart, options, size, yAlign)
| 280 | } |
| 281 | |
| 282 | function determineXAlign(chart, options, size, yAlign) { |
| 283 | const {x, width} = size; |
| 284 | const {width: chartWidth, chartArea: {left, right}} = chart; |
| 285 | let xAlign = 'center'; |
| 286 | |
| 287 | if (yAlign === 'center') { |
| 288 | xAlign = x <= (left + right) / 2 ? 'left' : 'right'; |
| 289 | } else if (x <= width / 2) { |
| 290 | xAlign = 'left'; |
| 291 | } else if (x >= chartWidth - width / 2) { |
| 292 | xAlign = 'right'; |
| 293 | } |
| 294 | |
| 295 | if (doesNotFitWithAlign(xAlign, chart, options, size)) { |
| 296 | xAlign = 'center'; |
| 297 | } |
| 298 | |
| 299 | return xAlign; |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Helper to get the alignment of a tooltip given the size |
no test coverage detected