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

Method drawBorder

src/core/core.scale.js:1527–1557  ·  view source on GitHub ↗

* @protected

()

Source from the content-addressed store, hash-verified

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