* Give some default value to the input `textStyle` object, based on the current settings * in this `textStyle` object. * * The Scenario: * when text position is `inside` and `textFill` is not specified, we show * text border by default for better view. But it should be considered that text posi
(textStyle)
| 17817 | * does, `rollbackDefaultTextStyle` is not needed to be called). |
| 17818 | */ |
| 17819 | function applyDefaultTextStyle(textStyle) { |
| 17820 | var textPosition = textStyle.textPosition; |
| 17821 | var opt = textStyle.insideRollbackOpt; |
| 17822 | var insideRollback; |
| 17823 | |
| 17824 | if (opt && textStyle.textFill == null) { |
| 17825 | var autoColor = opt.autoColor; |
| 17826 | var isRectText = opt.isRectText; |
| 17827 | var useInsideStyle = opt.useInsideStyle; |
| 17828 | |
| 17829 | var useInsideStyleCache = useInsideStyle !== false |
| 17830 | && (useInsideStyle === true |
| 17831 | || (isRectText |
| 17832 | && textPosition |
| 17833 | // textPosition can be [10, 30] |
| 17834 | && typeof textPosition === 'string' |
| 17835 | && textPosition.indexOf('inside') >= 0 |
| 17836 | ) |
| 17837 | ); |
| 17838 | var useAutoColorCache = !useInsideStyleCache && autoColor != null; |
| 17839 | |
| 17840 | // All of the props declared in `CACHED_LABEL_STYLE_PROPERTIES` are to be cached. |
| 17841 | if (useInsideStyleCache || useAutoColorCache) { |
| 17842 | insideRollback = { |
| 17843 | textFill: textStyle.textFill, |
| 17844 | textStroke: textStyle.textStroke, |
| 17845 | textStrokeWidth: textStyle.textStrokeWidth |
| 17846 | }; |
| 17847 | } |
| 17848 | if (useInsideStyleCache) { |
| 17849 | textStyle.textFill = '#fff'; |
| 17850 | // Consider text with #fff overflow its container. |
| 17851 | if (textStyle.textStroke == null) { |
| 17852 | textStyle.textStroke = autoColor; |
| 17853 | textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2); |
| 17854 | } |
| 17855 | } |
| 17856 | if (useAutoColorCache) { |
| 17857 | textStyle.textFill = autoColor; |
| 17858 | } |
| 17859 | } |
| 17860 | |
| 17861 | // Always set `insideRollback`, so that the previous one can be cleared. |
| 17862 | textStyle.insideRollback = insideRollback; |
| 17863 | } |
| 17864 | |
| 17865 | /** |
| 17866 | * Consider the case: in a scatter, |
no test coverage detected