MCPcopy
hub / github.com/chartjs/Chart.js / drawBorder

Method drawBorder

src/core/core.scale.js:1522–1552  ·  view source on GitHub ↗

* @protected

()

Source from the content-addressed store, hash-verified

1520 * @protected
1521 */
1522 drawBorder() {
1523 const {chart, ctx, options: {border, grid}} = this;
1524 const borderOpts = border.setContext(this.getContext());
1525 const axisWidth = border.display ? borderOpts.width : 0;
1526 if (!axisWidth) {
1527 return;
1528 }
1529 const lastLineWidth = grid.setContext(this.getContext(0)).lineWidth;
1530 const borderValue = this._borderValue;
1531 let x1, x2, y1, y2;
1532
1533 if (this.isHorizontal()) {
1534 x1 = _alignPixel(chart, this.left, axisWidth) - axisWidth / 2;
1535 x2 = _alignPixel(chart, this.right, lastLineWidth) + lastLineWidth / 2;
1536 y1 = y2 = borderValue;
1537 } else {
1538 y1 = _alignPixel(chart, this.top, axisWidth) - axisWidth / 2;
1539 y2 = _alignPixel(chart, this.bottom, lastLineWidth) + lastLineWidth / 2;
1540 x1 = x2 = borderValue;
1541 }
1542 ctx.save();
1543 ctx.lineWidth = borderOpts.width;
1544 ctx.strokeStyle = borderOpts.color;
1545
1546 ctx.beginPath();
1547 ctx.moveTo(x1, y1);
1548 ctx.lineTo(x2, y2);
1549 ctx.stroke();
1550
1551 ctx.restore();
1552 }
1553
1554 /**
1555 * @protected

Callers 2

drawMethod · 0.95
_layersMethod · 0.95

Calls 4

getContextMethod · 0.95
isHorizontalMethod · 0.95
_alignPixelFunction · 0.85
setContextMethod · 0.80

Tested by

no test coverage detected