MCPcopy
hub / github.com/apache/echarts / getControllerVisual

Method getControllerVisual

src/component/visualMap/VisualMapView.ts:103–151  ·  view source on GitHub ↗

* @protected * @param targetValue can be Infinity or -Infinity * @param visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize' * @param opts * @param opts.forceState Specify state, instead of using getValueState method. * @param opts.convertOpacityToAlpha For colo

(
        targetValue: number,
        visualCluster: 'color' | 'opacity' | 'symbol' | 'symbolSize',
        opts?: {
            forceState?: VisualState
            convertOpacityToAlpha?: boolean
        }
    )

Source from the content-addressed store, hash-verified

101 * @return {*} Visual value.
102 */
103 protected getControllerVisual(
104 targetValue: number,
105 visualCluster: 'color' | 'opacity' | 'symbol' | 'symbolSize',
106 opts?: {
107 forceState?: VisualState
108 convertOpacityToAlpha?: boolean
109 }
110 ) {
111
112 opts = opts || {};
113
114 const forceState = opts.forceState;
115 const visualMapModel = this.visualMapModel;
116 const visualObj: {[key in typeof visualCluster]?: VisualOptionUnit[key]} = {};
117
118 // Default values.
119 if (visualCluster === 'color') {
120 const defaultColor = visualMapModel.get('contentColor');
121 visualObj.color = defaultColor as ColorString;
122 }
123
124 function getter(key: typeof visualCluster) {
125 return visualObj[key];
126 }
127
128 function setter(key: typeof visualCluster, value: any) {
129 (visualObj as any)[key] = value;
130 }
131
132 const mappings = visualMapModel.controllerVisuals[
133 forceState || visualMapModel.getValueState(targetValue)
134 ];
135 const visualTypes = VisualMapping.prepareVisualTypes(mappings);
136
137 zrUtil.each(visualTypes, function (type) {
138 let visualMapping = mappings[type];
139 if (opts.convertOpacityToAlpha && type === 'opacity') {
140 type = 'colorAlpha';
141 visualMapping = mappings.__alphaForOpacity;
142 }
143 if (VisualMapping.dependsOn(type, visualCluster)) {
144 visualMapping && visualMapping.applyVisual(
145 targetValue, getter, setter
146 );
147 }
148 });
149
150 return visualObj[visualCluster];
151 }
152
153 protected positionGroup(group: Group) {
154 const model = this.visualMapModel;

Callers 5

_createBarVisualMethod · 0.80
_makeColorGradientMethod · 0.80
_updateHandleMethod · 0.80
_showIndicatorMethod · 0.80
_createItemSymbolMethod · 0.80

Calls 6

prepareVisualTypesMethod · 0.80
dependsOnMethod · 0.80
applyVisualMethod · 0.80
getMethod · 0.45
getValueStateMethod · 0.45
eachMethod · 0.45

Tested by

no test coverage detected