(pt, ctx, options)
| 927 | } |
| 928 | |
| 929 | drawBody(pt, ctx, options) { |
| 930 | const {body} = this; |
| 931 | const {bodySpacing, bodyAlign, displayColors, boxHeight, boxWidth, boxPadding} = options; |
| 932 | const bodyFont = toFont(options.bodyFont); |
| 933 | let bodyLineHeight = bodyFont.lineHeight; |
| 934 | let xLinePadding = 0; |
| 935 | |
| 936 | const rtlHelper = getRtlAdapter(options.rtl, this.x, this.width); |
| 937 | |
| 938 | const fillLineOfText = function(line) { |
| 939 | ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2); |
| 940 | pt.y += bodyLineHeight + bodySpacing; |
| 941 | }; |
| 942 | |
| 943 | const bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign); |
| 944 | let bodyItem, textColor, lines, i, j, ilen, jlen; |
| 945 | |
| 946 | ctx.textAlign = bodyAlign; |
| 947 | ctx.textBaseline = 'middle'; |
| 948 | ctx.font = bodyFont.string; |
| 949 | |
| 950 | pt.x = getAlignedX(this, bodyAlignForCalculation, options); |
| 951 | |
| 952 | // Before body lines |
| 953 | ctx.fillStyle = options.bodyColor; |
| 954 | each(this.beforeBody, fillLineOfText); |
| 955 | |
| 956 | xLinePadding = displayColors && bodyAlignForCalculation !== 'right' |
| 957 | ? bodyAlign === 'center' ? (boxWidth / 2 + boxPadding) : (boxWidth + 2 + boxPadding) |
| 958 | : 0; |
| 959 | |
| 960 | // Draw body lines now |
| 961 | for (i = 0, ilen = body.length; i < ilen; ++i) { |
| 962 | bodyItem = body[i]; |
| 963 | textColor = this.labelTextColors[i]; |
| 964 | |
| 965 | ctx.fillStyle = textColor; |
| 966 | each(bodyItem.before, fillLineOfText); |
| 967 | |
| 968 | lines = bodyItem.lines; |
| 969 | // Draw Legend-like boxes if needed |
| 970 | if (displayColors && lines.length) { |
| 971 | this._drawColorBox(ctx, pt, i, rtlHelper, options); |
| 972 | bodyLineHeight = Math.max(bodyFont.lineHeight, boxHeight); |
| 973 | } |
| 974 | |
| 975 | for (j = 0, jlen = lines.length; j < jlen; ++j) { |
| 976 | fillLineOfText(lines[j]); |
| 977 | // Reset for any lines that don't include colorbox |
| 978 | bodyLineHeight = bodyFont.lineHeight; |
| 979 | } |
| 980 | |
| 981 | each(bodyItem.after, fillLineOfText); |
| 982 | } |
| 983 | |
| 984 | // Reset back to 0 for after body |
| 985 | xLinePadding = 0; |
| 986 | bodyLineHeight = bodyFont.lineHeight; |
no test coverage detected