Skip to content

Commit

Permalink
fix: optimize code in tooltip processor base
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Oct 10, 2024
1 parent 0ec3367 commit 4beeda7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vchart/src/component/tooltip/processor/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export abstract class BaseTooltipProcessor {
// 触发事件
this.component.event.emit(ChartEvent.tooltipShow, {
...params,
isEmptyTooltip: isNil(title?.key) && isNil(title?.value) && !content?.length,
isEmptyTooltip: isEmpty,
tooltipData: data,
activeType: this.activeType,
tooltip: this.component
Expand Down Expand Up @@ -117,10 +117,10 @@ export abstract class BaseTooltipProcessor {
if (isNil(this._cacheActiveSpec.handler) && isValid(tooltipSpec.handler)) {
this._cacheActiveSpec.handler = tooltipSpec.handler;
}
const updateTitle = this._cacheActiveSpec.updateTitle ?? tooltipSpec[this.activeType]?.updateTitle;
const updateContent = this._cacheActiveSpec.updateContent ?? tooltipSpec[this.activeType]?.updateContent;
const maxLineCount =
this._cacheActiveSpec.maxLineCount ?? tooltipSpec[this.activeType]?.maxLineCount ?? TOOLTIP_MAX_LINE_COUNT;
const specByType = tooltipSpec[this.activeType] ?? {};
const updateTitle = this._cacheActiveSpec.updateTitle ?? specByType.updateTitle;
const updateContent = this._cacheActiveSpec.updateContent ?? specByType.updateContent;
const maxLineCount = this._cacheActiveSpec.maxLineCount ?? specByType.maxLineCount ?? TOOLTIP_MAX_LINE_COUNT;

if (updateTitle) {
this._cacheActiveSpec.title =
Expand All @@ -131,7 +131,7 @@ export abstract class BaseTooltipProcessor {
this._cacheActiveSpec.content =
updateContent(this._cacheActiveSpec.content, data, params) ?? this._cacheActiveSpec.content;
} else if (maxLineCount >= 1 && this._cacheActiveSpec.content?.length > maxLineCount) {
const othersLine = this._cacheActiveSpec.othersLine ?? tooltipSpec[this.activeType]?.othersLine;
const othersLine = this._cacheActiveSpec.othersLine ?? specByType.othersLine;
const otherLine = othersLine
? {
...TOOLTIP_OTHERS_LINE,
Expand Down

0 comments on commit 4beeda7

Please sign in to comment.