@@ -31,7 +31,8 @@ import { LineShape } from 'zrender/src/graphic/shape/Line';
3131import { subPixelOptimize } from 'zrender/src/graphic/helper/subPixelOptimize' ;
3232import { Group , Text , Rect , Line , XY , setTooltipConfig , expandOrShrinkRect } from '../../util/graphic' ;
3333import { clearTmpModel , ListIterator } from '../../util/model' ;
34- import { clone , retrieve2 } from 'zrender/src/core/util' ;
34+ import { clone , retrieve2 , isFunction , isString } from 'zrender/src/core/util' ;
35+ import { formatTplSimple } from '../../util/format' ;
3536import { invert } from 'zrender/src/core/matrix' ;
3637import { MatrixBodyCorner , MatrixBodyOrCornerKind } from '../../coord/matrix/MatrixBodyCorner' ;
3738import { setLabelStyle } from '../../label/labelStyle' ;
@@ -289,12 +290,33 @@ function createMatrixCell(
289290 let cellText : Text | NullUndefined ;
290291
291292 if ( textValue != null ) {
292- const text = textValue + '' ;
293+ let text = textValue + '' ;
293294 _tmpCellLabelModel . option = cellOption ? cellOption . label : null ;
294295 _tmpCellLabelModel . parentModel = parentLabelModel ;
295296 // This is to accept `option.textStyle` as the default.
296297 _tmpCellLabelModel . ecModel = ecModel ;
297298
299+ const formatter = _tmpCellLabelModel . getShallow ( 'formatter' ) ;
300+ if ( formatter ) {
301+ const params = {
302+ componentType : 'matrix' as const ,
303+ componentIndex : matrixModel . componentIndex ,
304+ name : text ,
305+ value : textValue as unknown ,
306+ xyLocator : xyLocator . slice ( ) as MatrixXYLocator [ ] ,
307+ $vars : [ 'name' , 'value' , 'xyLocator' ] as const
308+ } ;
309+ if ( isFunction ( formatter ) ) {
310+ const formattedText = formatter ( params ) ;
311+ if ( formattedText != null ) {
312+ text = formattedText + '' ;
313+ }
314+ }
315+ else if ( isString ( formatter ) ) {
316+ text = formatTplSimple ( formatter , params ) ;
317+ }
318+ }
319+
298320 setLabelStyle (
299321 cellRect ,
300322 // Currently do not support other states (`emphasis`, `select`, `blur`)
0 commit comments