(
axis: Axis,
baseTooltipModel: Model<TooltipOption>,
globalAxisPointerModel: AxisPointerModel,
ecModel: GlobalModel,
fromTooltip: boolean | 'cross',
triggerTooltip: boolean
)
| 231 | } |
| 232 | |
| 233 | function makeAxisPointerModel( |
| 234 | axis: Axis, |
| 235 | baseTooltipModel: Model<TooltipOption>, |
| 236 | globalAxisPointerModel: AxisPointerModel, |
| 237 | ecModel: GlobalModel, |
| 238 | fromTooltip: boolean | 'cross', |
| 239 | triggerTooltip: boolean |
| 240 | ) { |
| 241 | const tooltipAxisPointerModel = baseTooltipModel.getModel('axisPointer'); |
| 242 | const fields = [ |
| 243 | 'type', 'snap', 'lineStyle', 'shadowStyle', 'label', |
| 244 | 'animation', 'animationDurationUpdate', 'animationEasingUpdate', 'z' |
| 245 | ] as const; |
| 246 | const volatileOption = {} as Pick<AxisPointerOption, typeof fields[number]>; |
| 247 | |
| 248 | each(fields, function (field) { |
| 249 | (volatileOption as any)[field] = clone(tooltipAxisPointerModel.get(field)); |
| 250 | }); |
| 251 | |
| 252 | // category axis do not auto snap, otherwise some tick that do not |
| 253 | // has value can not be hovered. value/time/log axis default snap if |
| 254 | // triggered from tooltip and trigger tooltip. |
| 255 | volatileOption.snap = axis.type !== 'category' && !!triggerTooltip; |
| 256 | |
| 257 | // Compatible with previous behavior, tooltip axis does not show label by default. |
| 258 | // Only these properties can be overridden from tooltip to axisPointer. |
| 259 | if (tooltipAxisPointerModel.get('type') === 'cross') { |
| 260 | volatileOption.type = 'line'; |
| 261 | } |
| 262 | const labelOption = volatileOption.label || (volatileOption.label = {}); |
| 263 | // Follow the convention, do not show label when triggered by tooltip by default. |
| 264 | labelOption.show == null && (labelOption.show = false); |
| 265 | |
| 266 | if (fromTooltip === 'cross') { |
| 267 | // When 'cross', both axes show labels. |
| 268 | const tooltipAxisPointerLabelShow = tooltipAxisPointerModel.get(['label', 'show']); |
| 269 | labelOption.show = tooltipAxisPointerLabelShow != null ? tooltipAxisPointerLabelShow : true; |
| 270 | // If triggerTooltip, this is a base axis, which should better not use cross style |
| 271 | // (cross style is dashed by default) |
| 272 | if (!triggerTooltip) { |
| 273 | const crossStyle = volatileOption.lineStyle = tooltipAxisPointerModel.get('crossStyle'); |
| 274 | crossStyle && defaults(labelOption, crossStyle.textStyle); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | return axis.model.getModel( |
| 279 | 'axisPointer', |
| 280 | new Model(volatileOption, globalAxisPointerModel, ecModel) |
| 281 | ); |
| 282 | } |
| 283 | |
| 284 | function collectSeriesInfo(result: CollectionResult, ecModel: GlobalModel) { |
| 285 | // Prepare data for axis trigger |
no test coverage detected
searching dependent graphs…