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

Function fixValue

src/component/axisPointer/modelHelper.ts:352–396  ·  view source on GitHub ↗
(axisModel: AxisBaseModel)

Source from the content-addressed store, hash-verified

350}
351
352export function fixValue(axisModel: AxisBaseModel) {
353 const axisInfo = getAxisInfo(axisModel);
354 if (!axisInfo) {
355 return;
356 }
357
358 const axisPointerModel = axisInfo.axisPointerModel;
359 const scale = axisInfo.axis.scale;
360 const option = axisPointerModel.option;
361 const status = axisPointerModel.get('status');
362 let value = axisPointerModel.get('value');
363
364 // Parse init value for category and time axis.
365 if (value != null) {
366 value = scale.parse(value);
367 }
368
369 const useHandle = isHandleTrigger(axisPointerModel);
370 // If `handle` used, `axisPointer` will always be displayed, so value
371 // and status should be initialized.
372 if (status == null) {
373 option.status = useHandle ? 'show' : 'hide';
374 }
375
376 const extent = scale.getExtent();
377
378 if (// Pick a value on axis when initializing.
379 value == null
380 // If both `handle` and `dataZoom` are used, value may be out of axis extent,
381 // where we should re-pick a value to keep `handle` displaying normally.
382 || value > extent[1]
383 ) {
384 // Make handle displayed on the end of the axis when init, which looks better.
385 value = extent[1];
386 }
387 if (value < extent[0]) {
388 value = extent[0];
389 }
390
391 option.value = value;
392
393 if (useHandle) {
394 option.status = axisInfo.axis.scale.isBlank() ? 'hide' : 'show';
395 }
396}
397
398export function getAxisInfo(axisModel: AxisBaseModel) {
399 const coordSysAxesInfo = (axisModel.ecModel.getComponent('axisPointer') as AxisPointerModel || {})

Callers

nothing calls this directly

Calls 5

isHandleTriggerFunction · 0.85
getAxisInfoFunction · 0.70
getExtentMethod · 0.65
getMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…