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

Method createIconPaths

src/component/toolbox/ToolboxView.ts:181–309  ·  view source on GitHub ↗
(
            featureModel: ToolboxFeatureModel,
            feature: ToolboxFeature | UserDefinedToolboxFeature,
            featureName: string
        )

Source from the content-addressed store, hash-verified

179 }
180
181 function createIconPaths(
182 featureModel: ToolboxFeatureModel,
183 feature: ToolboxFeature | UserDefinedToolboxFeature,
184 featureName: string
185 ) {
186 const iconStyleModel = featureModel.getModel('iconStyle');
187 const iconStyleEmphasisModel = featureModel.getModel(['emphasis', 'iconStyle']);
188
189 // If one feature has multiple icons, they are organized as
190 // {
191 // icon: {
192 // foo: '',
193 // bar: ''
194 // },
195 // title: {
196 // foo: '',
197 // bar: ''
198 // }
199 // }
200 const icons = (feature instanceof ToolboxFeature && feature.getIcons)
201 ? feature.getIcons() : featureModel.get('icon');
202 const titles = featureModel.get('title') || {};
203 let iconsMap: Dictionary<string>;
204 let titlesMap: Dictionary<string>;
205 if (isString(icons)) {
206 iconsMap = {};
207 iconsMap[featureName] = icons;
208 }
209 else {
210 iconsMap = icons;
211 }
212 if (isString(titles)) {
213 titlesMap = {};
214 titlesMap[featureName] = titles as string;
215 }
216 else {
217 titlesMap = titles;
218 }
219 const iconPaths: ToolboxFeatureModel['iconPaths'] = featureModel.iconPaths = {};
220 each(iconsMap, function (iconStr, iconName) {
221 const path = graphic.createIcon(
222 iconStr,
223 {},
224 {
225 x: -itemSize / 2,
226 y: -itemSize / 2,
227 width: itemSize,
228 height: itemSize
229 }
230 ) as Displayable; // TODO handling image
231 path.setStyle(iconStyleModel.getItemStyle());
232
233 const pathEmphasisState = path.ensureState('emphasis');
234 pathEmphasisState.style = iconStyleEmphasisModel.getItemStyle();
235
236 // Text position calculation
237 // TODO: extract `textStyle` from `iconStyle` and use `createTextStyle`
238 const textContent = new ZRText({

Callers

nothing calls this directly

Calls 11

getFontFunction · 0.90
setStyleMethod · 0.80
getItemStyleMethod · 0.80
enterEmphasisMethod · 0.80
leaveEmphasisMethod · 0.80
getIconsMethod · 0.65
eachFunction · 0.50
getModelMethod · 0.45
getMethod · 0.45
hideMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected