Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add valueFormatter in tooltip #16332

Merged
merged 3 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { bind, each, clone, trim, isString, isFunction, isArray, isObject } from 'zrender/src/core/util';
import { bind, each, clone, trim, isString, isFunction, isArray, isObject, extend } from 'zrender/src/core/util';
import env from 'zrender/src/core/env';
import TooltipHTMLContent from './TooltipHTMLContent';
import TooltipRichContent from './TooltipRichContent';
Expand Down Expand Up @@ -585,11 +585,16 @@ class TooltipView extends ComponentView {
const seriesTooltipResult = normalizeTooltipFormatResult(
series.formatTooltip(dataIndex, true, null)
);
if (seriesTooltipResult.markupFragment) {
axisSectionMarkup.blocks.push(seriesTooltipResult.markupFragment);
const frag = seriesTooltipResult.frag;
if (frag) {
const valueFormatter = buildTooltipModel(
[series as Model<TooltipableOption>],
globalTooltipModel
).get('valueFormatter');
axisSectionMarkup.blocks.push(valueFormatter ? extend({ valueFormatter }, frag) : frag);
}
if (seriesTooltipResult.markupText) {
markupTextArrLegacy.push(seriesTooltipResult.markupText);
if (seriesTooltipResult.text) {
markupTextArrLegacy.push(seriesTooltipResult.text);
}
cbParamsList.push(cbParams);
});
Expand Down Expand Up @@ -682,16 +687,17 @@ class TooltipView extends ComponentView {
dataModel.formatTooltip(dataIndex, false, dataType)
);
const orderMode = tooltipModel.get('order');
const markupText = seriesTooltipResult.markupFragment
? buildTooltipMarkup(
seriesTooltipResult.markupFragment,
const valueFormatter = tooltipModel.get('valueFormatter');
const frag = seriesTooltipResult.frag;
const markupText = frag ? buildTooltipMarkup(
valueFormatter ? extend({ valueFormatter }, frag) : frag,
markupStyleCreator,
renderMode,
orderMode,
ecModel.get('useUTC'),
tooltipModel.get('textStyle')
)
: seriesTooltipResult.markupText;
: seriesTooltipResult.text;

const asyncTicket = 'item_' + dataModel.name + '_' + dataIndex;

Expand Down
Loading