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

Method drawBackground

src/plugins/plugin.tooltip.js:961–1000  ·  src/plugins/plugin.tooltip.js::Tooltip.drawBackground
(pt, ctx, tooltipSize, options)

Source from the content-addressed store, hash-verified

959 }
960
961 drawBackground(pt, ctx, tooltipSize, options) {
962 const {xAlign, yAlign} = this;
963 const {x, y} = pt;
964 const {width, height} = tooltipSize;
965 const {topLeft, topRight, bottomLeft, bottomRight} = toTRBLCorners(options.cornerRadius);
966
967 ctx.fillStyle = options.backgroundColor;
968 ctx.strokeStyle = options.borderColor;
969 ctx.lineWidth = options.borderWidth;
970
971 ctx.beginPath();
972 ctx.moveTo(x + topLeft, y);
973 if (yAlign === class="st">'top') {
974 this.drawCaret(pt, ctx, tooltipSize, options);
975 }
976 ctx.lineTo(x + width - topRight, y);
977 ctx.quadraticCurveTo(x + width, y, x + width, y + topRight);
978 if (yAlign === class="st">'center' && xAlign === class="st">'right') {
979 this.drawCaret(pt, ctx, tooltipSize, options);
980 }
981 ctx.lineTo(x + width, y + height - bottomRight);
982 ctx.quadraticCurveTo(x + width, y + height, x + width - bottomRight, y + height);
983 if (yAlign === class="st">'bottom') {
984 this.drawCaret(pt, ctx, tooltipSize, options);
985 }
986 ctx.lineTo(x + bottomLeft, y + height);
987 ctx.quadraticCurveTo(x, y + height, x, y + height - bottomLeft);
988 if (yAlign === class="st">'center' && xAlign === class="st">'left') {
989 this.drawCaret(pt, ctx, tooltipSize, options);
990 }
991 ctx.lineTo(x, y + topLeft);
992 ctx.quadraticCurveTo(x, y, x + topLeft, y);
993 ctx.closePath();
994
995 ctx.fill();
996
997 if (options.borderWidth > 0) {
998 ctx.stroke();
999 }
1000 }
1001
1002 /**
1003 * Update x/y animation targets when _active elements are animating too

Callers 1

drawMethod · 0.95

Calls 2

drawCaretMethod · 0.95
toTRBLCornersFunction · 0.85

Tested by

no test coverage detected