MCPcopy Index your code
hub / github.com/apache/echarts / applyOptionStyleForRegion

Function applyOptionStyleForRegion

src/component/helper/MapDraw.ts:617–677  ·  view source on GitHub ↗
(
    api: ExtensionAPI,
    data: SeriesData | NullUndefined,
    isVisualEncodedByVisualMap: boolean,
    el: Displayable,
    dataIndex: number,
    regionModel: Model<
        GeoStyleableOption & {
            emphasis?: GeoStyleableOption;
            select?: GeoStyleableOption;
            blur?: GeoStyleableOption;
        }
    >
)

Source from the content-addressed store, hash-verified

615};
616
617function applyOptionStyleForRegion(
618 api: ExtensionAPI,
619 data: SeriesData | NullUndefined,
620 isVisualEncodedByVisualMap: boolean,
621 el: Displayable,
622 dataIndex: number,
623 regionModel: Model<
624 GeoStyleableOption & {
625 emphasis?: GeoStyleableOption;
626 select?: GeoStyleableOption;
627 blur?: GeoStyleableOption;
628 }
629 >
630): void {
631 // All of the path are using `itemStyle`, because
632 // (1) Some SVG also use fill on polyline (The different between
633 // polyline and polygon is "open" or "close" but not fill or not).
634 // (2) For the common props like opacity, if some use itemStyle
635 // and some use `lineStyle`, it might confuse users.
636 // (3) Most SVG use <path>, where can not detect whether to draw a "line"
637 // or a filled shape, so use `itemStyle` for <path>.
638
639 const normalStyleModel = regionModel.getModel('itemStyle');
640 const emphasisStyleModel = regionModel.getModel(['emphasis', 'itemStyle']);
641 const blurStyleModel = regionModel.getModel(['blur', 'itemStyle']);
642 const selectStyleModel = regionModel.getModel(['select', 'itemStyle']);
643
644 // NOTE: DON'T use 'style' in visual when drawing map.
645 // This component is used for drawing underlying map for both geo component and map series.
646 const normalStyle = getFixedItemStyle(normalStyleModel);
647 const emphasisStyle = getFixedItemStyle(emphasisStyleModel);
648 const selectStyle = getFixedItemStyle(selectStyleModel);
649 const blurStyle = getFixedItemStyle(blurStyleModel);
650
651 // Update the itemStyle if has data visual
652 if (data) {
653 // Only visual color of each item will be used. It can be encoded by visualMap
654 // But visual color of series is used in symbol drawing
655
656 // Visual color for each series is for the symbol draw
657 const style = data.getItemVisual(dataIndex, 'style');
658 const decal = data.getItemVisual(dataIndex, 'decal');
659 if (isVisualEncodedByVisualMap && style.fill) {
660 normalStyle.fill = style.fill;
661 }
662 if (decal) {
663 normalStyle.decal = createOrUpdatePatternFromDecal(decal, api);
664 }
665 }
666
667 // SVG text, tspan and image can be named but not supporeted
668 // to be styled by region option yet.
669 el.setStyle(normalStyle);
670 el.style.strokeNoScale = true;
671 el.ensureState('emphasis').style = emphasisStyle;
672 el.ensureState('select').style = selectStyle;
673 el.ensureState('blur').style = blurStyle;
674

Callers 2

createCompoundPathMethod · 0.85
_buildSVGMethod · 0.85

Calls 6

setDefaultStateProxyFunction · 0.90
getFixedItemStyleFunction · 0.85
setStyleMethod · 0.80
getModelMethod · 0.45
getItemVisualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…