* @deprecated The original intention of `api.style` is enable to set itemStyle * like other series. But it is not necessary and not easy to give a strict definition * of what it returns. And since echarts5 it needs to be make compat work. So * deprecates it since echarts5. *
(userProps?: ZRStyleProps, dataIndexInside?: number)
| 802 | * @param dataIndexInside by default `currDataIndexInside`. |
| 803 | */ |
| 804 | function style(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps { |
| 805 | if (__DEV__) { |
| 806 | warnDeprecated('api.style', 'Please write literal style directly instead.'); |
| 807 | } |
| 808 | |
| 809 | dataIndexInside == null && (dataIndexInside = currDataIndexInside); |
| 810 | |
| 811 | const style = data.getItemVisual(dataIndexInside, 'style'); |
| 812 | const visualColor = style && style.fill; |
| 813 | const opacity = style && style.opacity; |
| 814 | |
| 815 | let itemStyle = getItemStyleModel(dataIndexInside, NORMAL).getItemStyle(); |
| 816 | visualColor != null && (itemStyle.fill = visualColor); |
| 817 | opacity != null && (itemStyle.opacity = opacity); |
| 818 | |
| 819 | const opt = {inheritColor: isString(visualColor) ? visualColor : tokens.color.neutral99}; |
| 820 | const labelModel = getLabelModel(dataIndexInside, NORMAL); |
| 821 | // Now that the feature of "auto adjust text fill/stroke" has been migrated to zrender |
| 822 | // since ec5, we should set `isAttached` as `false` here and make compat in |
| 823 | // `convertToEC4StyleForCustomSerise`. |
| 824 | const textStyle = labelStyleHelper.createTextStyle(labelModel, null, opt, false, true); |
| 825 | textStyle.text = labelModel.getShallow('show') |
| 826 | ? retrieve2( |
| 827 | customSeries.getFormattedLabel(dataIndexInside, NORMAL), |
| 828 | getDefaultLabel(data, dataIndexInside) |
| 829 | ) |
| 830 | : null; |
| 831 | const textConfig = labelStyleHelper.createTextConfig(labelModel, opt, false); |
| 832 | |
| 833 | preFetchFromExtra(userProps, itemStyle); |
| 834 | itemStyle = convertToEC4StyleForCustomSerise(itemStyle, textStyle, textConfig); |
| 835 | |
| 836 | userProps && applyUserPropsAfter(itemStyle, userProps); |
| 837 | (itemStyle as LegacyStyleProps).legacy = true; |
| 838 | |
| 839 | return itemStyle; |
| 840 | } |
| 841 | |
| 842 | /** |
| 843 | * @deprecated The reason see `api.style()` |
nothing calls this directly
no test coverage detected
searching dependent graphs…