(pt, ctx, options)
| 869 | } |
| 870 | |
| 871 | drawBody(pt, ctx, options) { |
| 872 | const {body} = this; |
| 873 | const {bodySpacing, bodyAlign, displayColors, boxHeight, boxWidth, boxPadding} = options; |
| 874 | const bodyFont = toFont(options.bodyFont); |
| 875 | let bodyLineHeight = bodyFont.lineHeight; |
| 876 | let xLinePadding = 0; |
| 877 | |
| 878 | const rtlHelper = getRtlAdapter(options.rtl, this.x, this.width); |
| 879 | |
| 880 | const fillLineOfText = function(line) { |
| 881 | ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2); |
| 882 | pt.y += bodyLineHeight + bodySpacing; |
| 883 | }; |
| 884 | |
| 885 | const bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign); |
| 886 | let bodyItem, textColor, lines, i, j, ilen, jlen; |
| 887 | |
| 888 | ctx.textAlign = bodyAlign; |
| 889 | ctx.textBaseline = class="st">'middle'; |
| 890 | ctx.font = bodyFont.string; |
| 891 | |
| 892 | pt.x = getAlignedX(this, bodyAlignForCalculation, options); |
| 893 | |
| 894 | class="cm">// Before body lines |
| 895 | ctx.fillStyle = options.bodyColor; |
| 896 | each(this.beforeBody, fillLineOfText); |
| 897 | |
| 898 | xLinePadding = displayColors && bodyAlignForCalculation !== class="st">'right' |
| 899 | ? bodyAlign === class="st">'center' ? (boxWidth / 2 + boxPadding) : (boxWidth + 2 + boxPadding) |
| 900 | : 0; |
| 901 | |
| 902 | class="cm">// Draw body lines now |
| 903 | for (i = 0, ilen = body.length; i < ilen; ++i) { |
| 904 | bodyItem = body[i]; |
| 905 | textColor = this.labelTextColors[i]; |
| 906 | |
| 907 | ctx.fillStyle = textColor; |
| 908 | each(bodyItem.before, fillLineOfText); |
| 909 | |
| 910 | lines = bodyItem.lines; |
| 911 | class="cm">// Draw Legend-like boxes if needed |
| 912 | if (displayColors && lines.length) { |
| 913 | this._drawColorBox(ctx, pt, i, rtlHelper, options); |
| 914 | bodyLineHeight = Math.max(bodyFont.lineHeight, boxHeight); |
| 915 | } |
| 916 | |
| 917 | for (j = 0, jlen = lines.length; j < jlen; ++j) { |
| 918 | fillLineOfText(lines[j]); |
| 919 | class="cm">// Reset for any lines that don't include colorbox |
| 920 | bodyLineHeight = bodyFont.lineHeight; |
| 921 | } |
| 922 | |
| 923 | each(bodyItem.after, fillLineOfText); |
| 924 | } |
| 925 | |
| 926 | class="cm">// Reset back to 0 for after body |
| 927 | xLinePadding = 0; |
| 928 | bodyLineHeight = bodyFont.lineHeight; |
no test coverage detected