(textList, offset, opts, config, context, eachSpacing, xAxisPoints)
| 1902 | } |
| 1903 | |
| 1904 | function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxisPoints) { |
| 1905 | var toolTipOption = assign({}, { |
| 1906 | bgColor: '#000000', |
| 1907 | bgOpacity: 0.7, |
| 1908 | fontColor: '#FFFFFF' |
| 1909 | }, opts.extra.tooltip); |
| 1910 | var legendWidth = 4 * opts.pixelRatio; |
| 1911 | var legendMarginRight = 5 * opts.pixelRatio; |
| 1912 | var arrowWidth = 8 * opts.pixelRatio; |
| 1913 | var isOverRightBorder = false; |
| 1914 | if (opts.type == 'line' || opts.type == 'area' || opts.type == 'candle' || opts.type == 'mix') { |
| 1915 | drawToolTipSplitLine(opts.tooltip.offset.x, opts, config, context); |
| 1916 | } |
| 1917 | |
| 1918 | offset = assign({ |
| 1919 | x: 0, |
| 1920 | y: 0 |
| 1921 | }, offset); |
| 1922 | offset.y -= 8 * opts.pixelRatio; |
| 1923 | var textWidth = textList.map(function(item) { |
| 1924 | return measureText(item.text, config.fontSize); |
| 1925 | }); |
| 1926 | var toolTipWidth = legendWidth + legendMarginRight + 4 * config.toolTipPadding + Math.max.apply(null, textWidth); |
| 1927 | var toolTipHeight = 2 * config.toolTipPadding + textList.length * config.toolTipLineHeight; |
| 1928 | |
| 1929 | // if beyond the right border |
| 1930 | if (offset.x - Math.abs(opts._scrollDistance_) + arrowWidth + toolTipWidth > opts.width) { |
| 1931 | isOverRightBorder = true; |
| 1932 | } |
| 1933 | if (toolTipHeight + offset.y > opts.height) { |
| 1934 | offset.y = opts.height - toolTipHeight; |
| 1935 | } |
| 1936 | // draw background rect |
| 1937 | context.beginPath(); |
| 1938 | context.setFillStyle(hexToRgb(toolTipOption.bgColor || config.toolTipBackground, toolTipOption.bgOpacity || config.toolTipOpacity)); |
| 1939 | if (isOverRightBorder) { |
| 1940 | context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio); |
| 1941 | context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio); |
| 1942 | context.lineTo(offset.x - arrowWidth, offset.y); |
| 1943 | context.lineTo(offset.x - arrowWidth - Math.round(toolTipWidth), offset.y); |
| 1944 | context.lineTo(offset.x - arrowWidth - Math.round(toolTipWidth), offset.y + toolTipHeight); |
| 1945 | context.lineTo(offset.x - arrowWidth, offset.y + toolTipHeight); |
| 1946 | context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio + 5 * opts.pixelRatio); |
| 1947 | context.lineTo(offset.x, offset.y + 10 * opts.pixelRatio); |
| 1948 | } else { |
| 1949 | context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio); |
| 1950 | context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio); |
| 1951 | context.lineTo(offset.x + arrowWidth, offset.y); |
| 1952 | context.lineTo(offset.x + arrowWidth + Math.round(toolTipWidth), offset.y); |
| 1953 | context.lineTo(offset.x + arrowWidth + Math.round(toolTipWidth), offset.y + toolTipHeight); |
| 1954 | context.lineTo(offset.x + arrowWidth, offset.y + toolTipHeight); |
| 1955 | context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pixelRatio + 5 * opts.pixelRatio); |
| 1956 | context.lineTo(offset.x, offset.y + 10 * opts.pixelRatio); |
| 1957 | } |
| 1958 | |
| 1959 | context.closePath(); |
| 1960 | context.fill(); |
| 1961 |
no test coverage detected