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

Function applyVisual

src/visual/visualSolution.ts:136–190  ·  view source on GitHub ↗
(
    stateList: readonly VisualState[],
    visualMappings: VisualMappingCollection<VisualState>,
    data: SeriesData,
    getValueState: (this: Scope, valueOrIndex: ParsedValue | number) => VisualState,
    scope?: Scope,
    dimension?: DimensionLoose
)

Source from the content-addressed store, hash-verified

134 */
135// ???! handle brush?
136export function applyVisual<VisualState extends string, Scope>(
137 stateList: readonly VisualState[],
138 visualMappings: VisualMappingCollection<VisualState>,
139 data: SeriesData,
140 getValueState: (this: Scope, valueOrIndex: ParsedValue | number) => VisualState,
141 scope?: Scope,
142 dimension?: DimensionLoose
143) {
144 const visualTypesMap: Partial<Record<VisualState, BuiltinVisualProperty[]>> = {};
145 zrUtil.each(stateList, function (state) {
146 const visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
147 visualTypesMap[state] = visualTypes;
148 });
149
150 let dataIndex: number;
151
152 function getVisual(key: string) {
153 return getItemVisualFromData(data, dataIndex, key) as string | number;
154 }
155
156 function setVisual(key: string, value: any) {
157 setItemVisualFromData(data, dataIndex, key, value);
158 }
159
160 if (dimension == null) {
161 data.each(eachItem);
162 }
163 else {
164 data.each([dimension], eachItem);
165 }
166
167 function eachItem(valueOrIndex: ParsedValue | number, index?: number) {
168 dataIndex = dimension == null
169 ? valueOrIndex as number // First argument is index
170 : index;
171
172 const rawDataItem = data.getRawDataItem(dataIndex);
173 // Consider performance
174 // @ts-ignore
175 if (rawDataItem && rawDataItem.visualMap === false) {
176 return;
177 }
178
179 const valueState = getValueState.call(scope, valueOrIndex);
180 const mappings = visualMappings[valueState];
181 const visualTypes = visualTypesMap[valueState];
182
183 for (let i = 0, len = visualTypes.length; i < len; i++) {
184 const type = visualTypes[i];
185 mappings[type] && mappings[type].applyVisual(
186 valueOrIndex, getVisual, setVisual
187 );
188 }
189 }
190}
191
192/**
193 * @param data

Callers

nothing calls this directly

Calls 2

prepareVisualTypesMethod · 0.80
eachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…