(result: CollectionResult, ecModel: GlobalModel, api: ExtensionAPI)
| 114 | } |
| 115 | |
| 116 | function collectAxesInfo(result: CollectionResult, ecModel: GlobalModel, api: ExtensionAPI) { |
| 117 | const globalTooltipModel = ecModel.getComponent('tooltip'); |
| 118 | const globalAxisPointerModel = ecModel.getComponent('axisPointer') as AxisPointerModel; |
| 119 | // links can only be set on global. |
| 120 | const linksOption = globalAxisPointerModel.get('link', true) || []; |
| 121 | const linkGroups: LinkGroup[] = []; |
| 122 | |
| 123 | // Collect axes info. |
| 124 | each(api.getCoordinateSystems(), function (coordSys) { |
| 125 | // Some coordinate system do not support axes, like geo. |
| 126 | if (!coordSys.axisPointerEnabled) { |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | const coordSysKey = makeKey(coordSys.model); |
| 131 | const axesInfoInCoordSys: CollectionResult['coordSysAxesInfo'][string] = |
| 132 | result.coordSysAxesInfo[coordSysKey] = {}; |
| 133 | result.coordSysMap[coordSysKey] = coordSys; |
| 134 | |
| 135 | // Set tooltip (like 'cross') is a convenient way to show axisPointer |
| 136 | // for user. So we enable setting tooltip on coordSys model. |
| 137 | const coordSysModel = coordSys.model as ComponentModel<ComponentOption & { |
| 138 | tooltip: TooltipOption // TODO: Same with top level tooltip? |
| 139 | }>; |
| 140 | const baseTooltipModel = coordSysModel.getModel('tooltip', globalTooltipModel); |
| 141 | |
| 142 | each(coordSys.getAxes(), curry(saveTooltipAxisInfo, false, null)); |
| 143 | |
| 144 | // If axis tooltip used, choose tooltip axis for each coordSys. |
| 145 | // Notice this case: coordSys is `grid` but not `cartesian2D` here. |
| 146 | if (coordSys.getTooltipAxes |
| 147 | && globalTooltipModel |
| 148 | // If tooltip.showContent is set as false, tooltip will not |
| 149 | // show but axisPointer will show as normal. |
| 150 | && baseTooltipModel.get('show') |
| 151 | ) { |
| 152 | // Compatible with previous logic. But series.tooltip.trigger: 'axis' |
| 153 | // or series.data[n].tooltip.trigger: 'axis' are not support any more. |
| 154 | const triggerAxis = baseTooltipModel.get('trigger') === 'axis'; |
| 155 | const cross = baseTooltipModel.get(['axisPointer', 'type']) === 'cross'; |
| 156 | const tooltipAxes = coordSys.getTooltipAxes(baseTooltipModel.get(['axisPointer', 'axis'])); |
| 157 | if (triggerAxis || cross) { |
| 158 | each(tooltipAxes.baseAxes, curry( |
| 159 | saveTooltipAxisInfo, cross ? 'cross' : true, triggerAxis |
| 160 | )); |
| 161 | } |
| 162 | if (cross) { |
| 163 | each(tooltipAxes.otherAxes, curry(saveTooltipAxisInfo, 'cross', false)); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | // fromTooltip: true | false | 'cross' |
| 168 | // triggerTooltip: true | false | null |
| 169 | function saveTooltipAxisInfo( |
| 170 | fromTooltip: boolean | 'cross', |
| 171 | triggerTooltip: boolean, |
| 172 | axis: Axis |
| 173 | ) { |
no test coverage detected
searching dependent graphs…