(result: TooltipFormatResult)
| 221 | * For backward compat, normalize the return from `formatTooltip`. |
| 222 | */ |
| 223 | export function normalizeTooltipFormatResult(result: TooltipFormatResult): { |
| 224 | // If `markupFragment` exists, `markupText` should be ignored. |
| 225 | frag: TooltipMarkupBlockFragment; |
| 226 | // Can be `null`/`undefined`, means no tooltip. |
| 227 | text: string; |
| 228 | // Merged with `markersExisting`. |
| 229 | // markers: Dictionary<ColorString>; |
| 230 | } { |
| 231 | let markupText; |
| 232 | // let markers: Dictionary<ColorString>; |
| 233 | let markupFragment: TooltipMarkupBlockFragment; |
| 234 | if (zrUtil.isObject(result)) { |
| 235 | if ((result as TooltipMarkupBlockFragment).type) { |
| 236 | markupFragment = result as TooltipMarkupBlockFragment; |
| 237 | } |
| 238 | else { |
| 239 | if (__DEV__) { |
| 240 | console.warn('The return type of `formatTooltip` is not supported: ' + makePrintable(result)); |
| 241 | } |
| 242 | } |
| 243 | // else { |
| 244 | // markupText = (result as TooltipFormatResultLegacyObject).html; |
| 245 | // markers = (result as TooltipFormatResultLegacyObject).markers; |
| 246 | // if (markersExisting) { |
| 247 | // markers = zrUtil.merge(markersExisting, markers); |
| 248 | // } |
| 249 | // } |
| 250 | } |
| 251 | else { |
| 252 | markupText = result; |
| 253 | } |
| 254 | |
| 255 | return { |
| 256 | text: markupText, |
| 257 | // markers: markers || markersExisting, |
| 258 | frag: markupFragment |
| 259 | }; |
| 260 | } |
no test coverage detected
searching dependent graphs…