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

Method _createHandle

src/component/visualMap/ContinuousView.ts:253–326  ·  view source on GitHub ↗
(
        visualMapModel: ContinuousModel,
        mainGroup: graphic.Group,
        handleIndex: 0 | 1,
        itemSize: number[],
        textSize: number,
        orient: Orient
    )

Source from the content-addressed store, hash-verified

251 }
252
253 private _createHandle(
254 visualMapModel: ContinuousModel,
255 mainGroup: graphic.Group,
256 handleIndex: 0 | 1,
257 itemSize: number[],
258 textSize: number,
259 orient: Orient
260 ) {
261 const onDrift = zrUtil.bind(this._dragHandle, this, handleIndex, false);
262 const onDragEnd = zrUtil.bind(this._dragHandle, this, handleIndex, true);
263 const handleSize = parsePercent(visualMapModel.get('handleSize'), itemSize[0]);
264 const handleThumb = createSymbol(
265 visualMapModel.get('handleIcon'),
266 -handleSize / 2, -handleSize / 2, handleSize, handleSize,
267 null, true
268 );
269 const cursor = getCursor(this._orient);
270 handleThumb.attr({
271 cursor: cursor,
272 draggable: true,
273 drift: onDrift,
274 ondragend: onDragEnd,
275 onmousemove(e) {
276 eventTool.stop(e.event);
277 }
278 });
279 handleThumb.x = itemSize[0] / 2;
280
281 handleThumb.useStyle(visualMapModel.getModel('handleStyle').getItemStyle());
282 (handleThumb as graphic.Path).setStyle({
283 strokeNoScale: true,
284 strokeFirst: true
285 });
286 (handleThumb as graphic.Path).style.lineWidth *= 2;
287
288 handleThumb.ensureState('emphasis').style = visualMapModel.getModel(['emphasis', 'handleStyle']).getItemStyle();
289 setAsHighDownDispatcher(handleThumb, true);
290
291 mainGroup.add(handleThumb);
292
293 // Text is always horizontal layout but should not be effected by
294 // transform (orient/inverse). So label is built separately but not
295 // use zrender/graphic/helper/RectText, and is located based on view
296 // group (according to handleLabelPoint) but not barGroup.
297 const textStyleModel = this.visualMapModel.textStyleModel;
298 const handleLabel = new graphic.Text({
299 cursor: cursor,
300 draggable: true,
301 drift: onDrift,
302 onmousemove(e) {
303 // For mobile device, prevent screen slider on the button.
304 eventTool.stop(e.event);
305 },
306 ondragend: onDragEnd,
307 style: createTextStyle(textStyleModel, {
308 x: 0,
309 y: 0,
310 text: ''

Callers 1

_renderBarMethod · 0.95

Calls 9

createSymbolFunction · 0.90
setAsHighDownDispatcherFunction · 0.90
createTextStyleFunction · 0.90
getItemStyleMethod · 0.80
setStyleMethod · 0.80
getCursorFunction · 0.70
getMethod · 0.45
getModelMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected