MCPcopy Create free account
hub / github.com/chartjs/Chart.js / _getYAxisLabelAlignment

Method _getYAxisLabelAlignment

src/core/core.scale.js:1357–1423  ·  view source on GitHub ↗
(tl)

Source from the content-addressed store, hash-verified

1355 }
1356
1357 _getYAxisLabelAlignment(tl) {
1358 const {position, ticks: {crossAlign, mirror, padding}} = this.options;
1359 const labelSizes = this._getLabelSizes();
1360 const tickAndPadding = tl + padding;
1361 const widest = labelSizes.widest.width;
1362
1363 let textAlign;
1364 let x;
1365
1366 if (position === 'left') {
1367 if (mirror) {
1368 x = this.right + padding;
1369
1370 if (crossAlign === 'near') {
1371 textAlign = 'left';
1372 } else if (crossAlign === 'center') {
1373 textAlign = 'center';
1374 x += (widest / 2);
1375 } else {
1376 textAlign = 'right';
1377 x += widest;
1378 }
1379 } else {
1380 x = this.right - tickAndPadding;
1381
1382 if (crossAlign === 'near') {
1383 textAlign = 'right';
1384 } else if (crossAlign === 'center') {
1385 textAlign = 'center';
1386 x -= (widest / 2);
1387 } else {
1388 textAlign = 'left';
1389 x = this.left;
1390 }
1391 }
1392 } else if (position === 'right') {
1393 if (mirror) {
1394 x = this.left + padding;
1395
1396 if (crossAlign === 'near') {
1397 textAlign = 'right';
1398 } else if (crossAlign === 'center') {
1399 textAlign = 'center';
1400 x -= (widest / 2);
1401 } else {
1402 textAlign = 'left';
1403 x -= widest;
1404 }
1405 } else {
1406 x = this.left + tickAndPadding;
1407
1408 if (crossAlign === 'near') {
1409 textAlign = 'left';
1410 } else if (crossAlign === 'center') {
1411 textAlign = 'center';
1412 x += widest / 2;
1413 } else {
1414 textAlign = 'right';

Callers 1

_computeLabelItemsMethod · 0.95

Calls 1

_getLabelSizesMethod · 0.95

Tested by

no test coverage detected