(axisModel: AxisBaseModel)
| 350 | } |
| 351 | |
| 352 | export 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 | |
| 398 | export function getAxisInfo(axisModel: AxisBaseModel) { |
| 399 | const coordSysAxesInfo = (axisModel.ecModel.getComponent('axisPointer') as AxisPointerModel || {}) |
nothing calls this directly
no test coverage detected
searching dependent graphs…