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

Method drawBorder

src/core/core.scale.js:1524–1554  ·  view source on GitHub ↗

* @protected

()

Source from the content-addressed store, hash-verified

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