MCPcopy Create free account
hub / github.com/CoderOpen/waimai / drawToolTipSplitLine

Function drawToolTipSplitLine

front/components/u-charts/u-charts.js:1741–1782  ·  view source on GitHub ↗
(offsetX, opts, config, context)

Source from the content-addressed store, hash-verified

1739}
1740
1741function drawToolTipSplitLine(offsetX, opts, config, context) {
1742 var toolTipOption = opts.extra.tooltip || {};
1743 toolTipOption.gridType = toolTipOption.gridType == undefined ? 'solid' : toolTipOption.gridType;
1744 toolTipOption.dashLength = toolTipOption.dashLength == undefined ? 4 : toolTipOption.dashLength;
1745 var startY = opts.area[0];
1746 var endY = opts.height - opts.area[2];
1747
1748 if (toolTipOption.gridType == 'dash') {
1749 context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
1750 }
1751 context.setStrokeStyle(toolTipOption.gridColor || '#cccccc');
1752 context.setLineWidth(1 * opts.pixelRatio);
1753 context.beginPath();
1754 context.moveTo(offsetX, startY);
1755 context.lineTo(offsetX, endY);
1756 context.stroke();
1757 context.setLineDash([]);
1758
1759 if (toolTipOption.xAxisLabel) {
1760 let labelText = opts.categories[opts.tooltip.index];
1761 context.setFontSize(config.fontSize);
1762 let textWidth = measureText(labelText, config.fontSize);
1763
1764 let textX = offsetX - 0.5 * textWidth;
1765 let textY = endY;
1766 context.beginPath();
1767 context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity));
1768 context.setStrokeStyle(toolTipOption.labelBgColor || config.toolTipBackground);
1769 context.setLineWidth(1 * opts.pixelRatio);
1770 context.rect(textX - config.toolTipPadding, textY, textWidth + 2 * config.toolTipPadding, config.fontSize + 2 * config.toolTipPadding);
1771 context.closePath();
1772 context.stroke();
1773 context.fill();
1774
1775 context.beginPath();
1776 context.setFontSize(config.fontSize);
1777 context.setFillStyle(toolTipOption.labelFontColor || config.fontColor);
1778 context.fillText(String(labelText), textX, textY + config.toolTipPadding + config.fontSize);
1779 context.closePath();
1780 context.stroke();
1781 }
1782}
1783
1784function drawMarkLine(minRange, maxRange, opts, config, context) {
1785 let markLineOption = assign({}, {

Callers 1

drawToolTipFunction · 0.85

Calls 2

measureTextFunction · 0.85
hexToRgbFunction · 0.85

Tested by

no test coverage detected